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