svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectFeaturePanel.java @ 10608
History | View | Annotate | Download (12.1 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.event.MouseAdapter; |
5 |
import java.awt.event.MouseEvent; |
6 |
|
7 |
import javax.swing.JCheckBox; |
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.JScrollPane; |
10 |
import javax.swing.JTextField; |
11 |
import javax.swing.ListSelectionModel; |
12 |
import javax.swing.event.ListSelectionListener; |
13 |
|
14 |
import com.iver.andami.PluginServices; |
15 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
16 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
17 |
|
18 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
19 |
*
|
20 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
21 |
*
|
22 |
* This program is free software; you can redistribute it and/or
|
23 |
* modify it under the terms of the GNU General Public License
|
24 |
* as published by the Free Software Foundation; either version 2
|
25 |
* of the License, or (at your option) any later version.
|
26 |
*
|
27 |
* This program is distributed in the hope that it will be useful,
|
28 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
29 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
30 |
* GNU General Public License for more details.
|
31 |
*
|
32 |
* You should have received a copy of the GNU General Public License
|
33 |
* along with this program; if not, write to the Free Software
|
34 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
35 |
*
|
36 |
* For more information, contact:
|
37 |
*
|
38 |
* Generalitat Valenciana
|
39 |
* Conselleria d'Infraestructures i Transport
|
40 |
* Av. Blasco Ib??ez, 50
|
41 |
* 46010 VALENCIA
|
42 |
* SPAIN
|
43 |
*
|
44 |
* +34 963862235
|
45 |
* gvsig@gva.es
|
46 |
* www.gvsig.gva.es
|
47 |
*
|
48 |
* or
|
49 |
*
|
50 |
* IVER T.I. S.A
|
51 |
* Salamanca 50
|
52 |
* 46005 Valencia
|
53 |
* Spain
|
54 |
*
|
55 |
* +34 963163400
|
56 |
* dac@iver.es
|
57 |
*/
|
58 |
/* CVS MESSAGES:
|
59 |
*
|
60 |
* $Id: WFSSelectFeaturePanel.java 10608 2007-03-05 13:49:42Z ppiqueras $
|
61 |
* $Log$
|
62 |
* Revision 1.17 2007-03-05 13:49:42 ppiqueras
|
63 |
* Si una capa WFS no tiene campos (y por tanto no tiene un campo obligatorio de tipo geometr?a), que avise al usuario y no permita que se intente cargar dicha capa.
|
64 |
*
|
65 |
* Revision 1.16 2007/02/22 12:25:09 ppiqueras
|
66 |
* A?adidas tool tip text.
|
67 |
*
|
68 |
* Revision 1.15 2007/02/09 14:12:39 jorpiell
|
69 |
* Soporte para WFS 1.1 y WFS-T
|
70 |
*
|
71 |
* Revision 1.14 2007/02/07 13:26:23 ppiqueras
|
72 |
* Corregido bug: al seleccionar una feature, pero sin cerrar el di?logo, se retrocede y se conecta a otro servidor, se manten?a la posici?n seleccionada en la tabla de features. Se ha solucionado haciendo que se quede deseleccionada toda la tabla de features.
|
73 |
*
|
74 |
* Revision 1.13 2007/01/23 13:12:43 ppiqueras
|
75 |
* Corregido un peque?o bug: el ?rea de texto del nombre de la feature no debe ser editable, dado que si se edita no procesa el texto escrito.
|
76 |
*
|
77 |
* Revision 1.12 2007/01/15 14:16:22 ppiqueras
|
78 |
* Corregido bug: no cargaba los campos al principio y adem?s se ejecutaba m?s de una vez.
|
79 |
*
|
80 |
* Revision 1.11 2006/12/15 13:57:34 ppiqueras
|
81 |
* eliminado un import que sobraba
|
82 |
*
|
83 |
* Revision 1.10 2006/12/12 10:24:45 ppiqueras
|
84 |
* Nueva funcionalidad: Pulsando doble 'click' sobre una capa de un servidor, se carga (igual que antes), pero adem?s se avanza a la siguiente pesta?a sin tener que pulsar el bot?n 'Siguiente'.
|
85 |
*
|
86 |
* Revision 1.9 2006/12/04 08:59:47 ppiqueras
|
87 |
* Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
|
88 |
*
|
89 |
* Revision 1.8 2006/10/27 06:44:56 jorpiell
|
90 |
* Se han cambiado algunas etiquetas de texto que sal?an recortadas
|
91 |
*
|
92 |
* Revision 1.7 2006/07/21 11:50:31 jaume
|
93 |
* improved appearance
|
94 |
*
|
95 |
* Revision 1.6 2006/06/21 12:35:45 jorpiell
|
96 |
* Se ha a?adido la ventana de propiedades. Esto implica a?adir listeners por todos los paneles. Adem?s no se muestra la geomatr?a en la lista de atributos y se muestran ?nicamnete los que se van a descargar
|
97 |
*
|
98 |
* Revision 1.5 2006/05/25 10:31:06 jorpiell
|
99 |
* Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
|
100 |
*
|
101 |
* Revision 1.4 2006/05/23 08:09:39 jorpiell
|
102 |
* Se ha cambiado la forma en la que se leian los valores seleccionados en los paneles y se ha cambiado el comportamiento de los botones
|
103 |
*
|
104 |
* Revision 1.3 2006/05/19 12:57:08 jorpiell
|
105 |
* Modificados algunos paneles
|
106 |
*
|
107 |
* Revision 1.2 2006/04/20 16:38:24 jorpiell
|
108 |
* Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature().
|
109 |
*
|
110 |
*
|
111 |
*/
|
112 |
/**
|
113 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
114 |
*/
|
115 |
public class WFSSelectFeaturePanel extends JPanel { |
116 |
private JPanel coveragesListPanel = null; |
117 |
private JScrollPane jScrollPane = null; |
118 |
private LayerTable lstFeatures = null; |
119 |
private JTextField txtName = null; |
120 |
private JCheckBox chkExtendedNames = null; |
121 |
private WFSWizardData data = null; |
122 |
private WFSParamsPanel parent = null; |
123 |
private JPanel layerNamePanel = null; |
124 |
|
125 |
|
126 |
/**
|
127 |
* This method initializes
|
128 |
*
|
129 |
*/
|
130 |
public WFSSelectFeaturePanel(WFSParamsPanel parent) {
|
131 |
super();
|
132 |
this.parent = parent;
|
133 |
initialize(); |
134 |
} |
135 |
|
136 |
/**
|
137 |
* This method initializes this
|
138 |
*
|
139 |
*/
|
140 |
private void initialize() { |
141 |
this.setLayout(null); |
142 |
this.setBounds(10, 5, 481, 427); |
143 |
this.add(getFeaturesListPanel(), null); |
144 |
this.add(getChkExtendedNames(), null); |
145 |
this.add(getLayerNamePanel(), null); |
146 |
} |
147 |
|
148 |
/**
|
149 |
* This method initializes coveragesListPanel
|
150 |
*
|
151 |
* @return javax.swing.JPanel
|
152 |
*/
|
153 |
private JPanel getFeaturesListPanel() { |
154 |
if (coveragesListPanel == null) { |
155 |
coveragesListPanel = new JPanel(); |
156 |
coveragesListPanel.setLayout(null);
|
157 |
coveragesListPanel.setLocation(new java.awt.Point(7,57)); |
158 |
coveragesListPanel.setSize(new java.awt.Dimension(482,302)); |
159 |
coveragesListPanel.add(getJScrollPane(), null);
|
160 |
coveragesListPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
161 |
null, PluginServices.getText(this, "select_features"), |
162 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
163 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
164 |
} |
165 |
return coveragesListPanel;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* This method initializes jScrollPane
|
170 |
*
|
171 |
* @return javax.swing.JScrollPane
|
172 |
*/
|
173 |
private JScrollPane getJScrollPane() { |
174 |
if (jScrollPane == null) { |
175 |
jScrollPane = new JScrollPane(); |
176 |
jScrollPane.setBounds(6, 17, 469, 280); |
177 |
jScrollPane.setViewportView(getLstFeatures()); |
178 |
jScrollPane.setToolTipText(PluginServices.getText(jScrollPane, "feature_Selection_Info"));
|
179 |
} |
180 |
return jScrollPane;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* This method initializes jList1
|
185 |
*
|
186 |
* @return javax.swing.JList
|
187 |
*/
|
188 |
public LayerTable getLstFeatures() {
|
189 |
if (lstFeatures == null) { |
190 |
lstFeatures = new LayerTable();
|
191 |
lstFeatures.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
192 |
lstFeatures.getSelectionModel().addListSelectionListener(new ListSelectionListener() { |
193 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
194 |
// With this condition we force that the two lines only will be execute one time when user presses the JList
|
195 |
if (e.getValueIsAdjusting() == false) { |
196 |
// Indicate that now we are loading a new layer
|
197 |
parent.setWFSFilterPanelIsAsTabForWFSLayersLoad(true);
|
198 |
refreshData(); |
199 |
} |
200 |
} |
201 |
}); |
202 |
|
203 |
// Double-click -> click the 'Next' button
|
204 |
lstFeatures.addMouseListener(new MouseAdapter() { |
205 |
/*
|
206 |
* (non-Javadoc)
|
207 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
|
208 |
*/
|
209 |
public void mouseClicked(MouseEvent e) { |
210 |
if (e.getClickCount() == 2) { |
211 |
parent.doClickOnNextButton(); |
212 |
} |
213 |
} |
214 |
}); |
215 |
|
216 |
|
217 |
lstFeatures.setToolTipText(PluginServices.getText(lstFeatures, "feature_Selection_Info"));
|
218 |
} |
219 |
|
220 |
return lstFeatures;
|
221 |
} |
222 |
|
223 |
/**
|
224 |
* This method initializes jTextField
|
225 |
*
|
226 |
* @return javax.swing.JTextField
|
227 |
*/
|
228 |
public JTextField getTxtName() { |
229 |
if (txtName == null) { |
230 |
txtName = new JTextField(); |
231 |
txtName.setBounds(6, 19, 469, 20); |
232 |
txtName.setText(PluginServices.getText(this, "WFSLayer")); |
233 |
txtName.setEditable(false);
|
234 |
txtName.setBackground(Color.WHITE);
|
235 |
txtName.setToolTipText(PluginServices.getText(txtName, "feature_to_load"));
|
236 |
txtName.addKeyListener(new java.awt.event.KeyAdapter() {
|
237 |
public void keyTyped(java.awt.event.KeyEvent e) { |
238 |
parent.isApplicable(true);
|
239 |
} |
240 |
}); |
241 |
} |
242 |
return txtName;
|
243 |
} |
244 |
/**
|
245 |
* This method initializes chkExtendedNames
|
246 |
*
|
247 |
* @return javax.swing.JCheckBox
|
248 |
*/
|
249 |
private JCheckBox getChkExtendedNames() { |
250 |
if (chkExtendedNames == null) { |
251 |
chkExtendedNames = new JCheckBox(); |
252 |
chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names")); |
253 |
chkExtendedNames.setBounds(10, 368, 380, 20); |
254 |
chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
255 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
256 |
boolean b = chkExtendedNames.isSelected();
|
257 |
getLstFeatures().setShowLayerNames(b); |
258 |
getLstFeatures().repaint(); |
259 |
} |
260 |
}); |
261 |
chkExtendedNames.addActionListener(new java.awt.event.ActionListener() {
|
262 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
263 |
// fPrefs.putBoolean("show_layer_names", chkExtendedNames.isSelected());
|
264 |
} |
265 |
}); |
266 |
// chkExtendedNames.setSelected(fPrefs.getBoolean("show_layer_names", false));
|
267 |
|
268 |
} |
269 |
return chkExtendedNames;
|
270 |
} |
271 |
|
272 |
/**
|
273 |
*
|
274 |
* @return The selected Feature
|
275 |
*/
|
276 |
public WFSLayerNode getSelectedFeature(){
|
277 |
return (WFSLayerNode)getLstFeatures().getSelectedValue();
|
278 |
} |
279 |
|
280 |
public void setSelectedFeature(WFSLayerNode layerNode){ |
281 |
int index = -1; |
282 |
for (int i=0; i<getLstFeatures().getRowCount(); i++){ |
283 |
WFSLayerNode node = (WFSLayerNode)getLstFeatures().getValueAt(i); |
284 |
if (node != null && layerNode.getName().equals(node.getName())){ |
285 |
index = i; |
286 |
} |
287 |
} |
288 |
if (index != -1){ |
289 |
getLstFeatures().changeSelection(index,0,false,false); |
290 |
} |
291 |
} |
292 |
|
293 |
/**
|
294 |
* Sets the object that holds the wizard data.
|
295 |
*
|
296 |
* Establece el objeto que contiene los datos del wizard.
|
297 |
*
|
298 |
* @param data
|
299 |
*/
|
300 |
public void setWizardData(WFSWizardData data) { |
301 |
this.data = data;
|
302 |
refreshInfo(); |
303 |
} |
304 |
|
305 |
/**
|
306 |
* Refresh the features list
|
307 |
*/
|
308 |
public void refreshInfo(){ |
309 |
// Unselects all features
|
310 |
unselectAllFeatures(); |
311 |
|
312 |
// Add the new features
|
313 |
getLstFeatures().addFeatures(data.getFeatures()); |
314 |
} |
315 |
|
316 |
/**
|
317 |
* Updates the list with no feature selected
|
318 |
*/
|
319 |
public void unselectAllFeatures() { |
320 |
// Reset the last row selection of the features table
|
321 |
int numberOfFeatures = getLstFeatures().getRowCount();
|
322 |
|
323 |
if (numberOfFeatures > 0) { |
324 |
ListSelectionModel model = getLstFeatures().getSelectionModel();
|
325 |
model.removeSelectionInterval(0, numberOfFeatures - 1); // whatever row selection |
326 |
} |
327 |
} |
328 |
|
329 |
/**
|
330 |
* Refreshes the wizard components data each time a feature
|
331 |
* is selected. The describeFeatureType operation must be
|
332 |
* sent
|
333 |
*/
|
334 |
public void refreshData(){ |
335 |
WFSLayerNode lyr = (WFSLayerNode)getLstFeatures().getSelectedValue(); |
336 |
try{
|
337 |
getTxtName().setText(lyr.getTitle()); |
338 |
}catch(NullPointerException e){ |
339 |
getTxtName().setText(PluginServices.getText(this,"default_name")); |
340 |
} |
341 |
|
342 |
parent.refreshData(lyr); |
343 |
} |
344 |
|
345 |
/**
|
346 |
* This method initializes layerNamePanel
|
347 |
*
|
348 |
* @return javax.swing.JPanel
|
349 |
*/
|
350 |
private JPanel getLayerNamePanel() { |
351 |
if (layerNamePanel == null) { |
352 |
layerNamePanel = new JPanel(); |
353 |
layerNamePanel.setLayout(null);
|
354 |
layerNamePanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
355 |
null, PluginServices.getText(this, "layer_name"), |
356 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
357 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
358 |
layerNamePanel.setBounds(new java.awt.Rectangle(7, 4, 482, 49)); |
359 |
layerNamePanel.add(getTxtName(), null);
|
360 |
|
361 |
} |
362 |
return layerNamePanel;
|
363 |
} |
364 |
|
365 |
/**
|
366 |
*
|
367 |
* @return the layer name
|
368 |
*/
|
369 |
public String getLayerName(){ |
370 |
return ((WFSLayerNode)getLstFeatures().getSelectedValue()).getName();
|
371 |
} |
372 |
|
373 |
/**
|
374 |
*
|
375 |
* @return the name space
|
376 |
*/
|
377 |
public String getLayerNameSpace(){ |
378 |
return ((WFSLayerNode)getLstFeatures().getSelectedValue()).getNameSpace();
|
379 |
} |
380 |
|
381 |
public WFSLayerNode getWFSLayerNode(){
|
382 |
WFSLayerNode layerNode = (WFSLayerNode)getLstFeatures().getSelectedValue(); |
383 |
return layerNode;
|
384 |
} |
385 |
|
386 |
/**
|
387 |
*
|
388 |
* @return the test that will be showed it the gvSIG
|
389 |
* toc
|
390 |
*/
|
391 |
public String getLayerText(){ |
392 |
return getTxtName().getText();
|
393 |
} |
394 |
|
395 |
public void setLayerName(String name) { |
396 |
getTxtName().setText(name); |
397 |
} |
398 |
|
399 |
|
400 |
|
401 |
|
402 |
} // @jve:decl-index=0:visual-constraint="10,16"
|