root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSSelectFieldsPanel.java @ 27077
History | View | Annotate | Download (12.4 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.beans.PropertyChangeEvent; |
5 |
import java.beans.PropertyChangeListener; |
6 |
import java.util.Vector; |
7 |
|
8 |
import javax.swing.JPanel; |
9 |
import javax.swing.JScrollPane; |
10 |
import javax.swing.JToolTip; |
11 |
|
12 |
import org.gvsig.gui.beans.controls.MultiLineToolTip; |
13 |
import org.gvsig.gui.beans.panelGroup.IPanelGroup; |
14 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
15 |
|
16 |
import com.iver.andami.PluginServices; |
17 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
18 |
import com.iver.cit.gvsig.gui.panels.fieldstree.FieldsTreeTable; |
19 |
import com.iver.cit.gvsig.gui.panels.fieldstree.FieldsTreeTableModel; |
20 |
import com.iver.cit.gvsig.gui.panels.fieldstree.TreeTableModelWithCheckBoxes; |
21 |
|
22 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
23 |
*
|
24 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
25 |
*
|
26 |
* This program is free software; you can redistribute it and/or
|
27 |
* modify it under the terms of the GNU General Public License
|
28 |
* as published by the Free Software Foundation; either version 2
|
29 |
* of the License, or (at your option) any later version.
|
30 |
*
|
31 |
* This program is distributed in the hope that it will be useful,
|
32 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
33 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
34 |
* GNU General Public License for more details.
|
35 |
*
|
36 |
* You should have received a copy of the GNU General Public License
|
37 |
* along with this program; if not, write to the Free Software
|
38 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
39 |
*
|
40 |
* For more information, contact:
|
41 |
*
|
42 |
* Generalitat Valenciana
|
43 |
* Conselleria d'Infraestructures i Transport
|
44 |
* Av. Blasco Ib??ez, 50
|
45 |
* 46010 VALENCIA
|
46 |
* SPAIN
|
47 |
*
|
48 |
* +34 963862235
|
49 |
* gvsig@gva.es
|
50 |
* www.gvsig.gva.es
|
51 |
*
|
52 |
* or
|
53 |
*
|
54 |
* IVER T.I. S.A
|
55 |
* Salamanca 50
|
56 |
* 46005 Valencia
|
57 |
* Spain
|
58 |
*
|
59 |
* +34 963163400
|
60 |
* dac@iver.es
|
61 |
*/
|
62 |
/* CVS MESSAGES:
|
63 |
*
|
64 |
* $Id$
|
65 |
* $Log$
|
66 |
* Revision 1.8 2007-04-11 12:10:08 ppiqueras
|
67 |
* Corregido bug: si la capa no tiene campos, no permitir cargarla.
|
68 |
*
|
69 |
* Revision 1.7 2007/02/22 12:24:51 ppiqueras
|
70 |
* A?adidas tool tip text.
|
71 |
*
|
72 |
* Revision 1.6 2007/02/19 11:44:42 jorpiell
|
73 |
* A?adidos los filtros por ?rea
|
74 |
*
|
75 |
* Revision 1.5 2006/12/26 09:19:52 ppiqueras
|
76 |
* Cambiado "atttibutes" en todas las aparaciones en atributos, m?todos, clases, paquetes o comentarios por "fields". (S?lo a aquellas que afectan a clases dentro del proyecto extWFS2).
|
77 |
*
|
78 |
* Revision 1.17 2006/12/15 13:58:25 ppiqueras
|
79 |
* Eliminado un import que sobraba, y reorganizado c?digo
|
80 |
*
|
81 |
* Revision 1.16 2006/12/04 08:59:47 ppiqueras
|
82 |
* Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todav?a no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
|
83 |
*
|
84 |
* Revision 1.15 2006/11/01 17:29:08 jorpiell
|
85 |
* Se ha elimiado el nodo virtual de la raiz. Adem?s ya se cargan los valores de un campo complejo en la pesta?a del filtro
|
86 |
*
|
87 |
* Revision 1.14 2006/10/31 09:39:18 jorpiell
|
88 |
* Cambiado el tama?o del panel
|
89 |
*
|
90 |
* Revision 1.13 2006/10/27 11:33:19 jorpiell
|
91 |
* A?adida la treetable con los check box para seleccionar los atributos
|
92 |
*
|
93 |
* Revision 1.12 2006/10/24 07:58:14 jorpiell
|
94 |
* Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
|
95 |
*
|
96 |
* Revision 1.11 2006/10/24 07:27:56 jorpiell
|
97 |
* Algunos cambios en el modelo que usa la tabla
|
98 |
*
|
99 |
* Revision 1.10 2006/10/10 12:55:06 jorpiell
|
100 |
* Se ha a?adido el soporte de features complejas
|
101 |
*
|
102 |
* Revision 1.9 2006/10/02 09:09:45 jorpiell
|
103 |
* Cambios del 10 copiados al head
|
104 |
*
|
105 |
* Revision 1.7.2.1 2006/09/19 12:28:11 jorpiell
|
106 |
* Ya no se depende de geotools
|
107 |
*
|
108 |
* Revision 1.8 2006/09/18 12:07:31 jorpiell
|
109 |
* Se ha sustituido geotools por el driver de remoteservices
|
110 |
*
|
111 |
* Revision 1.7 2006/09/05 13:01:31 jorpiell
|
112 |
* Reducido el tama?o de los botones
|
113 |
*
|
114 |
* Revision 1.6 2006/07/24 07:30:33 jorpiell
|
115 |
* Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
|
116 |
*
|
117 |
* Revision 1.5 2006/07/21 11:50:31 jaume
|
118 |
* improved appearance
|
119 |
*
|
120 |
* Revision 1.4 2006/06/21 12:35:45 jorpiell
|
121 |
* 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
|
122 |
*
|
123 |
* Revision 1.3 2006/06/15 07:50:58 jorpiell
|
124 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
|
125 |
*
|
126 |
* Revision 1.2 2006/05/26 06:29:42 jorpiell
|
127 |
* Se ha cambiado el tama?o de los botones. Adem?s, al seleccionar todos los atributos se seleccionan en orden.
|
128 |
*
|
129 |
* Revision 1.1 2006/05/25 10:30:13 jorpiell
|
130 |
* Esta clase se ha renombrado. WFSFields era algo confusa
|
131 |
*
|
132 |
* Revision 1.3 2006/05/23 08:09:39 jorpiell
|
133 |
* 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
|
134 |
*
|
135 |
* Revision 1.2 2006/05/19 12:57:08 jorpiell
|
136 |
* Modificados algunos paneles
|
137 |
*
|
138 |
* Revision 1.1 2006/04/20 16:38:24 jorpiell
|
139 |
* 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().
|
140 |
*
|
141 |
*
|
142 |
*/
|
143 |
|
144 |
/**
|
145 |
* <p>Panel with the fields of the feature selected of the current layer.</p>
|
146 |
*
|
147 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
148 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
149 |
*/
|
150 |
public class WFSSelectFieldsPanel extends AbstractWFSPanel { |
151 |
private static final long serialVersionUID = -1596729857889892588L; |
152 |
|
153 |
private JScrollPaneML fieldsScroll = null; |
154 |
private FieldsTreeTable fieldsTreeTable = null; |
155 |
private FieldsTreeTableModel model = null; |
156 |
private JPanel treeTablePanel = null; |
157 |
private boolean fieldsSelectedOfSameLayerHasChanged; |
158 |
private String namespace = null; |
159 |
|
160 |
/**
|
161 |
* Gets the name space of the layer which contains the fields stored
|
162 |
*
|
163 |
* @return the namespace name space of the layer which contains the fields stored
|
164 |
*/
|
165 |
public String getNamespace() { |
166 |
return namespace;
|
167 |
} |
168 |
|
169 |
/**
|
170 |
* Creates a new WFS select fields panel.
|
171 |
*/
|
172 |
public WFSSelectFieldsPanel(){
|
173 |
super();
|
174 |
initialize(); |
175 |
} |
176 |
|
177 |
/**
|
178 |
* This method initializes jScrollPane
|
179 |
*
|
180 |
* @return javax.swing.JScrollPane
|
181 |
*/
|
182 |
private JScrollPane getFieldsScroll() { |
183 |
if (fieldsScroll == null) { |
184 |
fieldsScroll = new JScrollPaneML();
|
185 |
fieldsScroll.setLocation(new java.awt.Point(6, 20)); |
186 |
fieldsScroll.setSize(new java.awt.Dimension(472, 361)); |
187 |
fieldsScroll.setViewportView(getFieldsTreeTable()); |
188 |
MultiLineToolTip tip = new MultiLineToolTip();
|
189 |
tip.setComponent(fieldsScroll); |
190 |
fieldsScroll.setToolTipText(PluginServices.getText(fieldsScroll, "fields_Selection_Info"));
|
191 |
} |
192 |
return fieldsScroll;
|
193 |
} |
194 |
|
195 |
/**
|
196 |
* This method initializes lstTemps
|
197 |
*
|
198 |
* @return javax.swing.JList
|
199 |
*/
|
200 |
public FieldsTreeTable getFieldsTreeTable() {
|
201 |
if (fieldsTreeTable == null) { |
202 |
model = new TreeTableModelWithCheckBoxes();
|
203 |
fieldsTreeTable = new FieldsTreeTable(model,this); |
204 |
fieldsTreeTable.setLocation(new java.awt.Point(7, 4)); |
205 |
fieldsTreeTable.setSize(new java.awt.Dimension(482, 304)); |
206 |
fieldsTreeTable.setToolTipText(PluginServices.getText(fieldsTreeTable, "fields_Selection_Info"));
|
207 |
|
208 |
// If user has changed the fields selection in the same layer
|
209 |
fieldsTreeTable.addPropertyChangeListener(new PropertyChangeListener() { |
210 |
/*
|
211 |
* (non-Javadoc)
|
212 |
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
|
213 |
*/
|
214 |
public void propertyChange(PropertyChangeEvent evt) { |
215 |
// If the selection of the fields of the layer has changed
|
216 |
if (evt.getPropertyName().compareTo("tableCellEditor") == 0) { |
217 |
fieldsSelectedOfSameLayerHasChanged = true;
|
218 |
} |
219 |
else if (evt.getPropertyName().compareTo("selectionModel") == 0) { // If the layer has changed |
220 |
fieldsSelectedOfSameLayerHasChanged = false;
|
221 |
} |
222 |
} |
223 |
}); |
224 |
} |
225 |
return fieldsTreeTable;
|
226 |
} |
227 |
|
228 |
/*
|
229 |
* (non-Javadoc)
|
230 |
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#refresh(com.iver.cit.gvsig.fmap.layers.WFSLayerNode)
|
231 |
*/
|
232 |
public void refresh(WFSLayerNode feature){ |
233 |
setFields(feature); |
234 |
setSelectedFields(feature); |
235 |
} |
236 |
|
237 |
/**
|
238 |
* <p>Updates the inner tree table with the fields of the layer.</p>
|
239 |
*
|
240 |
* @param feature node with the fields
|
241 |
*/
|
242 |
private void setFields(WFSLayerNode feature){ |
243 |
Vector<Object> fields = feature.getFields(); |
244 |
|
245 |
// If there are no fields
|
246 |
if (fields.size() == 0) { |
247 |
return;
|
248 |
} |
249 |
|
250 |
model = new TreeTableModelWithCheckBoxes(fields.get(0)); |
251 |
getFieldsTreeTable().setModel(model); |
252 |
namespace = feature.getNameSpace(); |
253 |
} |
254 |
|
255 |
/**
|
256 |
* <p>Changes to enabled the selection value of the selected fields.</p>
|
257 |
*
|
258 |
* @param feature node with the fields
|
259 |
*/
|
260 |
public void setSelectedFields(WFSLayerNode feature){ |
261 |
Vector<Object> selectedFields = feature.getSelectedFields(); |
262 |
getFieldsTreeTable().setSelectedFields(selectedFields); |
263 |
} |
264 |
|
265 |
/**
|
266 |
* Gets the name of the field which is a geometry
|
267 |
*
|
268 |
* @return name of the field which is a geometry
|
269 |
*/
|
270 |
public String getGeometryFieldName(){ |
271 |
return getFieldsTreeTable().getGeometryField();
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* Gets only the selected fields.
|
276 |
*
|
277 |
* @return the selected fields
|
278 |
*/
|
279 |
public XMLElement[] getSelectedFields(){ |
280 |
return fieldsTreeTable.getSelectedElements();
|
281 |
} |
282 |
|
283 |
/**
|
284 |
* This method initializes treeTablePanel
|
285 |
*
|
286 |
* @return javax.swing.JPanel
|
287 |
*/
|
288 |
private JPanel getTreeTablePanel() { |
289 |
if (treeTablePanel == null) { |
290 |
treeTablePanel = new JPanel(); |
291 |
treeTablePanel.setLayout(null);
|
292 |
treeTablePanel.setLocation(new java.awt.Point(7, 4)); |
293 |
treeTablePanel.setSize(new java.awt.Dimension(484, 387)); |
294 |
treeTablePanel.add(getFieldsScroll(), null);
|
295 |
treeTablePanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
296 |
null, PluginServices.getText(this, "select_fields"), |
297 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
298 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
299 |
} |
300 |
return treeTablePanel;
|
301 |
} |
302 |
|
303 |
/**
|
304 |
* Returns true if user has changed the selection of some field of the same layer; else returns false
|
305 |
*
|
306 |
* @return A boolean value
|
307 |
*/
|
308 |
public boolean getFieldsSelectedOfSameLayerHasChanged() { |
309 |
return this.fieldsSelectedOfSameLayerHasChanged; |
310 |
} |
311 |
|
312 |
/**
|
313 |
* <p>Changes the status to applied.</p>
|
314 |
*
|
315 |
* @param applicable a boolean value
|
316 |
*/
|
317 |
public void setApplicable(boolean applicable) { |
318 |
IPanelGroup panelGroup = getPanelGroup(); |
319 |
|
320 |
if (panelGroup == null) |
321 |
return;
|
322 |
|
323 |
((WFSParamsPanel)panelGroup).setApplicable(applicable); |
324 |
} |
325 |
|
326 |
/**
|
327 |
* Resets the value of the field 'fieldsSelectedOfSameLayerHasChanged'
|
328 |
*
|
329 |
* @return A boolean value
|
330 |
*/
|
331 |
public void resetFieldsSelectedOfSameLayerHasChanged() { |
332 |
this.fieldsSelectedOfSameLayerHasChanged = false; |
333 |
} |
334 |
|
335 |
/*
|
336 |
* (non-Javadoc)
|
337 |
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#initialize()
|
338 |
*/
|
339 |
protected void initialize(){ |
340 |
setLabel(PluginServices.getText(this, "fields_uppercase_first")); |
341 |
setLabelGroup(PluginServices.getText(this, "wfs")); |
342 |
this.setLayout(null); |
343 |
this.add(getTreeTablePanel(), null); |
344 |
fieldsSelectedOfSameLayerHasChanged = false;
|
345 |
} |
346 |
|
347 |
/**
|
348 |
* JCrollPane with multi line tool tip text.
|
349 |
*
|
350 |
* @see JScrollPane
|
351 |
*
|
352 |
* @author Pablo Piqueras Bartolome (pablo.piqueras@iver.es)
|
353 |
*/
|
354 |
private class JScrollPaneML extends JScrollPane { |
355 |
private static final long serialVersionUID = -5589382813201358787L; |
356 |
|
357 |
/**
|
358 |
* @see JScrollPane#JScrollPane()
|
359 |
*/
|
360 |
public JScrollPaneML() {
|
361 |
super();
|
362 |
} |
363 |
|
364 |
/**
|
365 |
* @see JScrollPane#JScrollPane(Component, int, int)
|
366 |
*/
|
367 |
public JScrollPaneML(Component view, int vsbPolicy, int hsbPolicy) { |
368 |
super(view, vsbPolicy, hsbPolicy);
|
369 |
} |
370 |
|
371 |
/**
|
372 |
* @see JScrollPane#JScrollPane(Component)
|
373 |
*/
|
374 |
public JScrollPaneML(Component view) { |
375 |
super(view);
|
376 |
} |
377 |
|
378 |
/**
|
379 |
* @see JScrollPane#JScrollPane(int, int)
|
380 |
*/
|
381 |
public JScrollPaneML(int vsbPolicy, int hsbPolicy) { |
382 |
super(vsbPolicy, hsbPolicy);
|
383 |
} |
384 |
|
385 |
/*
|
386 |
* (non-Javadoc)
|
387 |
* @see javax.swing.JComponent#createToolTip()
|
388 |
*/
|
389 |
public JToolTip createToolTip() { |
390 |
// Multiline support
|
391 |
MultiLineToolTip tip = new MultiLineToolTip();
|
392 |
tip.setComponent(this);
|
393 |
return tip;
|
394 |
} |
395 |
} |
396 |
} |