svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / gui / ViewProperties.java @ 37609
History | View | Annotate | Download (22.6 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.app.project.documents.view.gui; |
23 |
|
24 |
import java.awt.Color; |
25 |
import java.awt.Component; |
26 |
import java.awt.Dimension; |
27 |
import java.awt.GridLayout; |
28 |
import java.awt.event.ActionListener; |
29 |
import java.util.List; |
30 |
|
31 |
import javax.swing.JButton; |
32 |
import javax.swing.JColorChooser; |
33 |
import javax.swing.JComboBox; |
34 |
import javax.swing.JLabel; |
35 |
import javax.swing.JOptionPane; |
36 |
import javax.swing.JPanel; |
37 |
|
38 |
import org.cresques.cts.IProjection; |
39 |
|
40 |
import org.gvsig.andami.PluginServices; |
41 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
42 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
43 |
import org.gvsig.app.gui.JComboBoxUnits; |
44 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
45 |
import org.gvsig.app.project.Project; |
46 |
import org.gvsig.app.project.ProjectManager; |
47 |
import org.gvsig.app.project.documents.Document; |
48 |
import org.gvsig.app.project.documents.view.DefaultViewDocument; |
49 |
import org.gvsig.app.project.documents.view.ViewManager; |
50 |
import org.gvsig.fmap.mapcontext.MapContext; |
51 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
53 |
|
54 |
/**
|
55 |
* Dialogo donde se muestran las propiedades de una vista
|
56 |
*
|
57 |
* @author Fernando Gonz?lez Cort?s
|
58 |
*/
|
59 |
public class ViewProperties extends JPanel implements SingletonWindow { |
60 |
|
61 |
/**
|
62 |
*
|
63 |
*/
|
64 |
private static final long serialVersionUID = 5328865370833315385L; |
65 |
private javax.swing.JLabel jLabel = null; |
66 |
private javax.swing.JTextField txtName = null; |
67 |
private javax.swing.JLabel jLabel1 = null; |
68 |
private javax.swing.JTextField txtDate = null; |
69 |
private javax.swing.JLabel jLabel2 = null; |
70 |
private javax.swing.JTextField txtOwner = null; |
71 |
private javax.swing.JLabel jLabel4 = null; |
72 |
private javax.swing.JComboBox cmbMapUnits = null; |
73 |
private javax.swing.JLabel jLabel5 = null; |
74 |
private javax.swing.JComboBox cmbDistanceUnits = null; |
75 |
private javax.swing.JLabel jLabel6 = null; |
76 |
private javax.swing.JTextArea txtComments = null; |
77 |
private javax.swing.JLabel jLabel7 = null; |
78 |
private javax.swing.JLabel lblColor = null; |
79 |
|
80 |
private Color backColor = null; |
81 |
|
82 |
private JButton btnColor = null; |
83 |
private DefaultViewDocument view = null; |
84 |
private javax.swing.JScrollPane jScrollPane = null; |
85 |
private javax.swing.JPanel jPanel = null; |
86 |
private javax.swing.JPanel jPanel1 = null; |
87 |
private javax.swing.JPanel jPanel2 = null; |
88 |
private javax.swing.JPanel jPanel3 = null; |
89 |
|
90 |
private javax.swing.JLabel jLabel3 = null; |
91 |
private javax.swing.JLabel jLabelSep1 = null; |
92 |
protected CRSSelectPanel jPanelProj = null; |
93 |
private AcceptCancelPanel okCancelPanel = null; |
94 |
private boolean isAcceppted = false; |
95 |
private JLabel jLabel8 = null; |
96 |
private JComboBox cmbDistanceArea = null; |
97 |
|
98 |
/**
|
99 |
* This is the default constructor
|
100 |
*
|
101 |
* @param f
|
102 |
* Frame padre del dialogo
|
103 |
* @param v
|
104 |
* Vista que se representa
|
105 |
*/
|
106 |
public ViewProperties(DefaultViewDocument v) {
|
107 |
view = v; |
108 |
initialize(); |
109 |
} |
110 |
|
111 |
/**
|
112 |
* This method initializes this
|
113 |
*/
|
114 |
private void initialize() { |
115 |
this.setSize(386, 436); |
116 |
java.awt.FlowLayout layFlowLayout3 = new java.awt.FlowLayout();
|
117 |
layFlowLayout3.setHgap(0);
|
118 |
setLayout(layFlowLayout3); |
119 |
this.setPreferredSize(new java.awt.Dimension(365, 463)); |
120 |
add(getJPanel(), null);
|
121 |
add(getJPanel1(), null);
|
122 |
add(getJPanel2(), null);
|
123 |
add(getJPanel3(), null);
|
124 |
add(getJLabelSep1(), null);
|
125 |
this.add(getJPanelProj(), null); |
126 |
this.add(getJLabel6(), null); |
127 |
add(getJScrollPane(), null);
|
128 |
|
129 |
this.add(getJLabel7(), null); |
130 |
this.add(getLblColor(), null); |
131 |
this.add(getBtnColor(), null); |
132 |
|
133 |
add(getJLabel3(), null);
|
134 |
this.add(getOkCancelPanel(), null); |
135 |
txtName.setText(view.getName()); |
136 |
txtDate.setText(view.getCreationDate()); |
137 |
txtOwner.setText(view.getOwner()); |
138 |
|
139 |
cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort() |
140 |
.getMapUnits()); |
141 |
cmbDistanceUnits.setSelectedIndex(view.getMapContext().getViewPort() |
142 |
.getDistanceUnits()); |
143 |
cmbDistanceArea.setSelectedIndex(view.getMapContext().getViewPort() |
144 |
.getDistanceArea()); |
145 |
txtComments.setText(view.getComment()); |
146 |
|
147 |
lblColor.setBackground(view.getMapContext().getViewPort() |
148 |
.getBackColor()); |
149 |
} |
150 |
|
151 |
/**
|
152 |
* This method initializes jLabel
|
153 |
*
|
154 |
* @return javax.swing.JLabel
|
155 |
*/
|
156 |
private javax.swing.JLabel getJLabel() {
|
157 |
if (jLabel == null) { |
158 |
jLabel = new javax.swing.JLabel();
|
159 |
jLabel.setText(PluginServices.getText(this, "nombre") + ":"); |
160 |
} |
161 |
|
162 |
return jLabel;
|
163 |
} |
164 |
|
165 |
private javax.swing.JLabel getJLabelSep1() {
|
166 |
if (jLabelSep1 == null) { |
167 |
jLabelSep1 = new javax.swing.JLabel();
|
168 |
jLabelSep1.setPreferredSize(new java.awt.Dimension(200, 10)); |
169 |
} |
170 |
return jLabelSep1;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* This method initializes txtName
|
175 |
*
|
176 |
* @return javax.swing.JTextField
|
177 |
*/
|
178 |
private javax.swing.JTextField getTxtName() {
|
179 |
if (txtName == null) { |
180 |
txtName = new javax.swing.JTextField();
|
181 |
txtName.setPreferredSize(new java.awt.Dimension(200, 20)); |
182 |
} |
183 |
|
184 |
return txtName;
|
185 |
} |
186 |
|
187 |
/**
|
188 |
* This method initializes jLabel1
|
189 |
*
|
190 |
* @return javax.swing.JLabel
|
191 |
*/
|
192 |
private javax.swing.JLabel getJLabel1() {
|
193 |
if (jLabel1 == null) { |
194 |
jLabel1 = new javax.swing.JLabel();
|
195 |
jLabel1 |
196 |
.setText(PluginServices.getText(this, "creation_date") + ":"); |
197 |
} |
198 |
|
199 |
return jLabel1;
|
200 |
} |
201 |
|
202 |
/**
|
203 |
* This method initializes txtDate
|
204 |
*
|
205 |
* @return javax.swing.JTextField
|
206 |
*/
|
207 |
private javax.swing.JTextField getTxtDate() {
|
208 |
if (txtDate == null) { |
209 |
txtDate = new javax.swing.JTextField();
|
210 |
txtDate.setPreferredSize(new java.awt.Dimension(200, 20)); |
211 |
txtDate.setEditable(false);
|
212 |
txtDate.setBackground(java.awt.Color.white); |
213 |
} |
214 |
|
215 |
return txtDate;
|
216 |
} |
217 |
|
218 |
/**
|
219 |
* This method initializes jLabel2
|
220 |
*
|
221 |
* @return javax.swing.JLabel
|
222 |
*/
|
223 |
private javax.swing.JLabel getJLabel2() {
|
224 |
if (jLabel2 == null) { |
225 |
jLabel2 = new javax.swing.JLabel();
|
226 |
jLabel2.setText(PluginServices.getText(this, "owner") + ":"); |
227 |
} |
228 |
|
229 |
return jLabel2;
|
230 |
} |
231 |
|
232 |
/**
|
233 |
* This method initializes txtOwner
|
234 |
*
|
235 |
* @return javax.swing.JTextField
|
236 |
*/
|
237 |
private javax.swing.JTextField getTxtOwner() {
|
238 |
if (txtOwner == null) { |
239 |
txtOwner = new javax.swing.JTextField();
|
240 |
txtOwner.setPreferredSize(new java.awt.Dimension(200, 20)); |
241 |
} |
242 |
|
243 |
return txtOwner;
|
244 |
} |
245 |
|
246 |
/**
|
247 |
* This method initializes jLabel4
|
248 |
*
|
249 |
* @return javax.swing.JLabel
|
250 |
*/
|
251 |
private javax.swing.JLabel getJLabel4() {
|
252 |
if (jLabel4 == null) { |
253 |
jLabel4 = new javax.swing.JLabel();
|
254 |
jLabel4.setText(PluginServices.getText(this, "map_units") + ":"); |
255 |
jLabel4.setName("jLabel4");
|
256 |
} |
257 |
|
258 |
return jLabel4;
|
259 |
} |
260 |
|
261 |
/**
|
262 |
* This method initializes cmbMapUnits
|
263 |
*
|
264 |
* @return javax.swing.JComboBox
|
265 |
*/
|
266 |
private javax.swing.JComboBox getCmbMapUnits() {
|
267 |
if (cmbMapUnits == null |
268 |
|| MapContext.getDistanceNames().length > cmbMapUnits |
269 |
.getItemCount()) { |
270 |
cmbMapUnits = new JComboBoxUnits(false); |
271 |
|
272 |
cmbMapUnits.setPreferredSize(new java.awt.Dimension(200, 20)); |
273 |
IProjection proj = view.getProjection(); |
274 |
if (!proj.isProjected()) {
|
275 |
cmbMapUnits.setSelectedItem(PluginServices.getText(this,
|
276 |
"Grados")); // deegree |
277 |
cmbMapUnits.setEnabled(false);
|
278 |
} else {
|
279 |
if (!(cmbMapUnits.getItemCount() == MapContext
|
280 |
.getDistanceNames().length)) { |
281 |
cmbMapUnits.removeItem(PluginServices.getText(this,
|
282 |
"Grados")); // deegree |
283 |
view.getMapContext().getViewPort().setMapUnits(1);
|
284 |
} |
285 |
cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort() |
286 |
.getMapUnits()); |
287 |
cmbMapUnits.setEnabled(true);
|
288 |
} |
289 |
cmbMapUnits.setSelectedIndex(view.getMapContext().getViewPort() |
290 |
.getMapUnits()); |
291 |
} |
292 |
|
293 |
return cmbMapUnits;
|
294 |
} |
295 |
|
296 |
/**
|
297 |
* This method initializes jLabel5
|
298 |
*
|
299 |
* @return javax.swing.JLabel
|
300 |
*/
|
301 |
private javax.swing.JLabel getJLabel5() {
|
302 |
if (jLabel5 == null) { |
303 |
jLabel5 = new javax.swing.JLabel();
|
304 |
jLabel5.setText(PluginServices.getText(this, "distance_units") |
305 |
+ ":");
|
306 |
jLabel5.setName("jLabel5");
|
307 |
} |
308 |
|
309 |
return jLabel5;
|
310 |
} |
311 |
|
312 |
/**
|
313 |
* This method initializes cmbDistanceUnits
|
314 |
*
|
315 |
* @return javax.swing.JComboBox
|
316 |
*/
|
317 |
private javax.swing.JComboBox getCmbDistanceUnits() {
|
318 |
if (cmbDistanceUnits == null |
319 |
|| MapContext.getDistanceNames().length > cmbDistanceUnits |
320 |
.getItemCount()) { |
321 |
cmbDistanceUnits = new JComboBoxUnits(false); |
322 |
cmbDistanceUnits.setPreferredSize(new java.awt.Dimension(200, 20)); |
323 |
} |
324 |
|
325 |
return cmbDistanceUnits;
|
326 |
} |
327 |
|
328 |
/**
|
329 |
* This method initializes jLabel6
|
330 |
*
|
331 |
* @return javax.swing.JLabel
|
332 |
*/
|
333 |
private javax.swing.JLabel getJLabel6() {
|
334 |
if (jLabel6 == null) { |
335 |
jLabel6 = new javax.swing.JLabel();
|
336 |
jLabel6.setText(PluginServices.getText(this, "comentarios") + ":"); |
337 |
jLabel6.setPreferredSize(new java.awt.Dimension(340, 35)); |
338 |
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); |
339 |
jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); |
340 |
} |
341 |
|
342 |
return jLabel6;
|
343 |
} |
344 |
|
345 |
/**
|
346 |
* This method initializes txtComments
|
347 |
*
|
348 |
* @return javax.swing.JTextArea
|
349 |
*/
|
350 |
private javax.swing.JTextArea getTxtComments() {
|
351 |
if (txtComments == null) { |
352 |
txtComments = new javax.swing.JTextArea();
|
353 |
txtComments.setRows(1);
|
354 |
txtComments.setColumns(28);
|
355 |
} |
356 |
|
357 |
return txtComments;
|
358 |
} |
359 |
|
360 |
/**
|
361 |
* This method initializes jLabel7
|
362 |
*
|
363 |
* @return javax.swing.JLabel
|
364 |
*/
|
365 |
private javax.swing.JLabel getJLabel7() {
|
366 |
if (jLabel7 == null) { |
367 |
jLabel7 = new javax.swing.JLabel();
|
368 |
jLabel7.setText(PluginServices.getText(this, "background_color") |
369 |
+ ":");
|
370 |
jLabel7.setPreferredSize(new java.awt.Dimension(190, 16)); |
371 |
} |
372 |
|
373 |
return jLabel7;
|
374 |
} |
375 |
|
376 |
/**
|
377 |
* This method initializes lblColor
|
378 |
*
|
379 |
* @return javax.swing.JLabel
|
380 |
*/
|
381 |
private javax.swing.JLabel getLblColor() {
|
382 |
if (lblColor == null) { |
383 |
lblColor = new javax.swing.JLabel();
|
384 |
lblColor.setText("");
|
385 |
lblColor.setPreferredSize(new java.awt.Dimension(30, 16)); |
386 |
Color theColor = view.getMapContext().getViewPort().getBackColor();
|
387 |
backColor = theColor; |
388 |
if (theColor == null) { |
389 |
theColor = Color.WHITE;
|
390 |
} |
391 |
lblColor.setBackground(theColor); |
392 |
lblColor.setOpaque(true);
|
393 |
} |
394 |
|
395 |
return lblColor;
|
396 |
} |
397 |
|
398 |
/**
|
399 |
* This method initializes btnColor
|
400 |
*
|
401 |
* @return javax.swing.JButton
|
402 |
*/
|
403 |
private JButton getBtnColor() { |
404 |
if (btnColor == null) { |
405 |
btnColor = |
406 |
ToolsSwingLocator.getUsabilitySwingManager().createJButton(); |
407 |
|
408 |
btnColor.setText("...");
|
409 |
|
410 |
btnColor.addActionListener(new java.awt.event.ActionListener() {
|
411 |
|
412 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
413 |
Color ret =
|
414 |
JColorChooser.showDialog(ViewProperties.this,
|
415 |
PluginServices.getText(this, "background_color"), |
416 |
lblColor.getBackground()); |
417 |
|
418 |
if (ret != null) { |
419 |
lblColor.setBackground(ret); |
420 |
backColor = ret; |
421 |
} else {
|
422 |
lblColor.setBackground(Color.WHITE);
|
423 |
} |
424 |
} |
425 |
}); |
426 |
} |
427 |
|
428 |
return btnColor;
|
429 |
} |
430 |
|
431 |
/**
|
432 |
* This method initializes jScrollPane
|
433 |
*
|
434 |
* @return javax.swing.JScrollPane
|
435 |
*/
|
436 |
private javax.swing.JScrollPane getJScrollPane() {
|
437 |
if (jScrollPane == null) { |
438 |
jScrollPane = new javax.swing.JScrollPane();
|
439 |
jScrollPane.setViewportView(getTxtComments()); |
440 |
jScrollPane.setPreferredSize(new java.awt.Dimension(340, 70)); |
441 |
} |
442 |
|
443 |
return jScrollPane;
|
444 |
} |
445 |
|
446 |
/**
|
447 |
* This method initializes jPanel
|
448 |
*
|
449 |
* @return javax.swing.JPanel
|
450 |
*/
|
451 |
private javax.swing.JPanel getJPanel() {
|
452 |
if (jPanel == null) { |
453 |
jPanel = new javax.swing.JPanel();
|
454 |
|
455 |
GridLayout layout = new GridLayout(3, 1); |
456 |
layout.setVgap(5);
|
457 |
jPanel.setLayout(layout); |
458 |
|
459 |
jPanel.add(getJLabel(), null);
|
460 |
jPanel.add(getJLabel1(), null);
|
461 |
jPanel.add(getJLabel2(), null);
|
462 |
jPanel.setPreferredSize(new java.awt.Dimension(140, 80)); |
463 |
} |
464 |
|
465 |
return jPanel;
|
466 |
} |
467 |
|
468 |
/**
|
469 |
* This method initializes jPanel1
|
470 |
*
|
471 |
* @return javax.swing.JPanel
|
472 |
*/
|
473 |
private javax.swing.JPanel getJPanel1() {
|
474 |
if (jPanel1 == null) { |
475 |
jPanel1 = new javax.swing.JPanel();
|
476 |
|
477 |
java.awt.FlowLayout layFlowLayout2 = new java.awt.FlowLayout();
|
478 |
layFlowLayout2.setHgap(5);
|
479 |
layFlowLayout2.setAlignment(java.awt.FlowLayout.LEFT); |
480 |
jPanel1.setLayout(layFlowLayout2); |
481 |
jPanel1.add(getTxtName(), null);
|
482 |
jPanel1.add(getTxtDate(), null);
|
483 |
jPanel1.add(getTxtOwner(), null);
|
484 |
jPanel1.setPreferredSize(new java.awt.Dimension(210, 80)); |
485 |
} |
486 |
|
487 |
return jPanel1;
|
488 |
} |
489 |
|
490 |
/**
|
491 |
* This method initializes jPanel2
|
492 |
*
|
493 |
* @return javax.swing.JPanel
|
494 |
*/
|
495 |
private javax.swing.JPanel getJPanel2() {
|
496 |
if (jPanel2 == null) { |
497 |
jLabel8 = new JLabel(); |
498 |
jLabel8.setText("unidades_area");
|
499 |
GridLayout gridLayout = new GridLayout(); |
500 |
gridLayout.setRows(3);
|
501 |
jPanel2 = new javax.swing.JPanel();
|
502 |
|
503 |
jPanel2.setLayout(gridLayout); |
504 |
jPanel2.setPreferredSize(new java.awt.Dimension(140, 80)); |
505 |
jPanel2.add(getJLabel4(), null);
|
506 |
jPanel2.add(getJLabel5(), null);
|
507 |
jPanel2.add(jLabel8, null);
|
508 |
} |
509 |
|
510 |
return jPanel2;
|
511 |
} |
512 |
|
513 |
/**
|
514 |
* This method initializes jPanel3
|
515 |
*
|
516 |
* @return javax.swing.JPanel
|
517 |
*/
|
518 |
private javax.swing.JPanel getJPanel3() {
|
519 |
if (jPanel3 == null) { |
520 |
jPanel3 = new javax.swing.JPanel();
|
521 |
|
522 |
java.awt.FlowLayout layFlowLayout6 = new java.awt.FlowLayout();
|
523 |
layFlowLayout6.setAlignment(java.awt.FlowLayout.LEFT); |
524 |
jPanel3.setLayout(layFlowLayout6); |
525 |
jPanel3.add(getCmbMapUnits(), null);
|
526 |
jPanel3.add(getCmbDistanceUnits(), null);
|
527 |
jPanel3.setPreferredSize(new java.awt.Dimension(210, 80)); |
528 |
jPanel3.add(getCmbDistanceArea(), null);
|
529 |
} |
530 |
|
531 |
return jPanel3;
|
532 |
} |
533 |
|
534 |
/**
|
535 |
* This method initializes jLabel3
|
536 |
*
|
537 |
* @return javax.swing.JLabel
|
538 |
*/
|
539 |
private javax.swing.JLabel getJLabel3() {
|
540 |
if (jLabel3 == null) { |
541 |
jLabel3 = new javax.swing.JLabel();
|
542 |
jLabel3.setText("");
|
543 |
jLabel3.setPreferredSize(new java.awt.Dimension(30, 0)); |
544 |
} |
545 |
|
546 |
return jLabel3;
|
547 |
} |
548 |
|
549 |
/**
|
550 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
551 |
*/
|
552 |
public WindowInfo getWindowInfo() {
|
553 |
WindowInfo m_viewinfo = new WindowInfo();
|
554 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_vista")); |
555 |
m_viewinfo.setHeight(410);
|
556 |
return m_viewinfo;
|
557 |
} |
558 |
|
559 |
/**
|
560 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
561 |
*/
|
562 |
public void viewActivated() { |
563 |
// FIXME: jjdc este metodo sobra ? esta vacio.
|
564 |
} |
565 |
|
566 |
/**
|
567 |
* This method initializes jPanel4
|
568 |
*
|
569 |
* @return javax.swing.JPanel
|
570 |
*/
|
571 |
private CRSSelectPanel getJPanelProj() {
|
572 |
if (jPanelProj == null) { |
573 |
IProjection proj = view.getProjection(); |
574 |
jPanelProj = CRSSelectPanel.getPanel(proj); |
575 |
jPanelProj.setPreferredSize(new java.awt.Dimension(330, 35)); |
576 |
} |
577 |
return jPanelProj;
|
578 |
} |
579 |
|
580 |
/**
|
581 |
* @see org.gvsig.andami.ui.mdiManager.SingletonWindow#getWindowModel()
|
582 |
*/
|
583 |
public Object getWindowModel() { |
584 |
return view;
|
585 |
} |
586 |
|
587 |
/**
|
588 |
* This method initializes okCancelPanel
|
589 |
*
|
590 |
* @return javax.swing.JPanel
|
591 |
*/
|
592 |
private AcceptCancelPanel getOkCancelPanel() {
|
593 |
if (okCancelPanel == null) { |
594 |
ActionListener okAction, cancelAction;
|
595 |
okAction = new java.awt.event.ActionListener() {
|
596 |
|
597 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
598 |
String name = txtName.getText();
|
599 |
if (name == null || name.length() == 0) { |
600 |
return;
|
601 |
} |
602 |
Project project = |
603 |
ProjectManager.getInstance().getCurrentProject(); |
604 |
List<Document> views = |
605 |
project.getDocuments(ViewManager.TYPENAME); |
606 |
for (Document theView : views) { |
607 |
if (view.equals(theView)) {
|
608 |
continue;
|
609 |
} |
610 |
if (theView.getName().equals(name)) {
|
611 |
JOptionPane.showMessageDialog(
|
612 |
(Component) PluginServices.getMainFrame(),
|
613 |
PluginServices.getText(this,
|
614 |
"elemento_ya_existe"));
|
615 |
return;
|
616 |
} |
617 |
} |
618 |
|
619 |
view.setName(name); |
620 |
view.setCreationDate(txtDate.getText()); |
621 |
view.setOwner(txtOwner.getText()); |
622 |
view.setComment(txtComments.getText()); |
623 |
view.getMapContext().getViewPort() |
624 |
.setMapUnits(cmbMapUnits.getSelectedIndex()); |
625 |
view.getMapContext().getViewPort() |
626 |
.setDistanceUnits(cmbDistanceUnits.getSelectedIndex()); |
627 |
view.getMapContext().getViewPort() |
628 |
.setDistanceArea(cmbDistanceArea.getSelectedIndex()); |
629 |
view.setBackColor(backColor); |
630 |
|
631 |
//Select the projection
|
632 |
if (jPanelProj.isOkPressed()) {
|
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 |
view.setProjection(jPanelProj.getCurProj()); |
647 |
} |
648 |
|
649 |
isAcceppted = true;
|
650 |
PluginServices.getMDIManager().closeWindow( |
651 |
ViewProperties.this); |
652 |
} |
653 |
}; |
654 |
cancelAction = new java.awt.event.ActionListener() {
|
655 |
|
656 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
657 |
isAcceppted = false;
|
658 |
PluginServices.getMDIManager().closeWindow( |
659 |
ViewProperties.this); |
660 |
} |
661 |
}; |
662 |
okCancelPanel = new AcceptCancelPanel(okAction, cancelAction);
|
663 |
Dimension sz = this.getSize(); |
664 |
sz.setSize((int) sz.getWidth() - 20, (int) sz.getHeight()); |
665 |
okCancelPanel.setPreferredSize(sz); |
666 |
} |
667 |
return okCancelPanel;
|
668 |
} |
669 |
|
670 |
public boolean isAcceppted() { |
671 |
return isAcceppted;
|
672 |
} |
673 |
|
674 |
/**
|
675 |
* This method initializes jComboBox
|
676 |
*
|
677 |
* @return javax.swing.JComboBox
|
678 |
*/
|
679 |
private JComboBox getCmbDistanceArea() { |
680 |
String[] names = MapContext.getAreaNames(); |
681 |
if (cmbDistanceArea == null |
682 |
|| names.length > cmbDistanceArea.getItemCount()) { |
683 |
for (int i = 0; i < names.length; i++) { |
684 |
names[i] = |
685 |
PluginServices.getText(this, names[i])
|
686 |
+ MapContext.getOfLinear(i); |
687 |
} |
688 |
cmbDistanceArea = new javax.swing.JComboBox(names);
|
689 |
cmbDistanceArea.setPreferredSize(new java.awt.Dimension(200, 20)); |
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 |
public Object getWindowProfile() { |
707 |
return WindowInfo.PROPERTIES_PROFILE;
|
708 |
} |
709 |
|
710 |
} // @jve:decl-index=0:visual-constraint="10,10"
|