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