root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / legend / gui / General.java @ 22072
History | View | Annotate | Download (25.1 KB)
1 |
/*
|
---|---|
2 |
* Created on 31-ene-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.project.documents.view.legend.gui; |
45 |
|
46 |
import java.awt.BorderLayout; |
47 |
import java.awt.ComponentOrientation; |
48 |
import java.awt.Dimension; |
49 |
import java.awt.FlowLayout; |
50 |
import java.awt.GridLayout; |
51 |
import java.awt.SystemColor; |
52 |
import java.awt.event.ActionEvent; |
53 |
import java.awt.event.ActionListener; |
54 |
import java.awt.geom.Rectangle2D; |
55 |
import java.text.NumberFormat; |
56 |
import java.text.ParseException; |
57 |
|
58 |
import javax.swing.BorderFactory; |
59 |
import javax.swing.ButtonGroup; |
60 |
import javax.swing.DefaultComboBoxModel; |
61 |
import javax.swing.JCheckBox; |
62 |
import javax.swing.JComboBox; |
63 |
import javax.swing.JLabel; |
64 |
import javax.swing.JPanel; |
65 |
import javax.swing.JRadioButton; |
66 |
import javax.swing.JScrollPane; |
67 |
import javax.swing.JTextArea; |
68 |
import javax.swing.JTextField; |
69 |
import javax.swing.border.BevelBorder; |
70 |
import javax.swing.border.EtchedBorder; |
71 |
import javax.swing.border.TitledBorder; |
72 |
|
73 |
import org.cresques.cts.ICoordTrans; |
74 |
import org.cresques.cts.IProjection; |
75 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
76 |
import org.gvsig.gui.beans.swing.JBlank; |
77 |
|
78 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
79 |
import com.hardcode.gdbms.engine.data.DataSource; |
80 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
81 |
import com.iver.andami.PluginServices; |
82 |
import com.iver.andami.messages.NotificationManager; |
83 |
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition; |
84 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
85 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
86 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
87 |
import com.iver.cit.gvsig.fmap.layers.FLyrDefault; |
88 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
89 |
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial; |
90 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
91 |
import com.iver.cit.gvsig.fmap.layers.VectorialDBAdapter; |
92 |
import com.iver.cit.gvsig.fmap.layers.VectorialFileAdapter; |
93 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
94 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
95 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
96 |
import com.iver.cit.gvsig.project.documents.view.legend.CreateSpatialIndexMonitorableTask; |
97 |
import com.iver.utiles.swing.threads.IMonitorableTask; |
98 |
|
99 |
|
100 |
|
101 |
/**
|
102 |
* This class implements an useful and intuitive graphic interface to change some
|
103 |
* properties of the layer. This class extends AbstractThemeManager. The properties
|
104 |
* that allow modified are the name of the layer, the scale, if the user want to use
|
105 |
* Spatial index or not and the HyperLink. Also shows a scroll with a little resume
|
106 |
* with the properties of the layer.
|
107 |
* @author jmorell
|
108 |
*
|
109 |
* TODO To change the template for this generated type comment go to
|
110 |
* Window - Preferences - Java - Code Style - Code Templates
|
111 |
*/
|
112 |
public class General extends AbstractThemeManagerPage { |
113 |
|
114 |
private static final long serialVersionUID = 1L; |
115 |
private FLayer layer;
|
116 |
private IProjectView view;
|
117 |
private NumberFormat nf = NumberFormat.getInstance(); |
118 |
private JPanel pnlLayerName = null; |
119 |
private GridBagLayoutPanel pnlScale = null; |
120 |
private JPanel pnlProperties = null; |
121 |
private JLabel lblLayerName = null; |
122 |
private JTextField txtLayerName = null; |
123 |
private JTextField txtMaxScale = null; |
124 |
private JTextArea propertiesTextArea = null; |
125 |
private JRadioButton rdBtnShowAlways = null; |
126 |
private JRadioButton rdBtnDoNotShow = null; |
127 |
private JTextField txtMinScale = null; |
128 |
private JComboBox cmbLinkField = null; |
129 |
private JTextField txtLinkExtension = null; |
130 |
private JComboBox cmbLinkType = null; |
131 |
private JCheckBox jCheckBoxSpatialIndex = null; |
132 |
private JPanel pnlHyperLink; |
133 |
private JLabel lblLinkExtension; |
134 |
private JLabel lblLinkField; |
135 |
private JLabel lblDefaultAction; |
136 |
private JPanel pnlFieldAndExtension; |
137 |
private JPanel pnlHyperLinkAction; |
138 |
private JScrollPane scrlProperties; |
139 |
|
140 |
/**
|
141 |
* This is the default constructor.
|
142 |
*/
|
143 |
public General() {
|
144 |
super();
|
145 |
initialize(); |
146 |
} |
147 |
/**
|
148 |
* This method initializes this
|
149 |
*
|
150 |
* @return void
|
151 |
*/
|
152 |
private void initialize() { |
153 |
this.setLayout(new BorderLayout()); |
154 |
GridBagLayoutPanel aux = new GridBagLayoutPanel();
|
155 |
aux.addComponent(getPnlLayerName()); |
156 |
aux.addComponent(new JBlank(10, 10)); |
157 |
aux.addComponent(getJCheckBoxSpatialIndex()); |
158 |
aux.addComponent("", getPnlScale());
|
159 |
JPanel aux2 = new JPanel(new GridLayout(1,2)); |
160 |
aux2.add(getPnlProperties()); |
161 |
aux2.add(getPnlHyperLink()); |
162 |
aux.addComponent("", aux2);
|
163 |
|
164 |
|
165 |
|
166 |
aux.setPreferredSize(getPreferredSize()); |
167 |
this.add(aux, BorderLayout.CENTER); |
168 |
this.add(new JBlank(5, 10), BorderLayout.WEST); |
169 |
this.add(new JBlank(5, 10), BorderLayout.EAST); |
170 |
|
171 |
} |
172 |
|
173 |
|
174 |
/**
|
175 |
* Sets the necessary properties in the panel. This properties are
|
176 |
* extracted from the layer. With this properties fills the TextFields,
|
177 |
* ComboBoxes and the rest of GUI components.
|
178 |
* @param FLayer layer,
|
179 |
*/
|
180 |
public void setModel(FLayer layer) { |
181 |
this.layer = layer;
|
182 |
|
183 |
if (layer instanceof FLyrVect) { |
184 |
FLyrVect lyrVect = (FLyrVect) layer; |
185 |
|
186 |
|
187 |
if(lyrVect.getISpatialIndex() == null) { |
188 |
getJCheckBoxSpatialIndex().setSelected(false);
|
189 |
} else {
|
190 |
getJCheckBoxSpatialIndex().setSelected(true);
|
191 |
} |
192 |
} |
193 |
if (layer.getMinScale() != -1) |
194 |
getTxtMaxScale().setText(nf.format(layer.getMinScale())); |
195 |
if (layer.getMaxScale() != -1) |
196 |
getTxtMinScale().setText(nf.format(layer.getMaxScale())); |
197 |
if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) { |
198 |
getRdBtnShowAlways().setSelected(true);
|
199 |
txtMaxScale.setEnabled(false);
|
200 |
txtMinScale.setEnabled(false);
|
201 |
|
202 |
} else {
|
203 |
getRdBtnDoNotShowWhen().setSelected(true);
|
204 |
txtMaxScale.setEnabled(true);
|
205 |
txtMinScale.setEnabled(true);
|
206 |
} |
207 |
txtLayerName.setText(layer.getName()); |
208 |
showLayerInfo(); |
209 |
|
210 |
|
211 |
if (PluginServices.getMainFrame() != null) |
212 |
if (PluginServices.getMDIManager().getActiveWindow() instanceof BaseView ){ |
213 |
BaseView theView = (BaseView)PluginServices.getMDIManager().getActiveWindow(); |
214 |
view = theView.getModel(); |
215 |
try {
|
216 |
if (layer instanceof AlphanumericData) { |
217 |
AlphanumericData ad = (AlphanumericData) layer; |
218 |
DataSource ds;
|
219 |
ds = ad.getRecordset(); |
220 |
String[] names = new String[ds.getFieldCount()]; |
221 |
for (int i = 0; i < ds.getFieldCount(); i++) { |
222 |
names[i] = ds.getFieldName(i); |
223 |
} |
224 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names); |
225 |
cmbLinkField.setModel(defaultModel); |
226 |
|
227 |
if (layer.getLinkProperties().getField()!=null) |
228 |
cmbLinkField.setSelectedItem(layer.getLinkProperties().getField()); |
229 |
else
|
230 |
cmbLinkField.setSelectedItem(view.getSelectedField()); |
231 |
} else {
|
232 |
cmbLinkField = new JComboBox(); |
233 |
} |
234 |
} catch (ReadDriverException e) {
|
235 |
NotificationManager.addError("No se pudo obtener la tabla", e);
|
236 |
} |
237 |
|
238 |
|
239 |
if(layer.getLinkProperties().getExt()!=null) |
240 |
getTxtLinkExtension().setText(layer.getLinkProperties().getExt()); |
241 |
|
242 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
243 |
"Enlazar_a_ficheros_de_imagen"));
|
244 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
245 |
"Enlazar_a_fichero_de_texto"));
|
246 |
|
247 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
248 |
"Enlazar_a_documento_PDF"));
|
249 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
250 |
"Enlazar_a_imagen_SVG"));
|
251 |
|
252 |
if (layer.getLinkProperties().getType()!=-1) |
253 |
getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType()); |
254 |
|
255 |
} |
256 |
|
257 |
} |
258 |
|
259 |
/**
|
260 |
* This method initializes jPanel
|
261 |
*
|
262 |
* @return javax.swing.JPanel
|
263 |
*/
|
264 |
private JPanel getPnlLayerName() { |
265 |
if (pnlLayerName == null) { |
266 |
lblLayerName = new JLabel(); |
267 |
pnlLayerName = new JPanel(); |
268 |
lblLayerName.setText(PluginServices.getText(this,"Nombre") + ":"); |
269 |
lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
|
270 |
pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
|
271 |
pnlLayerName.add(lblLayerName, null);
|
272 |
pnlLayerName.add(getTxtLayerName(), null);
|
273 |
} |
274 |
return pnlLayerName;
|
275 |
} |
276 |
/**
|
277 |
* This method initializes jPanel1
|
278 |
*
|
279 |
* @return javax.swing.JPanel
|
280 |
*/
|
281 |
private GridBagLayoutPanel getPnlScale() {
|
282 |
if (pnlScale == null) { |
283 |
pnlScale = new GridBagLayoutPanel();
|
284 |
pnlScale.setBorder(BorderFactory.createTitledBorder(
|
285 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
286 |
PluginServices.getText(this, "rango_de_escalas"), |
287 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
288 |
TitledBorder.DEFAULT_POSITION, null, null) |
289 |
); |
290 |
ButtonGroup buttonGroup = new ButtonGroup(); |
291 |
buttonGroup.add(getRdBtnShowAlways()); |
292 |
buttonGroup.add(getRdBtnDoNotShowWhen()); |
293 |
pnlScale.addComponent(getRdBtnShowAlways()); |
294 |
pnlScale.addComponent(getRdBtnDoNotShowWhen()); |
295 |
JPanel aux;
|
296 |
|
297 |
|
298 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
299 |
aux.add(getTxtMaxScale()); |
300 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")")); |
301 |
|
302 |
GridBagLayoutPanel aux2; |
303 |
aux2 = new GridBagLayoutPanel();
|
304 |
aux2.addComponent(PluginServices.getText( |
305 |
this,"este_por_debajo_de_"), |
306 |
aux); |
307 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
308 |
aux.add(getTxtMinScale()); |
309 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")")); |
310 |
|
311 |
aux2.addComponent(PluginServices.getText( |
312 |
this,"este_por_encima_de"), |
313 |
aux); |
314 |
|
315 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
316 |
|
317 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
318 |
|
319 |
} |
320 |
return pnlScale;
|
321 |
} |
322 |
/**
|
323 |
* This method initializes jPanel2, this contains the ScrollPane with the
|
324 |
* properies.
|
325 |
*
|
326 |
* @return javax.swing.JPanel
|
327 |
*/
|
328 |
private JPanel getPnlProperties() { |
329 |
if (pnlProperties == null) { |
330 |
pnlProperties = new JPanel(); |
331 |
pnlProperties.setBorder(BorderFactory.createTitledBorder(
|
332 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
333 |
PluginServices.getText(this, "propiedades"), |
334 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
335 |
TitledBorder.DEFAULT_POSITION, null, null) |
336 |
); |
337 |
pnlProperties.add(getScrlProperties(), null);
|
338 |
} |
339 |
return pnlProperties;
|
340 |
} |
341 |
|
342 |
/**
|
343 |
* This method initializes jTextField
|
344 |
*
|
345 |
* @return javax.swing.JTextField
|
346 |
*/
|
347 |
private JTextField getTxtLayerName() { |
348 |
if (txtLayerName == null) { |
349 |
txtLayerName = new JTextField(25); |
350 |
txtLayerName.setEditable(true);
|
351 |
} |
352 |
return txtLayerName;
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* This method initializes TxtMaxScale
|
357 |
* @return jTextField1
|
358 |
*/
|
359 |
private JTextField getTxtMaxScale() { |
360 |
if (txtMaxScale == null) { |
361 |
txtMaxScale = new JTextField(15); |
362 |
txtMaxScale.setEnabled(false);
|
363 |
} |
364 |
return txtMaxScale;
|
365 |
} |
366 |
/**
|
367 |
* This method initilizes TxtArea, in this TextArea sets the text with
|
368 |
* the properties of the layer
|
369 |
* @return
|
370 |
*/
|
371 |
private JTextArea getPropertiesTextArea() { |
372 |
if (propertiesTextArea == null) { |
373 |
propertiesTextArea = new JTextArea(); |
374 |
propertiesTextArea.setEditable(false);
|
375 |
propertiesTextArea.setBackground(SystemColor.control);
|
376 |
|
377 |
} |
378 |
return propertiesTextArea;
|
379 |
} |
380 |
|
381 |
/**
|
382 |
* This method initializes jScrollPane
|
383 |
*
|
384 |
* @return javax.swing.JScrollPane
|
385 |
*/
|
386 |
private JScrollPane getScrlProperties() { |
387 |
if (scrlProperties == null) { |
388 |
scrlProperties = new JScrollPane(); |
389 |
scrlProperties.setViewportView(getPropertiesTextArea()); |
390 |
scrlProperties.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
391 |
scrlProperties.setPreferredSize(new Dimension(350, 200)); |
392 |
} |
393 |
return scrlProperties;
|
394 |
} |
395 |
/**
|
396 |
* This method initializes jRadioButton
|
397 |
*
|
398 |
* @return javax.swing.JRadioButton
|
399 |
*/
|
400 |
private JRadioButton getRdBtnShowAlways() { |
401 |
if (rdBtnShowAlways == null) { |
402 |
rdBtnShowAlways = new JRadioButton(); |
403 |
rdBtnShowAlways.setText(PluginServices.getText(this,"Mostrar_siempre")); |
404 |
rdBtnShowAlways.setSelected(true);
|
405 |
rdBtnShowAlways.addActionListener(new ActionListener() { |
406 |
public void actionPerformed(ActionEvent e) { |
407 |
txtMaxScale.setEnabled(false);
|
408 |
txtMinScale.setEnabled(false);
|
409 |
} |
410 |
}); |
411 |
} |
412 |
return rdBtnShowAlways;
|
413 |
} |
414 |
/**
|
415 |
* This method initializes jRadioButton1
|
416 |
*
|
417 |
* @return javax.swing.JRadioButton
|
418 |
*/
|
419 |
private JRadioButton getRdBtnDoNotShowWhen() { |
420 |
if (rdBtnDoNotShow == null) { |
421 |
rdBtnDoNotShow = new JRadioButton(); |
422 |
rdBtnDoNotShow.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala")); |
423 |
rdBtnDoNotShow.addActionListener(new ActionListener() { |
424 |
public void actionPerformed(ActionEvent e) { |
425 |
txtMaxScale.setEnabled(true);
|
426 |
txtMinScale.setEnabled(true);
|
427 |
} |
428 |
}); |
429 |
} |
430 |
return rdBtnDoNotShow;
|
431 |
} |
432 |
/**
|
433 |
* This method initializes jTextField2
|
434 |
*
|
435 |
* @return javax.swing.JTextField
|
436 |
*/
|
437 |
private JTextField getTxtMinScale() { |
438 |
if (txtMinScale == null) { |
439 |
txtMinScale = new JTextField(15); |
440 |
txtMinScale.setEnabled(false);
|
441 |
} |
442 |
return txtMinScale;
|
443 |
} |
444 |
|
445 |
private String getLayerName(){ |
446 |
return txtLayerName.getText().toString();
|
447 |
} |
448 |
/**
|
449 |
* This method initializes jPanel3, this panel contains the components of the
|
450 |
* HyperLink
|
451 |
*
|
452 |
* @return javax.swing.JPanel
|
453 |
*/
|
454 |
private JPanel getPnlHyperLink() { |
455 |
if (pnlHyperLink == null) { |
456 |
pnlHyperLink = new JPanel(); |
457 |
pnlHyperLink.setBorder(BorderFactory.createTitledBorder(
|
458 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
459 |
PluginServices.getText(this, "Hiperenlace"), |
460 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
461 |
TitledBorder.DEFAULT_POSITION, null, null) |
462 |
); |
463 |
JPanel aux = new JPanel(new BorderLayout()); |
464 |
pnlHyperLink.setLayout(new BorderLayout()); |
465 |
aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
466 |
aux.add(getPnlFieldAndExtension(), BorderLayout.NORTH);
|
467 |
aux.add(getPnlHyperLinkAction(), BorderLayout.CENTER);
|
468 |
pnlHyperLink.add(aux); |
469 |
} |
470 |
return pnlHyperLink;
|
471 |
} |
472 |
|
473 |
|
474 |
private JPanel getPnlFieldAndExtension() { |
475 |
if (pnlFieldAndExtension == null) { |
476 |
lblLinkExtension = new JLabel(); |
477 |
lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"extension")); |
478 |
lblLinkField = new JLabel(); |
479 |
lblLinkField.setText(PluginServices.getText(this, "Campo")); |
480 |
pnlFieldAndExtension = new JPanel(); |
481 |
pnlFieldAndExtension.add(lblLinkField, null);
|
482 |
pnlFieldAndExtension.add(getCmbLinkField(), null);
|
483 |
pnlFieldAndExtension.add(lblLinkExtension, null);
|
484 |
pnlFieldAndExtension.add(getTxtLinkExtension(), null);
|
485 |
} |
486 |
return pnlFieldAndExtension;
|
487 |
} |
488 |
/**
|
489 |
* This method initializes jPanel8. This panel contains the ComboBox to select
|
490 |
* the action, (type of HyperLink)
|
491 |
*
|
492 |
* @return javax.swing.JPanel
|
493 |
*/
|
494 |
private JPanel getPnlHyperLinkAction() { |
495 |
if (pnlHyperLinkAction == null) { |
496 |
lblDefaultAction = new JLabel(); |
497 |
lblDefaultAction.setText(PluginServices.getText(this, "Accion_Predefinida") + " "); |
498 |
pnlHyperLinkAction = new JPanel(); |
499 |
pnlHyperLinkAction.add(lblDefaultAction, null);
|
500 |
pnlHyperLinkAction.add(getCmbLinkType(), null);
|
501 |
} |
502 |
return pnlHyperLinkAction;
|
503 |
} |
504 |
/**
|
505 |
* This method initializes jComboBox
|
506 |
*
|
507 |
* @return javax.swing.JComboBox
|
508 |
*/
|
509 |
private JComboBox getCmbLinkField() { |
510 |
if (cmbLinkField == null) { |
511 |
cmbLinkField = new JComboBox(); |
512 |
} |
513 |
return cmbLinkField;
|
514 |
} |
515 |
/**
|
516 |
* This method initializes jTextField
|
517 |
*
|
518 |
* @return javax.swing.JTextField
|
519 |
*/
|
520 |
private JTextField getTxtLinkExtension() { |
521 |
if (txtLinkExtension == null) { |
522 |
txtLinkExtension = new JTextField(); |
523 |
txtLinkExtension.setPreferredSize(new Dimension(40,20)); |
524 |
} |
525 |
return txtLinkExtension;
|
526 |
} |
527 |
/**
|
528 |
* This method initializes jComboBox1
|
529 |
*
|
530 |
* @return javax.swing.JComboBox
|
531 |
*/
|
532 |
private JComboBox getCmbLinkType() { |
533 |
if (cmbLinkType == null) { |
534 |
cmbLinkType = new JComboBox(); |
535 |
} |
536 |
return cmbLinkType;
|
537 |
} |
538 |
/**
|
539 |
* @return Returns the view.
|
540 |
*/
|
541 |
private IProjectView getView() {
|
542 |
return view;
|
543 |
} |
544 |
/**
|
545 |
* This method initializes jCheckBox
|
546 |
*
|
547 |
* @return javax.swing.JCheckBox
|
548 |
*/
|
549 |
private JCheckBox getJCheckBoxSpatialIndex() { |
550 |
if (jCheckBoxSpatialIndex == null) { |
551 |
jCheckBoxSpatialIndex = new JCheckBox(); |
552 |
jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23); |
553 |
jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial")); |
554 |
} |
555 |
return jCheckBoxSpatialIndex;
|
556 |
} |
557 |
|
558 |
/**
|
559 |
* Returns the selected Type in the ComboBox
|
560 |
*/
|
561 |
private int getLinkType() { |
562 |
return getCmbLinkType().getSelectedIndex();
|
563 |
|
564 |
} |
565 |
|
566 |
/**
|
567 |
* Returns the Selected Field in the ComboBox
|
568 |
*/
|
569 |
private String getSelectedLinkField() { |
570 |
return (String) getCmbLinkField().getSelectedItem(); |
571 |
} |
572 |
|
573 |
/**
|
574 |
* Returns the Extension in the TextField
|
575 |
*/
|
576 |
private String getExtensionLink() { |
577 |
return getTxtLinkExtension().getText();
|
578 |
} |
579 |
|
580 |
/**
|
581 |
* Returns true or false if the CheckBox is marked or not
|
582 |
*/
|
583 |
private boolean isSpatialIndexSelected() { |
584 |
return getJCheckBoxSpatialIndex().isSelected();
|
585 |
} |
586 |
|
587 |
/**
|
588 |
* Add the information of the layer to the textArea
|
589 |
*/
|
590 |
private void showLayerInfo() { |
591 |
try {
|
592 |
String info = ((FLyrDefault)layer).getInfoString();
|
593 |
if (info == null) { |
594 |
Rectangle2D fullExtentViewPort = layer.getFullExtent();
|
595 |
IProjection viewPortProj = layer.getMapContext().getProjection(); |
596 |
info = PluginServices.getText(this,"Extent") + " " + |
597 |
viewPortProj.getAbrev() + |
598 |
" (" + PluginServices.getText(this, "view_projection") + "):\n\t" + |
599 |
PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaxY() + "\n\t" + |
600 |
PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinY() + "\n\t" + |
601 |
PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinX() + "\n\t" + |
602 |
PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaxX() + "\n\n"; |
603 |
|
604 |
// show layer native projection
|
605 |
if (!layer.getProjection().getAbrev().equals(viewPortProj.getAbrev())) {
|
606 |
IProjection nativeLayerProj = layer.getProjection(); |
607 |
ICoordTrans ct = viewPortProj.getCT(nativeLayerProj); |
608 |
Rectangle2D nativeLayerExtent = ct.convert(fullExtentViewPort);
|
609 |
info += PluginServices.getText(this,"Extent") + " " + |
610 |
nativeLayerProj.getAbrev() + |
611 |
" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t" + |
612 |
PluginServices.getText(this,"Superior") + ":\t" + nativeLayerExtent.getMaxY() + "\n\t" + |
613 |
PluginServices.getText(this,"Inferior") + ":\t" + nativeLayerExtent.getMinY() + "\n\t" + |
614 |
PluginServices.getText(this,"Izquierda") + ":\t" + nativeLayerExtent.getMinX() + "\n\t" + |
615 |
PluginServices.getText(this,"Derecha") + ":\t" + nativeLayerExtent.getMaxX() + "\n\n"; |
616 |
|
617 |
} |
618 |
if (layer instanceof FLyrVect) { |
619 |
ReadableVectorial rv=((FLyrVect)layer).getSource(); |
620 |
if (rv instanceof VectorialEditableAdapter) { |
621 |
rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter(); |
622 |
} |
623 |
|
624 |
info = info + PluginServices.getText(this,"Origen_de_datos") + ": "; |
625 |
if (rv instanceof VectorialFileAdapter) { |
626 |
info = info + "\n" + rv.getDriver().getName() + "\n" + |
627 |
PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile(); |
628 |
|
629 |
} else if (rv instanceof VectorialDBAdapter) { |
630 |
DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef(); |
631 |
info = info + "\n" + rv.getDriver().getName() + "\n"; |
632 |
|
633 |
try {
|
634 |
info = info + |
635 |
PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n"; |
636 |
} catch (Exception e) { |
637 |
//TODO: Que hacer aqui?
|
638 |
e.printStackTrace(); |
639 |
} |
640 |
|
641 |
info = info + |
642 |
PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n"; |
643 |
} else if (rv instanceof VectorialAdapter){ |
644 |
info = info + "\n" + rv.getDriver().getName() + "\n"; |
645 |
} |
646 |
|
647 |
|
648 |
|
649 |
} else {
|
650 |
info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName(); |
651 |
} |
652 |
|
653 |
} |
654 |
getPropertiesTextArea().setText(info); |
655 |
|
656 |
} catch (ReadDriverException e) {
|
657 |
NotificationManager.addError(e.getMessage(), e); |
658 |
} |
659 |
|
660 |
} |
661 |
|
662 |
/**
|
663 |
* Returns true or false if the scale is activa
|
664 |
*/
|
665 |
private boolean isScaleActive() { |
666 |
return getRdBtnDoNotShowWhen().isSelected();
|
667 |
} |
668 |
|
669 |
/**
|
670 |
* Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
|
671 |
* to create a spatial index for the selected layer in background.
|
672 |
* This task also allow to monitor process evolution, and to cancel
|
673 |
* this process.
|
674 |
* @throws DriverException
|
675 |
* @throws DriverIOException
|
676 |
*/
|
677 |
private IMonitorableTask getCreateSpatialIndexTask() throws ReadDriverException { |
678 |
// FIXME REVISAR ESTO (Quizas lanzar TaskException)
|
679 |
return new CreateSpatialIndexMonitorableTask((FLyrVect)layer); |
680 |
} |
681 |
|
682 |
public void acceptAction() { |
683 |
// Implementaci?n para hacer funcionar el hyperlink ...
|
684 |
//com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
|
685 |
//ProjectView view = theView.getModel();
|
686 |
if (PluginServices.getMainFrame() != null) |
687 |
{ |
688 |
IProjectView view = getView(); |
689 |
view.setTypeLink(getLinkType()); |
690 |
if (getSelectedLinkField()!=null) |
691 |
{ |
692 |
view.setSelectedField(getSelectedLinkField().toString().trim()); |
693 |
view.setExtLink(getExtensionLink()); |
694 |
|
695 |
} |
696 |
} |
697 |
|
698 |
|
699 |
} |
700 |
|
701 |
public void cancelAction() { |
702 |
// does nothing
|
703 |
} |
704 |
|
705 |
/**
|
706 |
* When we press the apply button, sets the new properties of the layer thar the
|
707 |
* user modified using the UI components
|
708 |
*/
|
709 |
public void applyAction() { |
710 |
if (isScaleActive()) {
|
711 |
try {
|
712 |
layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue()); |
713 |
} catch (ParseException ex) { |
714 |
if (getTxtMaxScale().getText().compareTo("") == 0) |
715 |
layer.setMinScale(-1);
|
716 |
else
|
717 |
System.err.print(ex.getLocalizedMessage());
|
718 |
} |
719 |
|
720 |
try {
|
721 |
layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue()); |
722 |
} catch (ParseException ex) { |
723 |
if (getTxtMinScale().getText().compareTo("") == 0) |
724 |
layer.setMaxScale(-1);
|
725 |
else
|
726 |
System.err.print(ex.getLocalizedMessage());
|
727 |
} |
728 |
|
729 |
} else {
|
730 |
layer.setMinScale(-1);
|
731 |
layer.setMaxScale(-1);
|
732 |
} |
733 |
|
734 |
if (!getLayerName().equals(layer.getName())){
|
735 |
layer.setName(getLayerName()); |
736 |
} |
737 |
|
738 |
if (layer instanceof FLyrVect){ |
739 |
FLyrVect lyrVect = (FLyrVect) layer; |
740 |
if (isSpatialIndexSelected()) {
|
741 |
if(lyrVect.getISpatialIndex() == null) { |
742 |
//AZABALA
|
743 |
try {
|
744 |
PluginServices. |
745 |
cancelableBackgroundExecution(getCreateSpatialIndexTask()); |
746 |
} catch (ReadDriverException e) {
|
747 |
// TODO Auto-generated catch block
|
748 |
NotificationManager.addError(e.getMessage(), e); |
749 |
} |
750 |
} |
751 |
} |
752 |
//AZABALA
|
753 |
/*
|
754 |
* If we unselect the spatial index checkbox...Must we delete
|
755 |
* spatial index file, or we only have to put Spatial Index
|
756 |
* reference to null?. I have followed the second choice
|
757 |
*/
|
758 |
else{
|
759 |
lyrVect.deleteSpatialIndex(); |
760 |
} |
761 |
|
762 |
|
763 |
} |
764 |
//Codigo relacionado
|
765 |
if (layer instanceof FLyrVect ){ |
766 |
FLyrVect vectlyr=(FLyrVect) layer; |
767 |
if (getSelectedLinkField()!=null){ |
768 |
vectlyr.getLinkProperties().setExt(getExtensionLink()); |
769 |
vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim()); |
770 |
vectlyr.getLinkProperties().setType(getLinkType()); |
771 |
|
772 |
System.out.println("Link Properties"); |
773 |
System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt()); |
774 |
System.out.println("Campo: " + vectlyr.getLinkProperties().getField()); |
775 |
System.out.println("Tipo: " + vectlyr.getLinkProperties().getType()); |
776 |
} |
777 |
} |
778 |
} |
779 |
|
780 |
/*
|
781 |
* (non-Javadoc)
|
782 |
* @see java.awt.Component#getName()
|
783 |
*/
|
784 |
public String getName() { |
785 |
return PluginServices.getText(this,"General"); |
786 |
} |
787 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
788 |
|