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