root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / legend / gui / General.java @ 31496
History | View | Annotate | Download (27.2 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 org.gvsig.app.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.text.NumberFormat; |
55 |
import java.text.ParseException; |
56 |
import java.util.Iterator; |
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.andami.PluginServices; |
76 |
import org.gvsig.andami.messages.NotificationManager; |
77 |
import org.gvsig.app.project.documents.view.ViewDocument; |
78 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
79 |
import org.gvsig.app.project.documents.view.legend.CreateSpatialIndexMonitorableTask; |
80 |
import org.gvsig.fmap.dal.DataStoreParameters; |
81 |
import org.gvsig.fmap.dal.exception.DataException; |
82 |
import org.gvsig.fmap.dal.exception.ReadException; |
83 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
84 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
85 |
import org.gvsig.fmap.dal.feature.FeatureType; |
86 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
87 |
import org.gvsig.fmap.geom.primitive.Envelope; |
88 |
import org.gvsig.fmap.geom.type.GeometryType; |
89 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
90 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
91 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
92 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
93 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
94 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
95 |
import org.gvsig.gui.beans.swing.JBlank; |
96 |
import org.gvsig.tools.locator.LocatorException; |
97 |
import org.gvsig.utils.swing.threads.IMonitorableTask; |
98 |
|
99 |
|
100 |
|
101 |
|
102 |
/**
|
103 |
* This class implements an useful and intuitive graphic interface to change some
|
104 |
* properties of the layer. This class extends AbstractThemeManager. The properties
|
105 |
* that allow modified are the name of the layer, the scale, if the user want to use
|
106 |
* Spatial index or not and the HyperLink. Also shows a scroll with a little resume
|
107 |
* with the properties of the layer.
|
108 |
* @author jmorell
|
109 |
*
|
110 |
* TODO To change the template for this generated type comment go to
|
111 |
* Window - Preferences - Java - Code Style - Code Templates
|
112 |
*/
|
113 |
public class General extends AbstractThemeManagerPage { |
114 |
|
115 |
private static final long serialVersionUID = 1L; |
116 |
private FLayer layer;
|
117 |
private ViewDocument view;
|
118 |
private NumberFormat nf = NumberFormat.getInstance(); |
119 |
private JPanel pnlLayerName = null; |
120 |
private GridBagLayoutPanel pnlScale = null; |
121 |
private JPanel pnlProperties = null; |
122 |
private JLabel lblLayerName = null; |
123 |
private JTextField txtLayerName = null; |
124 |
private JTextField txtMaxScale = null; |
125 |
private JTextArea propertiesTextArea = null; |
126 |
private JRadioButton rdBtnShowAlways = null; |
127 |
private JRadioButton rdBtnDoNotShow = null; |
128 |
private JTextField txtMinScale = null; |
129 |
private JComboBox cmbLinkField = null; |
130 |
private JTextField txtLinkExtension = null; |
131 |
private JComboBox cmbLinkType = null; |
132 |
private JCheckBox jCheckBoxSpatialIndex = null; |
133 |
private JPanel pnlHyperLink; |
134 |
private JLabel lblLinkExtension; |
135 |
private JLabel lblLinkField; |
136 |
private JLabel lblDefaultAction; |
137 |
private JPanel pnlFieldAndExtension; |
138 |
private JPanel pnlHyperLinkAction; |
139 |
private JScrollPane scrlProperties; |
140 |
|
141 |
/**
|
142 |
* This is the default constructor.
|
143 |
*/
|
144 |
public General() {
|
145 |
super();
|
146 |
initialize(); |
147 |
} |
148 |
/**
|
149 |
* This method initializes this
|
150 |
*
|
151 |
* @return void
|
152 |
*/
|
153 |
private void initialize() { |
154 |
this.setLayout(new BorderLayout()); |
155 |
GridBagLayoutPanel aux = new GridBagLayoutPanel();
|
156 |
aux.addComponent(getPnlLayerName()); |
157 |
aux.addComponent(new JBlank(10, 10)); |
158 |
aux.addComponent(getJCheckBoxSpatialIndex()); |
159 |
aux.addComponent("", getPnlScale());
|
160 |
JPanel aux2 = new JPanel(new GridLayout(1,2)); |
161 |
aux2.add(getPnlProperties()); |
162 |
aux2.add(getPnlHyperLink()); |
163 |
aux.addComponent(aux2); |
164 |
|
165 |
|
166 |
|
167 |
aux.setPreferredSize(getPreferredSize()); |
168 |
this.add(aux, BorderLayout.CENTER); |
169 |
this.add(new JBlank(5, 10), BorderLayout.WEST); |
170 |
this.add(new JBlank(5, 10), BorderLayout.EAST); |
171 |
|
172 |
} |
173 |
|
174 |
|
175 |
/**
|
176 |
* Sets the necessary properties in the panel. This properties are
|
177 |
* extracted from the layer. With this properties fills the TextFields,
|
178 |
* ComboBoxes and the rest of GUI components.
|
179 |
* @param FLayer layer,
|
180 |
*/
|
181 |
public void setModel(FLayer layer) { |
182 |
this.layer = layer;
|
183 |
|
184 |
if (layer instanceof FLyrVect) { |
185 |
FLyrVect lyrVect = (FLyrVect) layer; |
186 |
|
187 |
|
188 |
//TODO
|
189 |
// if(lyrVect.getISpatialIndex() == null) {
|
190 |
// getJCheckBoxSpatialIndex().setSelected(false);
|
191 |
// } else {
|
192 |
// getJCheckBoxSpatialIndex().setSelected(true);
|
193 |
// }
|
194 |
} |
195 |
if (layer.getMinScale() != -1) { |
196 |
getTxtMaxScale().setText(nf.format(layer.getMinScale())); |
197 |
} |
198 |
if (layer.getMaxScale() != -1) { |
199 |
getTxtMinScale().setText(nf.format(layer.getMaxScale())); |
200 |
} |
201 |
if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) { |
202 |
getRdBtnShowAlways().setSelected(true);
|
203 |
txtMaxScale.setEnabled(false);
|
204 |
txtMinScale.setEnabled(false);
|
205 |
|
206 |
} else {
|
207 |
getRdBtnDoNotShowWhen().setSelected(true);
|
208 |
txtMaxScale.setEnabled(true);
|
209 |
txtMinScale.setEnabled(true);
|
210 |
} |
211 |
txtLayerName.setText(layer.getName()); |
212 |
showLayerInfo(); |
213 |
|
214 |
|
215 |
if (PluginServices.getMainFrame() != null) { |
216 |
if (PluginServices.getMDIManager().getActiveWindow() instanceof AbstractViewPanel ){ |
217 |
AbstractViewPanel theView = (AbstractViewPanel)PluginServices.getMDIManager().getActiveWindow(); |
218 |
view = theView.getModel(); |
219 |
try {
|
220 |
if (layer instanceof FLyrVect) { |
221 |
FLyrVect ad = (FLyrVect) layer; |
222 |
FeatureStore fs; |
223 |
fs = ad.getFeatureStore(); |
224 |
FeatureType ftype = fs.getDefaultFeatureType(); |
225 |
String[] names = new String[ftype.size()]; |
226 |
Iterator iter = ftype.iterator();
|
227 |
int i=0; |
228 |
while (iter.hasNext()){
|
229 |
names[i] = ((FeatureAttributeDescriptor)iter.next()).getName(); |
230 |
i++; |
231 |
} |
232 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names); |
233 |
cmbLinkField.setModel(defaultModel); |
234 |
|
235 |
if (layer.getLinkProperties().getField()!=null) { |
236 |
cmbLinkField.setSelectedItem(layer.getLinkProperties().getField()); |
237 |
} else {
|
238 |
cmbLinkField.setSelectedItem(view.getSelectedField()); |
239 |
} |
240 |
} else {
|
241 |
cmbLinkField = new JComboBox(); |
242 |
} |
243 |
} catch (DataException e) {
|
244 |
NotificationManager.addError("No se pudo obtener la tabla", e);
|
245 |
} |
246 |
|
247 |
|
248 |
if(layer.getLinkProperties().getExt()!=null) { |
249 |
getTxtLinkExtension().setText(layer.getLinkProperties().getExt()); |
250 |
} |
251 |
|
252 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
253 |
"Enlazar_a_ficheros_de_imagen"));
|
254 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
255 |
"Enlazar_a_fichero_de_texto"));
|
256 |
|
257 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
258 |
"Enlazar_a_documento_PDF"));
|
259 |
getCmbLinkType().addItem(PluginServices.getText(this,
|
260 |
"Enlazar_a_imagen_SVG"));
|
261 |
|
262 |
if (layer.getLinkProperties().getType()!=-1) { |
263 |
getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType()); |
264 |
} |
265 |
|
266 |
} |
267 |
} |
268 |
|
269 |
} |
270 |
|
271 |
/**
|
272 |
* This method initializes jPanel
|
273 |
*
|
274 |
* @return javax.swing.JPanel
|
275 |
*/
|
276 |
private JPanel getPnlLayerName() { |
277 |
if (pnlLayerName == null) { |
278 |
lblLayerName = new JLabel(); |
279 |
pnlLayerName = new JPanel(); |
280 |
lblLayerName.setText(PluginServices.getText(this,"Nombre") + ":"); |
281 |
lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
|
282 |
pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
|
283 |
pnlLayerName.add(lblLayerName, null);
|
284 |
pnlLayerName.add(getTxtLayerName(), null);
|
285 |
} |
286 |
return pnlLayerName;
|
287 |
} |
288 |
/**
|
289 |
* This method initializes jPanel1
|
290 |
*
|
291 |
* @return javax.swing.JPanel
|
292 |
*/
|
293 |
private GridBagLayoutPanel getPnlScale() {
|
294 |
if (pnlScale == null) { |
295 |
pnlScale = new GridBagLayoutPanel();
|
296 |
pnlScale.setBorder(BorderFactory.createTitledBorder(
|
297 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
298 |
PluginServices.getText(this, "rango_de_escalas"), |
299 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
300 |
TitledBorder.DEFAULT_POSITION, null, null) |
301 |
); |
302 |
ButtonGroup buttonGroup = new ButtonGroup(); |
303 |
buttonGroup.add(getRdBtnShowAlways()); |
304 |
buttonGroup.add(getRdBtnDoNotShowWhen()); |
305 |
pnlScale.addComponent(getRdBtnShowAlways()); |
306 |
pnlScale.addComponent(getRdBtnDoNotShowWhen()); |
307 |
JPanel aux;
|
308 |
|
309 |
|
310 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
311 |
aux.add(getTxtMaxScale()); |
312 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")")); |
313 |
|
314 |
GridBagLayoutPanel aux2; |
315 |
aux2 = new GridBagLayoutPanel();
|
316 |
aux2.addComponent(PluginServices.getText( |
317 |
this,"este_por_encima_de")+" 1:", |
318 |
aux); |
319 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
320 |
aux.add(getTxtMinScale()); |
321 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")")); |
322 |
|
323 |
aux2.addComponent(PluginServices.getText( |
324 |
this,"este_por_debajo_de_")+" 1:", |
325 |
aux); |
326 |
|
327 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
328 |
|
329 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
330 |
|
331 |
} |
332 |
return pnlScale;
|
333 |
} |
334 |
/**
|
335 |
* This method initializes jPanel2, this contains the ScrollPane with the
|
336 |
* properies.
|
337 |
*
|
338 |
* @return javax.swing.JPanel
|
339 |
*/
|
340 |
private JPanel getPnlProperties() { |
341 |
if (pnlProperties == null) { |
342 |
pnlProperties = new JPanel(); |
343 |
pnlProperties.setBorder(BorderFactory.createTitledBorder(
|
344 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
345 |
PluginServices.getText(this, "propiedades"), |
346 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
347 |
TitledBorder.DEFAULT_POSITION, null, null) |
348 |
); |
349 |
pnlProperties.add(getScrlProperties(), null);
|
350 |
} |
351 |
return pnlProperties;
|
352 |
} |
353 |
|
354 |
/**
|
355 |
* This method initializes jTextField
|
356 |
*
|
357 |
* @return javax.swing.JTextField
|
358 |
*/
|
359 |
private JTextField getTxtLayerName() { |
360 |
if (txtLayerName == null) { |
361 |
txtLayerName = new JTextField(25); |
362 |
txtLayerName.setEditable(true);
|
363 |
} |
364 |
return txtLayerName;
|
365 |
} |
366 |
|
367 |
/**
|
368 |
* This method initializes TxtMaxScale
|
369 |
* @return jTextField1
|
370 |
*/
|
371 |
private JTextField getTxtMaxScale() { |
372 |
if (txtMaxScale == null) { |
373 |
txtMaxScale = new JTextField(15); |
374 |
txtMaxScale.setEnabled(false);
|
375 |
} |
376 |
return txtMaxScale;
|
377 |
} |
378 |
/**
|
379 |
* This method initilizes TxtArea, in this TextArea sets the text with
|
380 |
* the properties of the layer
|
381 |
* @return
|
382 |
*/
|
383 |
private JTextArea getPropertiesTextArea() { |
384 |
if (propertiesTextArea == null) { |
385 |
propertiesTextArea = new JTextArea(); |
386 |
propertiesTextArea.setEditable(false);
|
387 |
propertiesTextArea.setBackground(SystemColor.control);
|
388 |
|
389 |
} |
390 |
return propertiesTextArea;
|
391 |
} |
392 |
|
393 |
/**
|
394 |
* This method initializes jScrollPane
|
395 |
*
|
396 |
* @return javax.swing.JScrollPane
|
397 |
*/
|
398 |
private JScrollPane getScrlProperties() { |
399 |
if (scrlProperties == null) { |
400 |
scrlProperties = new JScrollPane(); |
401 |
scrlProperties.setViewportView(getPropertiesTextArea()); |
402 |
scrlProperties.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
403 |
scrlProperties.setPreferredSize(new Dimension(350, 180)); |
404 |
} |
405 |
return scrlProperties;
|
406 |
} |
407 |
/**
|
408 |
* This method initializes jRadioButton
|
409 |
*
|
410 |
* @return javax.swing.JRadioButton
|
411 |
*/
|
412 |
private JRadioButton getRdBtnShowAlways() { |
413 |
if (rdBtnShowAlways == null) { |
414 |
rdBtnShowAlways = new JRadioButton(); |
415 |
rdBtnShowAlways.setText(PluginServices.getText(this,"Mostrar_siempre")); |
416 |
rdBtnShowAlways.setSelected(true);
|
417 |
rdBtnShowAlways.addActionListener(new ActionListener() { |
418 |
public void actionPerformed(ActionEvent e) { |
419 |
txtMaxScale.setEnabled(false);
|
420 |
txtMinScale.setEnabled(false);
|
421 |
} |
422 |
}); |
423 |
} |
424 |
return rdBtnShowAlways;
|
425 |
} |
426 |
/**
|
427 |
* This method initializes jRadioButton1
|
428 |
*
|
429 |
* @return javax.swing.JRadioButton
|
430 |
*/
|
431 |
private JRadioButton getRdBtnDoNotShowWhen() { |
432 |
if (rdBtnDoNotShow == null) { |
433 |
rdBtnDoNotShow = new JRadioButton(); |
434 |
rdBtnDoNotShow.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala")); |
435 |
rdBtnDoNotShow.addActionListener(new ActionListener() { |
436 |
public void actionPerformed(ActionEvent e) { |
437 |
txtMaxScale.setEnabled(true);
|
438 |
txtMinScale.setEnabled(true);
|
439 |
} |
440 |
}); |
441 |
} |
442 |
return rdBtnDoNotShow;
|
443 |
} |
444 |
/**
|
445 |
* This method initializes jTextField2
|
446 |
*
|
447 |
* @return javax.swing.JTextField
|
448 |
*/
|
449 |
private JTextField getTxtMinScale() { |
450 |
if (txtMinScale == null) { |
451 |
txtMinScale = new JTextField(15); |
452 |
txtMinScale.setEnabled(false);
|
453 |
} |
454 |
return txtMinScale;
|
455 |
} |
456 |
|
457 |
private String getLayerName(){ |
458 |
return txtLayerName.getText().toString();
|
459 |
} |
460 |
/**
|
461 |
* This method initializes jPanel3, this panel contains the components of the
|
462 |
* HyperLink
|
463 |
*
|
464 |
* @return javax.swing.JPanel
|
465 |
*/
|
466 |
private JPanel getPnlHyperLink() { |
467 |
if (pnlHyperLink == null) { |
468 |
pnlHyperLink = new JPanel(); |
469 |
pnlHyperLink.setBorder(BorderFactory.createTitledBorder(
|
470 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
471 |
PluginServices.getText(this, "Hiperenlace"), |
472 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
473 |
TitledBorder.DEFAULT_POSITION, null, null) |
474 |
); |
475 |
JPanel aux = new JPanel(new BorderLayout()); |
476 |
pnlHyperLink.setLayout(new BorderLayout()); |
477 |
aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
478 |
aux.add(getPnlFieldAndExtension(), BorderLayout.NORTH);
|
479 |
aux.add(getPnlHyperLinkAction(), BorderLayout.CENTER);
|
480 |
pnlHyperLink.add(aux); |
481 |
} |
482 |
return pnlHyperLink;
|
483 |
} |
484 |
|
485 |
|
486 |
private JPanel getPnlFieldAndExtension() { |
487 |
if (pnlFieldAndExtension == null) { |
488 |
lblLinkExtension = new JLabel(); |
489 |
lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"extension")); |
490 |
lblLinkField = new JLabel(); |
491 |
lblLinkField.setText(PluginServices.getText(this, "Campo")); |
492 |
pnlFieldAndExtension = new JPanel(); |
493 |
pnlFieldAndExtension.add(lblLinkField, null);
|
494 |
pnlFieldAndExtension.add(getCmbLinkField(), null);
|
495 |
pnlFieldAndExtension.add(lblLinkExtension, null);
|
496 |
pnlFieldAndExtension.add(getTxtLinkExtension(), null);
|
497 |
} |
498 |
return pnlFieldAndExtension;
|
499 |
} |
500 |
/**
|
501 |
* This method initializes jPanel8. This panel contains the ComboBox to select
|
502 |
* the action, (type of HyperLink)
|
503 |
*
|
504 |
* @return javax.swing.JPanel
|
505 |
*/
|
506 |
private JPanel getPnlHyperLinkAction() { |
507 |
if (pnlHyperLinkAction == null) { |
508 |
lblDefaultAction = new JLabel(); |
509 |
lblDefaultAction.setText(PluginServices.getText(this, "Accion_Predefinida") + " "); |
510 |
pnlHyperLinkAction = new JPanel(); |
511 |
pnlHyperLinkAction.add(lblDefaultAction, null);
|
512 |
pnlHyperLinkAction.add(getCmbLinkType(), null);
|
513 |
} |
514 |
return pnlHyperLinkAction;
|
515 |
} |
516 |
/**
|
517 |
* This method initializes jComboBox
|
518 |
*
|
519 |
* @return javax.swing.JComboBox
|
520 |
*/
|
521 |
private JComboBox getCmbLinkField() { |
522 |
if (cmbLinkField == null) { |
523 |
cmbLinkField = new JComboBox(); |
524 |
} |
525 |
return cmbLinkField;
|
526 |
} |
527 |
/**
|
528 |
* This method initializes jTextField
|
529 |
*
|
530 |
* @return javax.swing.JTextField
|
531 |
*/
|
532 |
private JTextField getTxtLinkExtension() { |
533 |
if (txtLinkExtension == null) { |
534 |
txtLinkExtension = new JTextField(); |
535 |
txtLinkExtension.setPreferredSize(new Dimension(40,20)); |
536 |
} |
537 |
return txtLinkExtension;
|
538 |
} |
539 |
/**
|
540 |
* This method initializes jComboBox1
|
541 |
*
|
542 |
* @return javax.swing.JComboBox
|
543 |
*/
|
544 |
private JComboBox getCmbLinkType() { |
545 |
if (cmbLinkType == null) { |
546 |
cmbLinkType = new JComboBox(); |
547 |
} |
548 |
return cmbLinkType;
|
549 |
} |
550 |
/**
|
551 |
* @return Returns the view.
|
552 |
*/
|
553 |
private ViewDocument getView() {
|
554 |
return view;
|
555 |
} |
556 |
/**
|
557 |
* This method initializes jCheckBox
|
558 |
*
|
559 |
* @return javax.swing.JCheckBox
|
560 |
*/
|
561 |
private JCheckBox getJCheckBoxSpatialIndex() { |
562 |
if (jCheckBoxSpatialIndex == null) { |
563 |
jCheckBoxSpatialIndex = new JCheckBox(); |
564 |
jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23); |
565 |
jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial")); |
566 |
} |
567 |
return jCheckBoxSpatialIndex;
|
568 |
} |
569 |
|
570 |
/**
|
571 |
* Returns the selected Type in the ComboBox
|
572 |
*/
|
573 |
private int getLinkType() { |
574 |
return getCmbLinkType().getSelectedIndex();
|
575 |
|
576 |
} |
577 |
|
578 |
/**
|
579 |
* Returns the Selected Field in the ComboBox
|
580 |
*/
|
581 |
private String getSelectedLinkField() { |
582 |
return (String) getCmbLinkField().getSelectedItem(); |
583 |
} |
584 |
|
585 |
/**
|
586 |
* Returns the Extension in the TextField
|
587 |
*/
|
588 |
private String getExtensionLink() { |
589 |
return getTxtLinkExtension().getText();
|
590 |
} |
591 |
|
592 |
/**
|
593 |
* Returns true or false if the CheckBox is marked or not
|
594 |
*/
|
595 |
private boolean isSpatialIndexSelected() { |
596 |
return getJCheckBoxSpatialIndex().isSelected();
|
597 |
} |
598 |
|
599 |
/**
|
600 |
* Add the information of the layer to the textArea
|
601 |
*/
|
602 |
private void showLayerInfo() { |
603 |
try {
|
604 |
String info = ((FLyrDefault)layer).getInfoString();
|
605 |
if (info == null) { |
606 |
StringBuffer buff= new StringBuffer(); |
607 |
Envelope fullExtentViewPort = layer.getFullEnvelope(); |
608 |
IProjection viewPortProj = layer.getMapContext().getProjection(); |
609 |
buff.append(PluginServices.getText(this,"Extent")); |
610 |
buff.append(" ");
|
611 |
buff.append(viewPortProj.getAbrev()); |
612 |
buff.append(" (" + PluginServices.getText(this, "view_projection") + "):\n\t"); |
613 |
buff.append(PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaximum(1) + "\n\t"); |
614 |
buff.append(PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinimum(1) + "\n\t"); |
615 |
buff.append(PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinimum(0) + "\n\t"); |
616 |
buff.append(PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaximum(0) + "\n"); |
617 |
// show layer native projection
|
618 |
if (layer.getProjection() != null |
619 |
&& !layer.getProjection().getAbrev().equals( |
620 |
viewPortProj.getAbrev())) { |
621 |
IProjection nativeLayerProj = layer.getProjection(); |
622 |
ICoordTrans ct = viewPortProj.getCT(nativeLayerProj); |
623 |
// Rectangle2D r=new Rectangle2D.Double(fullExtentViewPort.getMinimum(0),fullExtentViewPort.getMinimum(1),fullExtentViewPort.getLength(0),fullExtentViewPort.getLength(1));
|
624 |
// Rectangle2D nativeLayerExtent = ct.convert(r);
|
625 |
Envelope nativeLayerExtent = fullExtentViewPort.convert(ct); |
626 |
buff.append(PluginServices.getText(this,"Extent") + " "); |
627 |
buff.append(nativeLayerProj.getAbrev()); |
628 |
buff.append(" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t"); |
629 |
buff.append(PluginServices.getText(this, "Superior") |
630 |
+ ":\t" + nativeLayerExtent.getMaximum(1) + "\n\t"); |
631 |
buff.append(PluginServices.getText(this, "Inferior") |
632 |
+ ":\t" + nativeLayerExtent.getMinimum(1) + "\n\t"); |
633 |
buff.append(PluginServices.getText(this, "Izquierda") |
634 |
+ ":\t" + nativeLayerExtent.getMinimum(0) + "\n\t"); |
635 |
buff.append(PluginServices.getText(this, "Derecha") + ":\t" |
636 |
+ nativeLayerExtent.getMaximum(0) + "\n"); |
637 |
|
638 |
} |
639 |
if (layer instanceof FLyrVect) { |
640 |
FeatureStore fStore=((FLyrVect)layer).getFeatureStore(); |
641 |
// if (rv instanceof VectorialEditableAdapter) {
|
642 |
// rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
|
643 |
// }
|
644 |
|
645 |
buff.append(PluginServices.getText(this,"Origen_de_datos") + ": "); |
646 |
buff.append(fStore.getName()); |
647 |
info=buff.toString(); |
648 |
|
649 |
DataStoreParameters parameters=fStore.getParameters(); |
650 |
if (parameters instanceof FilesystemStoreParameters) { |
651 |
info = info + "\n" +
|
652 |
PluginServices.getText(this, "fichero") |
653 |
+ ": "
|
654 |
+ ((FilesystemStoreParameters) parameters) |
655 |
.getFile(); |
656 |
// FIXME
|
657 |
// }else if (parameters instanceof DBParameters){
|
658 |
// info = info + "\n" + fStore.getName() + "\n";
|
659 |
//
|
660 |
// try {
|
661 |
// info = info +
|
662 |
// PluginServices.getText(this,"url") +": " + ((DBParameters)parameters).getHost() + "\n";
|
663 |
// } catch (Exception e) {
|
664 |
// //TODO: Que hacer aqui?
|
665 |
// e.printStackTrace();
|
666 |
// }
|
667 |
//
|
668 |
// info = info +
|
669 |
// PluginServices.getText(this, "Tabla")
|
670 |
// + ": "
|
671 |
// + ((DBStoreParameters) parameters)
|
672 |
// .getTableName() + "\n";
|
673 |
}else{
|
674 |
info = info + "\n" + fStore.getName() + "\n"; |
675 |
} |
676 |
// if (rv instanceof VectorialFileAdapter) {
|
677 |
// info = info + "\n" + rv.getDriver().getName() + "\n" +
|
678 |
// PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
|
679 |
//
|
680 |
// } else if (rv instanceof VectorialDBAdapter) {
|
681 |
// DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
|
682 |
// info = info + "\n" + rv.getDriver().getName() + "\n";
|
683 |
//
|
684 |
// try {
|
685 |
// info = info +
|
686 |
// PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
|
687 |
// } catch (Exception e) {
|
688 |
// //TODO: Que hacer aqui?
|
689 |
// e.printStackTrace();
|
690 |
// }
|
691 |
//
|
692 |
// info = info +
|
693 |
// PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
|
694 |
// } else if (rv instanceof VectorialAdapter){
|
695 |
// info = info + "\n" + rv.getDriver().getName() + "\n";
|
696 |
// }
|
697 |
String sGeomType= "Unknow"; |
698 |
|
699 |
try {
|
700 |
GeometryType geomType = ((FLyrVect)layer).getTypeVectorLayer(); |
701 |
sGeomType = geomType.getName(); |
702 |
} catch (LocatorException e) {
|
703 |
NotificationManager.addError(e); |
704 |
} catch (GeometryTypeNotSupportedException e) {
|
705 |
NotificationManager.showMessageWarning("Not supported GeometryType", e);
|
706 |
} catch (GeometryTypeNotValidException e) {
|
707 |
NotificationManager.showMessageWarning("Not valid GeometryType", e);
|
708 |
} |
709 |
|
710 |
info += "\n" + PluginServices.getText(this,"type")+ ": "+sGeomType + "\n"; |
711 |
|
712 |
} else {
|
713 |
info=buff.toString(); |
714 |
info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName(); |
715 |
} |
716 |
|
717 |
} |
718 |
getPropertiesTextArea().setText(info); |
719 |
|
720 |
} catch (ReadException e) {
|
721 |
NotificationManager.addError(e.getMessage(), e); |
722 |
} catch (DataException e) {
|
723 |
NotificationManager.addError(e.getMessage(), e); |
724 |
} |
725 |
|
726 |
} |
727 |
|
728 |
/**
|
729 |
* Returns true or false if the scale is activa
|
730 |
*/
|
731 |
private boolean isScaleActive() { |
732 |
return getRdBtnDoNotShowWhen().isSelected();
|
733 |
} |
734 |
|
735 |
/**
|
736 |
* Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
|
737 |
* to create a spatial index for the selected layer in background.
|
738 |
* This task also allow to monitor process evolution, and to cancel
|
739 |
* this process.
|
740 |
*/
|
741 |
private IMonitorableTask getCreateSpatialIndexTask() throws DataException { |
742 |
// FIXME REVISAR ESTO (Quizas lanzar TaskException)
|
743 |
return new CreateSpatialIndexMonitorableTask((FLyrVect)layer); |
744 |
} |
745 |
|
746 |
public void acceptAction() { |
747 |
// Implementaci?n para hacer funcionar el hyperlink ...
|
748 |
//com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
|
749 |
//ProjectView view = theView.getModel();
|
750 |
if (PluginServices.getMainFrame() != null) |
751 |
{ |
752 |
ViewDocument view = getView(); |
753 |
view.setTypeLink(getLinkType()); |
754 |
if (getSelectedLinkField()!=null) |
755 |
{ |
756 |
view.setSelectedField(getSelectedLinkField().toString().trim()); |
757 |
view.setExtLink(getExtensionLink()); |
758 |
|
759 |
} |
760 |
} |
761 |
|
762 |
|
763 |
} |
764 |
|
765 |
public void cancelAction() { |
766 |
// does nothing
|
767 |
} |
768 |
|
769 |
/**
|
770 |
* When we press the apply button, sets the new properties of the layer thar the
|
771 |
* user modified using the UI components
|
772 |
*/
|
773 |
public void applyAction() { |
774 |
if (isScaleActive()) {
|
775 |
try {
|
776 |
layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue()); |
777 |
} catch (ParseException ex) { |
778 |
if (getTxtMaxScale().getText().compareTo("") == 0) { |
779 |
layer.setMinScale(-1);
|
780 |
} else {
|
781 |
System.err.print(ex.getLocalizedMessage());
|
782 |
} |
783 |
} |
784 |
|
785 |
try {
|
786 |
layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue()); |
787 |
} catch (ParseException ex) { |
788 |
if (getTxtMinScale().getText().compareTo("") == 0) { |
789 |
layer.setMaxScale(-1);
|
790 |
} else {
|
791 |
System.err.print(ex.getLocalizedMessage());
|
792 |
} |
793 |
} |
794 |
|
795 |
} else {
|
796 |
layer.setMinScale(-1);
|
797 |
layer.setMaxScale(-1);
|
798 |
} |
799 |
|
800 |
if (!getLayerName().equals(layer.getName())){
|
801 |
layer.setName(getLayerName()); |
802 |
} |
803 |
|
804 |
if (layer instanceof FLyrVect){ |
805 |
FLyrVect lyrVect = (FLyrVect) layer; |
806 |
if (isSpatialIndexSelected()) {
|
807 |
// TODO
|
808 |
|
809 |
// if(lyrVect.getISpatialIndex() == null) {
|
810 |
// //AZABALA
|
811 |
// try {
|
812 |
// PluginServices.
|
813 |
// cancelableBackgroundExecution(getCreateSpatialIndexTask());
|
814 |
// } catch (ReadDriverException e) {
|
815 |
// // TODO Auto-generated catch block
|
816 |
// NotificationManager.addError(e.getMessage(), e);
|
817 |
// }
|
818 |
// }
|
819 |
} |
820 |
//AZABALA
|
821 |
/*
|
822 |
* If we unselect the spatial index checkbox...Must we delete
|
823 |
* spatial index file, or we only have to put Spatial Index
|
824 |
* reference to null?. I have followed the second choice
|
825 |
*/
|
826 |
else{
|
827 |
// lyrVect.deleteSpatialIndex();
|
828 |
} |
829 |
|
830 |
|
831 |
} |
832 |
//Codigo relacionado
|
833 |
if (layer instanceof FLyrVect ){ |
834 |
FLyrVect vectlyr=(FLyrVect) layer; |
835 |
if (getSelectedLinkField()!=null){ |
836 |
vectlyr.getLinkProperties().setExt(getExtensionLink()); |
837 |
vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim()); |
838 |
vectlyr.getLinkProperties().setType(getLinkType()); |
839 |
|
840 |
System.out.println("Link Properties"); |
841 |
System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt()); |
842 |
System.out.println("Campo: " + vectlyr.getLinkProperties().getField()); |
843 |
System.out.println("Tipo: " + vectlyr.getLinkProperties().getType()); |
844 |
} |
845 |
} |
846 |
} |
847 |
|
848 |
/*
|
849 |
* (non-Javadoc)
|
850 |
* @see java.awt.Component#getName()
|
851 |
*/
|
852 |
public String getName() { |
853 |
return PluginServices.getText(this,"General"); |
854 |
} |
855 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
856 |
|