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