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