svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FThemePropertiesDialog.java @ 6877
History | View | Annotate | Download (13.9 KB)
1 |
/*
|
---|---|
2 |
* Created on 31-may-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.gui; |
48 |
|
49 |
import java.text.NumberFormat; |
50 |
import java.text.ParseException; |
51 |
|
52 |
import javax.swing.JLabel; |
53 |
import javax.swing.JPanel; |
54 |
import javax.swing.JTextField; |
55 |
|
56 |
import com.hardcode.gdbms.engine.data.DataSource; |
57 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
58 |
import com.iver.andami.PluginServices; |
59 |
import com.iver.andami.messages.NotificationManager; |
60 |
import com.iver.andami.ui.mdiManager.IWindow; |
61 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
62 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
63 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
64 |
import com.iver.cit.gvsig.project.ProjectView; |
65 |
/**
|
66 |
* Di?logo de propiedades del tema.
|
67 |
*
|
68 |
* @author Vicente Caballero Navarro
|
69 |
*/
|
70 |
public class FThemePropertiesDialog extends JPanel implements IWindow { |
71 |
private javax.swing.JPanel jContentPane = null; |
72 |
private javax.swing.JTabbedPane jTabbedPane = null; |
73 |
private javax.swing.JPanel phiperenlace = null; |
74 |
private javax.swing.JPanel phnorte = null; |
75 |
private javax.swing.JPanel phsur = null; |
76 |
private javax.swing.JLabel jLabel = null; |
77 |
private javax.swing.JComboBox jComboBox = null; |
78 |
private javax.swing.JLabel jLabel1 = null; |
79 |
private javax.swing.JComboBox jComboBox1 = null; |
80 |
private javax.swing.JPanel pbotones = null; |
81 |
private javax.swing.JButton baceptar = null; |
82 |
private javax.swing.JButton bcancelar = null; |
83 |
private javax.swing.JPanel pvisualizacion = null; |
84 |
private FLayer m_layer;
|
85 |
private javax.swing.JPanel pvnorte = null; |
86 |
private javax.swing.JPanel pvsur = null; |
87 |
private javax.swing.JLabel jLabel2 = null; |
88 |
private javax.swing.JLabel jLabel3 = null; |
89 |
private javax.swing.JTextField tminEscala = null; |
90 |
private javax.swing.JTextField tMaxScale = null; |
91 |
private ProjectView view;
|
92 |
|
93 |
private JLabel jLabel4 = null; |
94 |
private JTextField jTextField2 = null; |
95 |
private JPanel pvCenter = null; |
96 |
private JLabel jLabel5 = null; |
97 |
private JLabel jLabel6 = null; |
98 |
|
99 |
private NumberFormat nf = NumberFormat.getInstance(); |
100 |
|
101 |
/**
|
102 |
* This is the default constructor
|
103 |
*
|
104 |
* @param layer DOCUMENT ME!
|
105 |
* @param view DOCUMENT ME!
|
106 |
*/
|
107 |
public FThemePropertiesDialog(FLayer layer, ProjectView view) {
|
108 |
super();
|
109 |
this.view = view;
|
110 |
m_layer = layer; |
111 |
initialize(); |
112 |
} |
113 |
|
114 |
/**
|
115 |
* This method initializes this
|
116 |
*/
|
117 |
private void initialize() { |
118 |
this.setSize(367, 184); |
119 |
this.add(getJContentPane());
|
120 |
if (m_layer.getMinScale() != -1) |
121 |
getTminEscala().setText(nf.format(m_layer.getMinScale())); |
122 |
if (m_layer.getMaxScale() != -1) |
123 |
getTMaxScale().setText(nf.format(m_layer.getMaxScale())); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* This method initializes jContentPane
|
128 |
*
|
129 |
* @return javax.swing.JPanel
|
130 |
*/
|
131 |
private javax.swing.JPanel getJContentPane() {
|
132 |
if (jContentPane == null) { |
133 |
jContentPane = new javax.swing.JPanel();
|
134 |
jContentPane.setLayout(new java.awt.BorderLayout());
|
135 |
jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER); |
136 |
jContentPane.add(getPbotones(), java.awt.BorderLayout.SOUTH); |
137 |
} |
138 |
|
139 |
return jContentPane;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* This method initializes jTabbedPane
|
144 |
*
|
145 |
* @return javax.swing.JTabbedPane
|
146 |
*/
|
147 |
private javax.swing.JTabbedPane getJTabbedPane() {
|
148 |
if (jTabbedPane == null) { |
149 |
jTabbedPane = new javax.swing.JTabbedPane();
|
150 |
jTabbedPane.setPreferredSize(new java.awt.Dimension(320,140)); |
151 |
jTabbedPane.addTab(PluginServices.getText(this, "Hiperenlace"), |
152 |
null, getPhiperenlace(), null); |
153 |
jTabbedPane.addTab(PluginServices.getText(this, "Visualizacion"), |
154 |
null, getPvisualizacion(), null); |
155 |
} |
156 |
|
157 |
return jTabbedPane;
|
158 |
} |
159 |
|
160 |
/**
|
161 |
* This method initializes phiperenlace
|
162 |
*
|
163 |
* @return javax.swing.JPanel
|
164 |
*/
|
165 |
private javax.swing.JPanel getPhiperenlace() {
|
166 |
if (phiperenlace == null) { |
167 |
phiperenlace = new javax.swing.JPanel();
|
168 |
phiperenlace.setLayout(new java.awt.BorderLayout());
|
169 |
phiperenlace.setPreferredSize(new java.awt.Dimension(300,150)); |
170 |
phiperenlace.add(getPhnorte(), java.awt.BorderLayout.NORTH); |
171 |
phiperenlace.add(getPhsur(), java.awt.BorderLayout.CENTER); |
172 |
phiperenlace.setVisible(true);
|
173 |
} |
174 |
|
175 |
return phiperenlace;
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* This method initializes phnorte
|
180 |
*
|
181 |
* @return javax.swing.JPanel
|
182 |
*/
|
183 |
private javax.swing.JPanel getPhnorte() {
|
184 |
if (phnorte == null) { |
185 |
jLabel4 = new JLabel(); |
186 |
phnorte = new javax.swing.JPanel();
|
187 |
jLabel4.setText(PluginServices.getText(this,"extension")); |
188 |
phnorte.add(getJLabel(), null);
|
189 |
phnorte.add(getJComboBox(), null);
|
190 |
phnorte.add(jLabel4, null);
|
191 |
phnorte.add(getJTextField2(), null);
|
192 |
} |
193 |
|
194 |
return phnorte;
|
195 |
} |
196 |
|
197 |
/**
|
198 |
* This method initializes phsur
|
199 |
*
|
200 |
* @return javax.swing.JPanel
|
201 |
*/
|
202 |
private javax.swing.JPanel getPhsur() {
|
203 |
if (phsur == null) { |
204 |
phsur = new javax.swing.JPanel();
|
205 |
phsur.add(getJLabel1(), null);
|
206 |
phsur.add(getJComboBox1(), null);
|
207 |
} |
208 |
|
209 |
return phsur;
|
210 |
} |
211 |
|
212 |
/**
|
213 |
* This method initializes jLabel
|
214 |
*
|
215 |
* @return javax.swing.JLabel
|
216 |
*/
|
217 |
private javax.swing.JLabel getJLabel() {
|
218 |
if (jLabel == null) { |
219 |
jLabel = new javax.swing.JLabel();
|
220 |
jLabel.setText(PluginServices.getText(this, "Campo") + " "); |
221 |
} |
222 |
|
223 |
return jLabel;
|
224 |
} |
225 |
|
226 |
/**
|
227 |
* This method initializes jComboBox
|
228 |
*
|
229 |
* @return javax.swing.JComboBox
|
230 |
*/
|
231 |
private javax.swing.JComboBox getJComboBox() {
|
232 |
if (jComboBox == null) { |
233 |
try {
|
234 |
if (m_layer instanceof AlphanumericData) { |
235 |
AlphanumericData layer = (AlphanumericData) m_layer; |
236 |
DataSource ds;
|
237 |
ds = layer.getRecordset(); |
238 |
|
239 |
String[] names = new String[ds.getFieldCount()]; |
240 |
|
241 |
for (int i = 0; i < ds.getFieldCount(); i++) { |
242 |
names[i] = ds.getFieldName(i); |
243 |
} |
244 |
|
245 |
jComboBox = new javax.swing.JComboBox(names);
|
246 |
|
247 |
if (view.getSelectedField() != null) { |
248 |
jComboBox.setSelectedItem(view.getSelectedField()); |
249 |
} |
250 |
}else{
|
251 |
jComboBox = new javax.swing.JComboBox();
|
252 |
} |
253 |
} catch (DriverException e) {
|
254 |
NotificationManager.addError("No se pudo obtener la tabla", e);
|
255 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
256 |
NotificationManager.addError("No se pudo obtener la tabla", e);
|
257 |
} |
258 |
} |
259 |
|
260 |
return jComboBox;
|
261 |
} |
262 |
|
263 |
/**
|
264 |
* This method initializes jLabel1
|
265 |
*
|
266 |
* @return javax.swing.JLabel
|
267 |
*/
|
268 |
private javax.swing.JLabel getJLabel1() {
|
269 |
if (jLabel1 == null) { |
270 |
jLabel1 = new javax.swing.JLabel();
|
271 |
jLabel1.setText(PluginServices.getText(this, "Accion_Predefinida") + |
272 |
" ");
|
273 |
} |
274 |
|
275 |
return jLabel1;
|
276 |
} |
277 |
|
278 |
/**
|
279 |
* This method initializes jComboBox1
|
280 |
*
|
281 |
* @return javax.swing.JComboBox
|
282 |
*/
|
283 |
private javax.swing.JComboBox getJComboBox1() {
|
284 |
if (jComboBox1 == null) { |
285 |
jComboBox1 = new javax.swing.JComboBox();
|
286 |
jComboBox1.addItem(PluginServices.getText(this,
|
287 |
"Enlazar_a_ficheros_de_imagen"));
|
288 |
jComboBox1.addItem(PluginServices.getText(this,
|
289 |
"Enlazar_a_fichero_de_texto"));
|
290 |
if (view.getSelectedField() != null) { |
291 |
jComboBox1.setSelectedIndex(view.getTypeLink()); |
292 |
} |
293 |
} |
294 |
|
295 |
return jComboBox1;
|
296 |
} |
297 |
|
298 |
/**
|
299 |
* This method initializes pbotones
|
300 |
*
|
301 |
* @return javax.swing.JPanel
|
302 |
*/
|
303 |
private javax.swing.JPanel getPbotones() {
|
304 |
if (pbotones == null) { |
305 |
pbotones = new javax.swing.JPanel();
|
306 |
pbotones.add(getBaceptar(), null);
|
307 |
pbotones.add(getBcancelar(), null);
|
308 |
} |
309 |
|
310 |
return pbotones;
|
311 |
} |
312 |
|
313 |
/**
|
314 |
* This method initializes baceptar
|
315 |
*
|
316 |
* @return javax.swing.JButton
|
317 |
*/
|
318 |
private javax.swing.JButton getBaceptar() {
|
319 |
if (baceptar == null) { |
320 |
baceptar = new javax.swing.JButton();
|
321 |
baceptar.setText(PluginServices.getText(this, "Aceptar")); |
322 |
baceptar.addActionListener(new java.awt.event.ActionListener() {
|
323 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
324 |
view.setTypeLink(jComboBox1.getSelectedIndex()); |
325 |
if (jComboBox.getSelectedItem()!=null){ |
326 |
view.setSelectedField((jComboBox.getSelectedItem()).toString() |
327 |
.trim()); |
328 |
view.setExtLink(getJTextField2().getText()); |
329 |
} |
330 |
try
|
331 |
{ |
332 |
m_layer.setMinScale((nf.parse(getTminEscala().getText())).doubleValue()); |
333 |
} |
334 |
catch (ParseException ex) |
335 |
{ |
336 |
// No hacemos nada. Si mete algo mal, pasamos de
|
337 |
// lo que haya metido y a otra cosa.
|
338 |
if (getTminEscala().getText().compareTo("") == 0) |
339 |
m_layer.setMinScale(-1);
|
340 |
else
|
341 |
System.err.print(ex.getLocalizedMessage());
|
342 |
} |
343 |
try
|
344 |
{ |
345 |
m_layer.setMaxScale((nf.parse(getTMaxScale().getText())).doubleValue()); |
346 |
} |
347 |
catch (ParseException ex) |
348 |
{ |
349 |
if (getTMaxScale().getText().compareTo("") == 0) |
350 |
m_layer.setMaxScale(-1);
|
351 |
else
|
352 |
System.err.print(ex.getLocalizedMessage());
|
353 |
|
354 |
} |
355 |
PluginServices.getMDIManager().closeView(FThemePropertiesDialog.this); |
356 |
m_layer.getFMap().invalidate(); |
357 |
} |
358 |
}); |
359 |
} |
360 |
|
361 |
return baceptar;
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* This method initializes bcancelar
|
366 |
*
|
367 |
* @return javax.swing.JButton
|
368 |
*/
|
369 |
private javax.swing.JButton getBcancelar() {
|
370 |
if (bcancelar == null) { |
371 |
bcancelar = new javax.swing.JButton();
|
372 |
bcancelar.setText(PluginServices.getText(this, "Cancelar")); |
373 |
bcancelar.addActionListener(new java.awt.event.ActionListener() {
|
374 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
375 |
// View view =(View)App.instance.getMDIContext().getActiveView();
|
376 |
//view.getMapControl().setTool(MapControl.);
|
377 |
PluginServices.getMDIManager().closeView(FThemePropertiesDialog.this); |
378 |
} |
379 |
}); |
380 |
} |
381 |
|
382 |
return bcancelar;
|
383 |
} |
384 |
|
385 |
/**
|
386 |
* This method initializes pvisualizacion
|
387 |
*
|
388 |
* @return javax.swing.JPanel
|
389 |
*/
|
390 |
private javax.swing.JPanel getPvisualizacion() {
|
391 |
if (pvisualizacion == null) { |
392 |
pvisualizacion = new javax.swing.JPanel();
|
393 |
pvisualizacion.setLayout(new java.awt.BorderLayout());
|
394 |
pvisualizacion.setPreferredSize(new java.awt.Dimension(300,60)); |
395 |
pvisualizacion.add(getPvnorte(), java.awt.BorderLayout.NORTH); |
396 |
pvisualizacion.add(getPvCenter(), java.awt.BorderLayout.CENTER); |
397 |
pvisualizacion.add(getPvsur(), java.awt.BorderLayout.SOUTH); |
398 |
} |
399 |
|
400 |
return pvisualizacion;
|
401 |
} |
402 |
|
403 |
/**
|
404 |
* This method initializes pvnorte
|
405 |
*
|
406 |
* @return javax.swing.JPanel
|
407 |
*/
|
408 |
private javax.swing.JPanel getPvnorte() {
|
409 |
if (pvnorte == null) { |
410 |
jLabel6 = new JLabel(); |
411 |
jLabel5 = new JLabel(); |
412 |
pvnorte = new javax.swing.JPanel();
|
413 |
jLabel5.setText(m_layer.getName()); |
414 |
jLabel6.setText("Nombre de la capa : ");
|
415 |
pvnorte.add(jLabel6, null);
|
416 |
pvnorte.add(jLabel5, null);
|
417 |
} |
418 |
|
419 |
return pvnorte;
|
420 |
} |
421 |
|
422 |
/**
|
423 |
* This method initializes pvsur
|
424 |
*
|
425 |
* @return javax.swing.JPanel
|
426 |
*/
|
427 |
private javax.swing.JPanel getPvsur() {
|
428 |
if (pvsur == null) { |
429 |
pvsur = new javax.swing.JPanel();
|
430 |
pvsur.add(getJLabel3(), null);
|
431 |
pvsur.add(getTMaxScale(), null);
|
432 |
} |
433 |
|
434 |
return pvsur;
|
435 |
} |
436 |
|
437 |
/**
|
438 |
* This method initializes jLabel2
|
439 |
*
|
440 |
* @return javax.swing.JLabel
|
441 |
*/
|
442 |
private javax.swing.JLabel getJLabel2() {
|
443 |
if (jLabel2 == null) { |
444 |
jLabel2 = new javax.swing.JLabel();
|
445 |
jLabel2.setText(PluginServices.getText(this, "Escala_Minima") + |
446 |
" 1:");
|
447 |
} |
448 |
|
449 |
return jLabel2;
|
450 |
} |
451 |
|
452 |
/**
|
453 |
* This method initializes jLabel3
|
454 |
*
|
455 |
* @return javax.swing.JLabel
|
456 |
*/
|
457 |
private javax.swing.JLabel getJLabel3() {
|
458 |
if (jLabel3 == null) { |
459 |
jLabel3 = new javax.swing.JLabel();
|
460 |
jLabel3.setText(PluginServices.getText(this, "Escala_Maxima") + |
461 |
" 1:");
|
462 |
} |
463 |
|
464 |
return jLabel3;
|
465 |
} |
466 |
|
467 |
/**
|
468 |
* This method initializes tminEscala
|
469 |
*
|
470 |
* @return javax.swing.JTextField
|
471 |
*/
|
472 |
private javax.swing.JTextField getTminEscala() {
|
473 |
if (tminEscala == null) { |
474 |
tminEscala = new javax.swing.JTextField();
|
475 |
tminEscala.setPreferredSize(new java.awt.Dimension(150, 20)); |
476 |
} |
477 |
|
478 |
return tminEscala;
|
479 |
} |
480 |
|
481 |
/**
|
482 |
* This method initializes jTextField1
|
483 |
*
|
484 |
* @return javax.swing.JTextField
|
485 |
*/
|
486 |
private javax.swing.JTextField getTMaxScale() {
|
487 |
if (tMaxScale == null) { |
488 |
tMaxScale = new javax.swing.JTextField();
|
489 |
tMaxScale.setPreferredSize(new java.awt.Dimension(150, 20)); |
490 |
} |
491 |
|
492 |
return tMaxScale;
|
493 |
} |
494 |
|
495 |
/* (non-Javadoc)
|
496 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
497 |
*/
|
498 |
public ViewInfo getViewInfo() {
|
499 |
ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
500 |
m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_capa")); |
501 |
|
502 |
return m_viewinfo;
|
503 |
} |
504 |
|
505 |
/**
|
506 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#viewActivated()
|
507 |
*/
|
508 |
public void viewActivated() { |
509 |
} |
510 |
/**
|
511 |
* This method initializes jTextField2
|
512 |
*
|
513 |
* @return javax.swing.JTextField
|
514 |
*/
|
515 |
private JTextField getJTextField2() { |
516 |
if (jTextField2 == null) { |
517 |
jTextField2 = new JTextField(); |
518 |
jTextField2.setPreferredSize(new java.awt.Dimension(40,20)); |
519 |
if (view.getSelectedField() != null) { |
520 |
jTextField2.setText(view.getExtLink()); |
521 |
} |
522 |
} |
523 |
return jTextField2;
|
524 |
} |
525 |
/**
|
526 |
* This method initializes pvCenter
|
527 |
*
|
528 |
* @return javax.swing.JPanel
|
529 |
*/
|
530 |
private JPanel getPvCenter() { |
531 |
if (pvCenter == null) { |
532 |
pvCenter = new JPanel(); |
533 |
pvCenter.add(getJLabel2(), null);
|
534 |
pvCenter.add(getTminEscala(), null);
|
535 |
} |
536 |
return pvCenter;
|
537 |
} |
538 |
} // @jve:visual-info decl-index=0 visual-constraint="10,10"
|