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