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