svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / gui / GeneralViewPropertiesPage.java @ 47560
History | View | Annotate | Download (22.1 KB)
1 |
|
---|---|
2 |
|
3 |
package org.gvsig.app.project.documents.view.gui; |
4 |
|
5 |
import java.awt.BorderLayout; |
6 |
import java.awt.Color; |
7 |
import java.awt.Component; |
8 |
import java.awt.Dimension; |
9 |
import java.awt.GridBagConstraints; |
10 |
import java.awt.GridBagLayout; |
11 |
import java.awt.GridLayout; |
12 |
import java.awt.Insets; |
13 |
import java.util.List; |
14 |
|
15 |
import javax.swing.BorderFactory; |
16 |
import javax.swing.JButton; |
17 |
import javax.swing.JCheckBox; |
18 |
import javax.swing.JColorChooser; |
19 |
import javax.swing.JComboBox; |
20 |
import javax.swing.JComponent; |
21 |
import javax.swing.JLabel; |
22 |
import javax.swing.JOptionPane; |
23 |
import javax.swing.JPanel; |
24 |
|
25 |
import org.cresques.cts.IProjection; |
26 |
|
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.app.ApplicationLocator; |
29 |
import org.gvsig.app.gui.JComboBoxUnits; |
30 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
31 |
import org.gvsig.app.project.Project; |
32 |
import org.gvsig.app.project.ProjectManager; |
33 |
import org.gvsig.app.project.ProjectPreferences; |
34 |
import org.gvsig.app.project.documents.Document; |
35 |
import org.gvsig.app.project.documents.view.ViewDocument; |
36 |
import org.gvsig.app.project.documents.view.ViewManager; |
37 |
import org.gvsig.fmap.crs.CRSFactory; |
38 |
import org.gvsig.fmap.mapcontext.MapContext; |
39 |
import org.gvsig.i18n.Messages; |
40 |
import org.gvsig.propertypage.PropertiesPage; |
41 |
import org.gvsig.tools.ToolsLocator; |
42 |
import org.gvsig.tools.i18n.I18nManager; |
43 |
|
44 |
/**
|
45 |
* @author gvSIG team
|
46 |
*
|
47 |
*/
|
48 |
public class GeneralViewPropertiesPage extends JPanel implements PropertiesPage { |
49 |
|
50 |
/**
|
51 |
*
|
52 |
*/
|
53 |
private static final long serialVersionUID = 1356416393907133043L; |
54 |
|
55 |
private JPanel propertiesPanel; |
56 |
|
57 |
private javax.swing.JLabel jLabelName = null; |
58 |
private javax.swing.JTextField txtName = null; |
59 |
private javax.swing.JLabel jLabelDate = null; |
60 |
private javax.swing.JTextField txtDate = null; |
61 |
private javax.swing.JLabel jLabelOwner = null; |
62 |
private javax.swing.JTextField txtOwner = null; |
63 |
private javax.swing.JLabel jLabelMapUnits = null; |
64 |
private javax.swing.JComboBox cmbMapUnits = null; |
65 |
private javax.swing.JLabel jLabelDistanceUnits = null; |
66 |
private javax.swing.JComboBox cmbDistanceUnits = null; |
67 |
private javax.swing.JLabel jLabelAreaUnits = null; |
68 |
private javax.swing.JTextArea txtComments = null; |
69 |
private javax.swing.JLabel jLabelColor = null; |
70 |
private javax.swing.JLabel jLabelComments = null; |
71 |
private javax.swing.JPanel lblColor = null; |
72 |
|
73 |
private JCheckBox setAsDefCrsChk = null; |
74 |
|
75 |
private Color backColor = null; |
76 |
|
77 |
private JButton btnColor = null; |
78 |
private ViewDocument view = null; |
79 |
private javax.swing.JScrollPane jScrollPane = null; |
80 |
protected CRSSelectPanel jPanelProj = null; |
81 |
private boolean isAcceppted = false; |
82 |
private JComboBox cmbDistanceArea = null; |
83 |
|
84 |
/**
|
85 |
* @param view
|
86 |
*/
|
87 |
public GeneralViewPropertiesPage(ViewDocument view) {
|
88 |
super(new BorderLayout()); |
89 |
this.view = view;
|
90 |
initComponents(); |
91 |
} |
92 |
|
93 |
@Override
|
94 |
public void setData(Object data) { |
95 |
|
96 |
} |
97 |
|
98 |
@Override
|
99 |
public boolean whenAccept() { |
100 |
isAcceppted = true;
|
101 |
return whenApply();
|
102 |
} |
103 |
|
104 |
@Override
|
105 |
public boolean whenApply() { |
106 |
String name = txtName.getText();
|
107 |
if (name == null || name.length() == 0) { |
108 |
return false; |
109 |
} |
110 |
Project project = |
111 |
ProjectManager.getInstance().getCurrentProject(); |
112 |
List<Document> views = |
113 |
project.getDocuments(ViewManager.TYPENAME); |
114 |
for (Document theView : views) { |
115 |
if (view.equals(theView)) {
|
116 |
continue;
|
117 |
} |
118 |
if (theView.getName().equals(name)) {
|
119 |
JOptionPane.showMessageDialog(
|
120 |
(Component) PluginServices.getMainFrame(),
|
121 |
Messages.getText("elemento_ya_existe"));
|
122 |
return false; |
123 |
} |
124 |
} |
125 |
|
126 |
//FIXME: Parche provisional para permitir guardar otras propiedades de la vista en edici?n
|
127 |
if (!view.isLocked()) {
|
128 |
view.setName(name); |
129 |
view.setCreationDate(txtDate.getText()); |
130 |
view.setOwner(txtOwner.getText()); |
131 |
view.setComment(txtComments.getText()); |
132 |
view.getMapContext().getViewPort() |
133 |
.setMapUnits(cmbMapUnits.getSelectedIndex()); |
134 |
view.getMapContext().getViewPort() |
135 |
.setDistanceUnits(cmbDistanceUnits.getSelectedIndex()); |
136 |
view.getMapContext().getViewPort() |
137 |
.setDistanceArea(cmbDistanceArea.getSelectedIndex()); |
138 |
view.setBackColor(backColor); |
139 |
|
140 |
// Select the projection
|
141 |
if (jPanelProj.isOkPressed()) {
|
142 |
if (!jPanelProj.getCurProj().isProjected()) {
|
143 |
getCmbMapUnits() |
144 |
.setSelectedItem(Messages.getText("Grados"));
|
145 |
getCmbMapUnits().setEnabled(false);
|
146 |
} else {
|
147 |
if (getCmbMapUnits().getSelectedItem().equals(
|
148 |
Messages.getText("Grados"))) {
|
149 |
getCmbMapUnits().setSelectedIndex(1);
|
150 |
} |
151 |
getCmbMapUnits().setEnabled(true);
|
152 |
} |
153 |
view.setProjection(jPanelProj.getCurProj()); |
154 |
if (getSetAsDefaultCrsCheckbox().isSelected()) {
|
155 |
setAppDefaultCRS(jPanelProj.getCurProj().getAbrev()); |
156 |
} |
157 |
//Las siguientes l?neas est?n duplicadas a prop?sito
|
158 |
view.getMapContext().getViewPort() |
159 |
.setMapUnits(cmbMapUnits.getSelectedIndex()); |
160 |
} |
161 |
} |
162 |
|
163 |
return true; |
164 |
} |
165 |
|
166 |
@Override
|
167 |
public boolean whenCancel() { |
168 |
isAcceppted = false;
|
169 |
return true; |
170 |
} |
171 |
|
172 |
@Override
|
173 |
public String getTitle() { |
174 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
175 |
return i18nManager.getTranslation("General"); |
176 |
} |
177 |
|
178 |
@Override
|
179 |
public int getPriority() { |
180 |
return 1000; |
181 |
} |
182 |
|
183 |
@Override
|
184 |
public JComponent asJComponent() { |
185 |
return this; |
186 |
} |
187 |
|
188 |
private void initComponents() { |
189 |
this.add(getCenterPanel(), BorderLayout.NORTH); |
190 |
} |
191 |
|
192 |
private Component getCenterPanel() { |
193 |
if (propertiesPanel == null) { |
194 |
propertiesPanel = new JPanel(new GridBagLayout()); |
195 |
|
196 |
propertiesPanel.setLayout(new GridBagLayout()); |
197 |
propertiesPanel.setBorder(BorderFactory.createEmptyBorder(4, 5, 4, 5)); |
198 |
|
199 |
GridBagConstraints c = new GridBagConstraints(); |
200 |
c.insets = new Insets(2, 5, 2, 5); |
201 |
c.gridy = -1;
|
202 |
|
203 |
addRow(propertiesPanel, c, getJLabelName(), getTxtName()); |
204 |
addRow(propertiesPanel, c, getJLabelDate(), getTxtDate()); |
205 |
addRow(propertiesPanel, c, getJLabelOwner(), getTxtOwner()); |
206 |
addRow(propertiesPanel, c, getJLabelMapUnits(), getCmbMapUnits()); |
207 |
addRow(propertiesPanel, c, getJLabelDistanceUnits(), getCmbDistanceUnits()); |
208 |
addRow(propertiesPanel, c, getJLabelAreaUnits(), getCmbDistanceArea()); |
209 |
|
210 |
// some extra space
|
211 |
addRow(propertiesPanel, c, new JLabel(" "), new JLabel(" ")); |
212 |
|
213 |
GridLayout gl = new GridLayout(1,2); |
214 |
JPanel colorPanel = new JPanel(gl); |
215 |
colorPanel.add(getJLabelColor()); |
216 |
JPanel secondHalfPanel = new JPanel(new GridBagLayout()); |
217 |
|
218 |
GridBagConstraints c2 = new GridBagConstraints(); |
219 |
|
220 |
c2.fill = GridBagConstraints.BOTH;
|
221 |
c2.weightx = 1.0; //request any extra hor space |
222 |
c2.gridx = 0;
|
223 |
c2.gridwidth = 1;
|
224 |
c2.gridy = 0;
|
225 |
|
226 |
JPanel auxPanel = new JPanel(new GridLayout(1,2)); |
227 |
auxPanel.add(getLblColor(secondHalfPanel.getBackground())); |
228 |
auxPanel.add(new JLabel("")); |
229 |
secondHalfPanel.add(auxPanel, c2); |
230 |
|
231 |
c2.fill = GridBagConstraints.NONE;
|
232 |
c2.weightx = 0.0;
|
233 |
c2.gridx = 1;
|
234 |
secondHalfPanel.add(getBtnColor(), c2); |
235 |
|
236 |
colorPanel.add(secondHalfPanel); |
237 |
|
238 |
c.gridx = 0;
|
239 |
c.gridwidth = 2;
|
240 |
c.gridy++; |
241 |
propertiesPanel.add(colorPanel, c); |
242 |
c.gridwidth = 1;
|
243 |
|
244 |
c.anchor = GridBagConstraints.WEST;
|
245 |
c.weightx = 0.0d;
|
246 |
c.gridx = 0;
|
247 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
248 |
c.gridy++; |
249 |
c.weightx = 1.0d;
|
250 |
c.fill = GridBagConstraints.HORIZONTAL;
|
251 |
propertiesPanel.add(getJPanelProj(), c); |
252 |
|
253 |
// ============ set current as app default CRS
|
254 |
c.anchor = GridBagConstraints.CENTER;
|
255 |
c.gridy++; |
256 |
JPanel auxp = new JPanel(new BorderLayout()); |
257 |
auxp.add(getSetAsDefaultCrsCheckbox(), BorderLayout.CENTER);
|
258 |
propertiesPanel.add(auxp, c); |
259 |
// =============================
|
260 |
|
261 |
// some extra space
|
262 |
addRow(propertiesPanel, c, new JLabel(" "), new JLabel(" ")); |
263 |
|
264 |
c.anchor = GridBagConstraints.WEST;
|
265 |
c.weightx = 0.0d;
|
266 |
c.gridx = 0;
|
267 |
c.gridy++; |
268 |
propertiesPanel.add(getJLabelComments(), c); |
269 |
|
270 |
c.fill = GridBagConstraints.BOTH;
|
271 |
c.weightx = 1.0d;
|
272 |
c.gridy++; |
273 |
c.gridwidth = 2;
|
274 |
propertiesPanel.add(getJScrollPaneComments(), c); |
275 |
} |
276 |
return propertiesPanel;
|
277 |
} |
278 |
|
279 |
|
280 |
/**
|
281 |
* @return
|
282 |
*/
|
283 |
private JCheckBox getSetAsDefaultCrsCheckbox() { |
284 |
|
285 |
if (setAsDefCrsChk == null) { |
286 |
setAsDefCrsChk = new JCheckBox(Messages.getText( |
287 |
"_Set_this_CRS_as_app_default"));
|
288 |
updateSetAsDefaultCRSChk(); |
289 |
} |
290 |
return setAsDefCrsChk;
|
291 |
} |
292 |
|
293 |
|
294 |
private String getAppDefaultCRS() { |
295 |
ProjectPreferences pp = new ProjectPreferences();
|
296 |
IProjection curr_def = pp.getDefaultProjection(); |
297 |
return curr_def.getAbrev();
|
298 |
} |
299 |
|
300 |
private void setAppDefaultCRS(String abbrev) { |
301 |
IProjection proj = CRSFactory.getCRS(abbrev); |
302 |
ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
303 |
projectPreferences.setDefaultProjection(proj); |
304 |
} |
305 |
|
306 |
private void updateSetAsDefaultCRSChk() { |
307 |
|
308 |
IProjection view_proj = this.getJPanelProj().getCurProj();
|
309 |
String view_abbrev = view_proj.getAbrev();
|
310 |
|
311 |
String curr_app_crs_def = getAppDefaultCRS();
|
312 |
if (view_abbrev.compareToIgnoreCase(curr_app_crs_def) == 0) { |
313 |
// same as curr default
|
314 |
this.getSetAsDefaultCrsCheckbox().setSelected(true); |
315 |
this.getSetAsDefaultCrsCheckbox().setEnabled(false); |
316 |
} else {
|
317 |
this.getSetAsDefaultCrsCheckbox().setEnabled(true); |
318 |
this.getSetAsDefaultCrsCheckbox().setSelected(false); |
319 |
} |
320 |
} |
321 |
|
322 |
private void addRow(JComponent panel, GridBagConstraints c, JComponent label, JComponent text) { |
323 |
c.anchor = GridBagConstraints.WEST;
|
324 |
c.weightx = 0.0d;
|
325 |
c.gridx = 0;
|
326 |
c.gridy++; |
327 |
panel.add(label, c); |
328 |
|
329 |
c.fill = GridBagConstraints.HORIZONTAL;
|
330 |
c.weightx = 1.0d;
|
331 |
c.gridx = 1;
|
332 |
panel.add(text, c); |
333 |
} |
334 |
|
335 |
|
336 |
|
337 |
/**
|
338 |
* This method initializes jLabel
|
339 |
*
|
340 |
* @return javax.swing.JLabel
|
341 |
*/
|
342 |
private javax.swing.JLabel getJLabelName() {
|
343 |
if (jLabelName == null) { |
344 |
jLabelName = |
345 |
new javax.swing.JLabel(Messages.getText("nombre") + ":"); |
346 |
} |
347 |
|
348 |
return jLabelName;
|
349 |
} |
350 |
|
351 |
/**
|
352 |
* This method initializes txtName
|
353 |
*
|
354 |
* @return javax.swing.JTextField
|
355 |
*/
|
356 |
private javax.swing.JTextField getTxtName() {
|
357 |
if (txtName == null) { |
358 |
txtName = new javax.swing.JTextField(view.getName());
|
359 |
} |
360 |
|
361 |
return txtName;
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* This method initializes jLabel1
|
366 |
*
|
367 |
* @return javax.swing.JLabel
|
368 |
*/
|
369 |
private javax.swing.JLabel getJLabelDate() {
|
370 |
if (jLabelDate == null) { |
371 |
jLabelDate = |
372 |
new javax.swing.JLabel(Messages.getText("creation_date") + ":"); |
373 |
} |
374 |
|
375 |
return jLabelDate;
|
376 |
} |
377 |
|
378 |
/**
|
379 |
* This method initializes txtDate
|
380 |
*
|
381 |
* @return javax.swing.JTextField
|
382 |
*/
|
383 |
private javax.swing.JTextField getTxtDate() {
|
384 |
if (txtDate == null) { |
385 |
txtDate = new javax.swing.JTextField(view.getCreationDate());
|
386 |
txtDate.setEditable(false);
|
387 |
txtDate.setBackground(java.awt.Color.white); |
388 |
} |
389 |
|
390 |
return txtDate;
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* This method initializes jLabel2
|
395 |
*
|
396 |
* @return javax.swing.JLabel
|
397 |
*/
|
398 |
private javax.swing.JLabel getJLabelOwner() {
|
399 |
if (jLabelOwner == null) { |
400 |
jLabelOwner = |
401 |
new javax.swing.JLabel(Messages.getText("owner") + ":"); |
402 |
} |
403 |
|
404 |
return jLabelOwner;
|
405 |
} |
406 |
|
407 |
/**
|
408 |
* This method initializes txtOwner
|
409 |
*
|
410 |
* @return javax.swing.JTextField
|
411 |
*/
|
412 |
private javax.swing.JTextField getTxtOwner() {
|
413 |
if (txtOwner == null) { |
414 |
txtOwner = new javax.swing.JTextField(view.getOwner());
|
415 |
} |
416 |
|
417 |
return txtOwner;
|
418 |
} |
419 |
|
420 |
/**
|
421 |
* This method initializes jLabel4
|
422 |
*
|
423 |
* @return javax.swing.JLabel
|
424 |
*/
|
425 |
private javax.swing.JLabel getJLabelMapUnits() {
|
426 |
if (jLabelMapUnits == null) { |
427 |
jLabelMapUnits = |
428 |
new javax.swing.JLabel(Messages.getText("map_units") + ":"); |
429 |
} |
430 |
|
431 |
return jLabelMapUnits;
|
432 |
} |
433 |
|
434 |
/**
|
435 |
* This method initializes cmbMapUnits
|
436 |
*
|
437 |
* @return javax.swing.JComboBox
|
438 |
*/
|
439 |
private javax.swing.JComboBox getCmbMapUnits() {
|
440 |
if (cmbMapUnits == null |
441 |
|| MapContext.getDistanceNames().length > cmbMapUnits |
442 |
.getItemCount()) { |
443 |
cmbMapUnits = new JComboBoxUnits(false); |
444 |
|
445 |
IProjection proj = view.getProjection(); |
446 |
if (!proj.isProjected()) {
|
447 |
cmbMapUnits.setSelectedItem(Messages.getText("Grados")); // deegree |
448 |
cmbMapUnits.setEnabled(false);
|
449 |
} else {
|
450 |
if (!(cmbMapUnits.getItemCount() == MapContext
|
451 |
.getDistanceNames().length)) { |
452 |
cmbMapUnits.removeItem(Messages.getText("Grados")); // deegree |
453 |
view.getMapContext().getViewPort().setMapUnits(1);
|
454 |
} |
455 |
cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort() |
456 |
.getMapUnits()); |
457 |
cmbMapUnits.setEnabled(true);
|
458 |
} |
459 |
} |
460 |
|
461 |
return cmbMapUnits;
|
462 |
} |
463 |
|
464 |
/**
|
465 |
* This method initializes jLabel5
|
466 |
*
|
467 |
* @return javax.swing.JLabel
|
468 |
*/
|
469 |
private javax.swing.JLabel getJLabelDistanceUnits() {
|
470 |
if (jLabelDistanceUnits == null) { |
471 |
jLabelDistanceUnits = |
472 |
new javax.swing.JLabel(Messages.getText("distance_units") + ":"); |
473 |
} |
474 |
|
475 |
return jLabelDistanceUnits;
|
476 |
} |
477 |
|
478 |
/**
|
479 |
* This method initializes jLabel6
|
480 |
*
|
481 |
* @return javax.swing.JLabel
|
482 |
*/
|
483 |
private javax.swing.JLabel getJLabelAreaUnits() {
|
484 |
if (jLabelAreaUnits == null) { |
485 |
jLabelAreaUnits = |
486 |
new javax.swing.JLabel(Messages.getText("unidades_area") + ":"); |
487 |
} |
488 |
|
489 |
return jLabelAreaUnits;
|
490 |
} |
491 |
|
492 |
/**
|
493 |
* This method initializes cmbDistanceUnits
|
494 |
*
|
495 |
* @return javax.swing.JComboBox
|
496 |
*/
|
497 |
private javax.swing.JComboBox getCmbDistanceUnits() {
|
498 |
if (cmbDistanceUnits == null |
499 |
|| MapContext.getDistanceNames().length > cmbDistanceUnits |
500 |
.getItemCount()) { |
501 |
cmbDistanceUnits = new JComboBoxUnits(false); |
502 |
cmbDistanceUnits.setSelectedIndex(view.getMapContext() |
503 |
.getViewPort().getDistanceUnits()); |
504 |
} |
505 |
|
506 |
return cmbDistanceUnits;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* This method initializes jLabel6
|
511 |
*
|
512 |
* @return javax.swing.JLabel
|
513 |
*/
|
514 |
private javax.swing.JLabel getJLabelComments() {
|
515 |
if (jLabelComments == null) { |
516 |
jLabelComments = |
517 |
new javax.swing.JLabel(Messages.getText("comentarios") + ":"); |
518 |
jLabelComments |
519 |
.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
520 |
jLabelComments |
521 |
.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); |
522 |
} |
523 |
|
524 |
return jLabelComments;
|
525 |
} |
526 |
|
527 |
/**
|
528 |
* This method initializes txtComments
|
529 |
*
|
530 |
* @return javax.swing.JTextArea
|
531 |
*/
|
532 |
private javax.swing.JTextArea getTxtComments() {
|
533 |
if (txtComments == null) { |
534 |
txtComments = new javax.swing.JTextArea(view.getComment());
|
535 |
txtComments.setRows(3);
|
536 |
txtComments.setColumns(20);
|
537 |
} |
538 |
|
539 |
return txtComments;
|
540 |
} |
541 |
|
542 |
/**
|
543 |
* This method initializes jLabel7
|
544 |
*
|
545 |
* @return javax.swing.JLabel
|
546 |
*/
|
547 |
private javax.swing.JLabel getJLabelColor() {
|
548 |
if (jLabelColor == null) { |
549 |
jLabelColor = |
550 |
new javax.swing.JLabel(Messages.getText("background_color") |
551 |
+ ":");
|
552 |
} |
553 |
|
554 |
return jLabelColor;
|
555 |
} |
556 |
|
557 |
/**
|
558 |
* This method initializes lblColor
|
559 |
*
|
560 |
* @return javax.swing.JLabel
|
561 |
*/
|
562 |
private javax.swing.JPanel getLblColor(Color surround_color) { |
563 |
if (lblColor == null) { |
564 |
lblColor = new javax.swing.JPanel();
|
565 |
lblColor.setPreferredSize(new java.awt.Dimension(42, 21)); |
566 |
Color theColor = view.getMapContext().getViewPort().getBackColor();
|
567 |
backColor = theColor; |
568 |
if (theColor == null) { |
569 |
theColor = Color.WHITE;
|
570 |
} |
571 |
lblColor.setBackground(theColor); |
572 |
// lblColor.setBorder(BorderFactory.createLineBorder(surround_color, 3));
|
573 |
lblColor.setOpaque(true);
|
574 |
} |
575 |
|
576 |
return lblColor;
|
577 |
} |
578 |
|
579 |
/**
|
580 |
* This method initializes btnColor
|
581 |
*
|
582 |
* @return javax.swing.JButton
|
583 |
*/
|
584 |
private JButton getBtnColor() { |
585 |
if (btnColor == null) { |
586 |
btnColor = new JButton(); |
587 |
// ToolsSwingLocator.getUsabilitySwingManager().createJButton();
|
588 |
|
589 |
btnColor.setText("...");
|
590 |
|
591 |
btnColor.addActionListener(new java.awt.event.ActionListener() {
|
592 |
|
593 |
@Override
|
594 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
595 |
Color ret =
|
596 |
JColorChooser.showDialog(GeneralViewPropertiesPage.this,
|
597 |
Messages.getText("background_color"),
|
598 |
lblColor.getBackground()); |
599 |
|
600 |
if (ret != null) { |
601 |
lblColor.setBackground(ret); |
602 |
backColor = ret; |
603 |
} else {
|
604 |
lblColor.setBackground(Color.WHITE);
|
605 |
} |
606 |
} |
607 |
}); |
608 |
} |
609 |
|
610 |
return btnColor;
|
611 |
} |
612 |
|
613 |
/**
|
614 |
* This method initializes jScrollPane
|
615 |
*
|
616 |
* @return javax.swing.JScrollPane
|
617 |
*/
|
618 |
private javax.swing.JScrollPane getJScrollPaneComments() {
|
619 |
if (jScrollPane == null) { |
620 |
jScrollPane = new javax.swing.JScrollPane();
|
621 |
jScrollPane.setViewportView(getTxtComments()); |
622 |
Dimension dim = getTxtComments().getPreferredSize();
|
623 |
jScrollPane |
624 |
.setMinimumSize(new Dimension(dim.width, dim.height + 10)); |
625 |
} |
626 |
|
627 |
return jScrollPane;
|
628 |
} |
629 |
|
630 |
/**
|
631 |
* This method initializes jPanel4
|
632 |
*
|
633 |
* @return javax.swing.JPanel
|
634 |
*/
|
635 |
private CRSSelectPanel getJPanelProj() {
|
636 |
if (jPanelProj == null) { |
637 |
IProjection proj = view.getProjection(); |
638 |
jPanelProj = CRSSelectPanel.getPanel(proj); |
639 |
jPanelProj.addActionListener(new java.awt.event.ActionListener() {
|
640 |
|
641 |
@Override
|
642 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
643 |
if (jPanelProj.isOkPressed()) {
|
644 |
int numberOfLayers = view.getMapContext().getLayers().getLayersCount();
|
645 |
if(numberOfLayers > 0) { |
646 |
warningViewProjectionChange(); |
647 |
} |
648 |
|
649 |
if (!jPanelProj.getCurProj().isProjected()) {
|
650 |
getCmbMapUnits().setSelectedItem( |
651 |
PluginServices |
652 |
.getText(this, "Grados")); |
653 |
getCmbMapUnits().setEnabled(false);
|
654 |
} else {
|
655 |
if (getCmbMapUnits().getSelectedItem().equals(
|
656 |
PluginServices |
657 |
.getText(this, "Grados"))) { |
658 |
getCmbMapUnits().setSelectedIndex(1);
|
659 |
} |
660 |
getCmbMapUnits().setEnabled(true);
|
661 |
} |
662 |
updateSetAsDefaultCRSChk(); |
663 |
} |
664 |
} |
665 |
}); |
666 |
} |
667 |
return jPanelProj;
|
668 |
} |
669 |
|
670 |
private void warningViewProjectionChange() { |
671 |
JOptionPane.showMessageDialog(
|
672 |
(Component)PluginServices.getMainFrame(),
|
673 |
Messages.getText("view_contain_layers"));
|
674 |
} |
675 |
|
676 |
/**
|
677 |
* @return ViewDocument
|
678 |
* @see org.gvsig.andami.ui.mdiManager.SingletonWindow#getWindowModel()
|
679 |
*/
|
680 |
public Object getWindowModel() { |
681 |
return view;
|
682 |
} |
683 |
|
684 |
|
685 |
/**
|
686 |
* @return boolean
|
687 |
*/
|
688 |
public boolean isAcceppted() { |
689 |
return isAcceppted;
|
690 |
} |
691 |
|
692 |
/**
|
693 |
* This method initializes jComboBox
|
694 |
*
|
695 |
* @return javax.swing.JComboBox
|
696 |
*/
|
697 |
private JComboBox getCmbDistanceArea() { |
698 |
String[] names = MapContext.getAreaNames(); |
699 |
if (cmbDistanceArea == null |
700 |
|| names.length > cmbDistanceArea.getItemCount()) { |
701 |
for (int i = 0; i < names.length; i++) { |
702 |
names[i] = |
703 |
Messages.getText(names[i]) + MapContext.getOfLinear(i); |
704 |
} |
705 |
cmbDistanceArea = new javax.swing.JComboBox(names);
|
706 |
cmbDistanceArea.setEditable(false);
|
707 |
cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort() |
708 |
.getDistanceArea()); |
709 |
cmbDistanceArea |
710 |
.addActionListener(new java.awt.event.ActionListener() {
|
711 |
|
712 |
@Override
|
713 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
714 |
// view.getMapContext().getViewPort().setDistanceUnits(cmbDistanceUnits.getSelectedIndex());
|
715 |
} |
716 |
}); |
717 |
} |
718 |
|
719 |
return cmbDistanceArea;
|
720 |
|
721 |
} |
722 |
|
723 |
|
724 |
|
725 |
|
726 |
} |