Revision 38666
tags/v2_0_0_Build_2050/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/AbstractWFSPanel.java | ||
---|---|---|
1 |
package org.gvsig.wfs.gui.panels; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
|
|
5 |
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer; |
|
6 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
7 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature; |
|
8 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeatureManager; |
|
9 |
import org.slf4j.Logger; |
|
10 |
import org.slf4j.LoggerFactory; |
|
11 |
|
|
12 |
|
|
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 |
|
|
55 |
/* CVS MESSAGES: |
|
56 |
* |
|
57 |
* $Id$ |
|
58 |
* $Log$ |
|
59 |
* |
|
60 |
*/ |
|
61 |
|
|
62 |
/** |
|
63 |
* <p>Default panel used to create a WFS group's panel.</p> |
|
64 |
* |
|
65 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
66 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
67 |
*/ |
|
68 |
public abstract class AbstractWFSPanel extends AbstractPanel implements IWFSPanel { |
|
69 |
// Default dimensions of all WFS panels |
|
70 |
static final int PANEL_WIDTH = 475; |
|
71 |
static final int PANEL_HEIGHT = 365; |
|
72 |
protected static final Logger logger = LoggerFactory.getLogger(AbstractWFSPanel.class); |
|
73 |
|
|
74 |
/** |
|
75 |
* Initializes an WFS panel. |
|
76 |
*/ |
|
77 |
public AbstractWFSPanel() { |
|
78 |
super(); |
|
79 |
setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT)); |
|
80 |
} |
|
81 |
|
|
82 |
/* |
|
83 |
* (non-Javadoc) |
|
84 |
* @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#initialize() |
|
85 |
*/ |
|
86 |
protected void initialize() { |
|
87 |
// By default all panels will be at the GUI |
|
88 |
setVisible(true); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* <p>Gets the information of the wizard used to add or load panels.</p> |
|
93 |
* |
|
94 |
* @return the wizard data |
|
95 |
*/ |
|
96 |
public WFSServerExplorer getServerExplorer(){ |
|
97 |
return (getPanelGroup() == null)? null: ((WFSParamsPanel)getPanelGroup()).getServerExplorer(); |
|
98 |
} |
|
99 |
|
|
100 |
public WFSSelectedFeatureManager getSelectedFeatureManager(){ |
|
101 |
return (getPanelGroup() == null)? null: ((WFSParamsPanel)getPanelGroup()).getSelectedFeatureManager(); |
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object) |
|
107 |
*/ |
|
108 |
public void setReference(Object ref) { |
|
109 |
super.setReference(ref); |
|
110 |
} |
|
111 |
|
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* @see com.iver.cit.gvsig.gui.panels.IWFSPanel#refresh(com.iver.cit.gvsig.fmap.layers.WFSLayerNode) |
|
115 |
*/ |
|
116 |
public void refresh(WFSSelectedFeature layer) { |
|
117 |
} |
|
118 |
|
|
119 |
/* |
|
120 |
* (non-Javadoc) |
|
121 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept() |
|
122 |
*/ |
|
123 |
public void accept() { |
|
124 |
} |
|
125 |
|
|
126 |
/* |
|
127 |
* (non-Javadoc) |
|
128 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply() |
|
129 |
*/ |
|
130 |
public void apply() { |
|
131 |
} |
|
132 |
|
|
133 |
/* |
|
134 |
* (non-Javadoc) |
|
135 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel() |
|
136 |
*/ |
|
137 |
public void cancel() { |
|
138 |
} |
|
139 |
|
|
140 |
/* |
|
141 |
* (non-Javadoc) |
|
142 |
* @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected() |
|
143 |
*/ |
|
144 |
public void selected() { |
|
145 |
} |
|
146 |
} |
|
0 | 147 |
tags/v2_0_0_Build_2050/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSParamsPanel.java | ||
---|---|---|
1 |
package org.gvsig.wfs.gui.panels; |
|
2 |
|
|
3 |
import java.awt.Container; |
|
4 |
|
|
5 |
import javax.swing.JTabbedPane; |
|
6 |
|
|
7 |
import org.cresques.cts.IProjection; |
|
8 |
import org.geotools.filter.AbstractFilter; |
|
9 |
import org.gvsig.andami.PluginServices; |
|
10 |
import org.gvsig.app.gui.ILayerPanel; |
|
11 |
import org.gvsig.app.gui.WizardPanel; |
|
12 |
import org.gvsig.fmap.crs.CRSFactory; |
|
13 |
import org.gvsig.fmap.dal.DALLocator; |
|
14 |
import org.gvsig.fmap.dal.DataManager; |
|
15 |
import org.gvsig.fmap.dal.DataStore; |
|
16 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
17 |
import org.gvsig.fmap.dal.exception.DataException; |
|
18 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
19 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
20 |
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer; |
|
21 |
import org.gvsig.fmap.dal.store.wfs.WFSStoreParameters; |
|
22 |
import org.gvsig.fmap.dal.store.wfs.WFSStoreProvider; |
|
23 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
24 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
25 |
import org.gvsig.fmap.mapcontext.exceptions.CreateLayerException; |
|
26 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
27 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
28 |
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupException; |
|
29 |
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupGUIException; |
|
30 |
import org.gvsig.gui.beans.panelGroup.exceptions.ListCouldntAddPanelException; |
|
31 |
import org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader; |
|
32 |
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel; |
|
33 |
import org.gvsig.gui.beans.panelGroup.panels.IPanel; |
|
34 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
|
35 |
import org.gvsig.tools.dynobject.DynObject; |
|
36 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature; |
|
37 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeatureManager; |
|
38 |
import org.gvsig.wfs.gui.wizards.WFSWizard; |
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
|
|
43 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
44 |
* |
|
45 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
46 |
* |
|
47 |
* This program is free software; you can redistribute it and/or |
|
48 |
* modify it under the terms of the GNU General Public License |
|
49 |
* as published by the Free Software Foundation; either version 2 |
|
50 |
* of the License, or (at your option) any later version. |
|
51 |
* |
|
52 |
* This program is distributed in the hope that it will be useful, |
|
53 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
54 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
55 |
* GNU General Public License for more details. |
|
56 |
* |
|
57 |
* You should have received a copy of the GNU General Public License |
|
58 |
* along with this program; if not, write to the Free Software |
|
59 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
60 |
* |
|
61 |
* For more information, contact: |
|
62 |
* |
|
63 |
* Generalitat Valenciana |
|
64 |
* Conselleria d'Infraestructures i Transport |
|
65 |
* Av. Blasco Ib??ez, 50 |
|
66 |
* 46010 VALENCIA |
|
67 |
* SPAIN |
|
68 |
* |
|
69 |
* +34 963862235 |
|
70 |
* gvsig@gva.es |
|
71 |
* www.gvsig.gva.es |
|
72 |
* |
|
73 |
* or |
|
74 |
* |
|
75 |
* IVER T.I. S.A |
|
76 |
* Salamanca 50 |
|
77 |
* 46005 Valencia |
|
78 |
* Spain |
|
79 |
* |
|
80 |
* +34 963163400 |
|
81 |
* dac@iver.es |
|
82 |
*/ |
|
83 |
/* CVS MESSAGES: |
|
84 |
* |
|
85 |
* $Id: WFSParamsPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $ |
|
86 |
* $Log$ |
|
87 |
* Revision 1.42 2007-09-19 16:14:50 jaume |
|
88 |
* removed unnecessary imports |
|
89 |
* |
|
90 |
* Revision 1.41 2007/06/26 09:33:54 jorpiell |
|
91 |
* Information tab refreshed |
|
92 |
* |
|
93 |
* Revision 1.40 2007/04/11 12:08:55 ppiqueras |
|
94 |
* Varios cambios: |
|
95 |
* - Corregida etiqueta "Campo" |
|
96 |
* - Cambiada actualizaci?n |
|
97 |
* - Corregido bug: actualizar ?rea visible despu?s de pulsar "Aplicar" en la interfaz gr?fica. |
|
98 |
* |
|
99 |
* Revision 1.39 2007/03/15 13:33:44 ppiqueras |
|
100 |
* Corregido bug de excepci?n que se lanzaba cuando se filtraba y no se pod?a cargar la capa. |
|
101 |
* |
|
102 |
* Revision 1.38 2007/03/05 13:49:42 ppiqueras |
|
103 |
* 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. |
|
104 |
* |
|
105 |
* Revision 1.37 2007/03/01 13:12:09 ppiqueras |
|
106 |
* Mejorado el filtrado por ?rea. |
|
107 |
* |
|
108 |
* Revision 1.36 2007/02/22 12:30:59 ppiqueras |
|
109 |
* - Eliminado m?todo que sobraba. |
|
110 |
* - Mejorada la relaci?n con el panel del ?rea. |
|
111 |
* - A?adido JOptionPanel de aviso que no se aplicar? ?rea porque es incorrecta. |
|
112 |
* |
|
113 |
* Revision 1.35 2007/02/20 11:31:11 ppiqueras |
|
114 |
* Eliminados comentarios que sobraban. |
|
115 |
* |
|
116 |
* Revision 1.34 2007/02/19 11:44:42 jorpiell |
|
117 |
* Añadidos los filtros por área |
|
118 |
* |
|
119 |
* Revision 1.33 2007/02/16 13:36:53 ppiqueras |
|
120 |
* Que el ?rea seleccionada en el panel WFSArea sea accesible una vez se va a aplicar. |
|
121 |
* |
|
122 |
* Revision 1.32 2007/02/12 11:37:00 ppiqueras |
|
123 |
* A?adidos comentarios y m?todo para refrescar el MapControl de la pesta?a del ?rea. |
|
124 |
* |
|
125 |
* Revision 1.31 2007/02/09 14:12:39 jorpiell |
|
126 |
* Soporte para WFS 1.1 y WFS-T |
|
127 |
* |
|
128 |
* Revision 1.30 2007/02/02 12:22:22 ppiqueras |
|
129 |
* Corregido alg?n bug. |
|
130 |
* |
|
131 |
* Revision 1.29 2007/01/08 09:37:39 ppiqueras |
|
132 |
* Eliminado comentario que sobraba |
|
133 |
* |
|
134 |
* Revision 1.28 2006/12/29 09:27:02 ppiqueras |
|
135 |
* Corregidos varios bugs: |
|
136 |
* |
|
137 |
* - Se ejecuta 2 veces "Aplicar" o "Aceptar" en los filtros WFS. |
|
138 |
* - Cuando se carga por primera vez una capa WFS, si se pone un |
|
139 |
* filtro incorrecto, se ignora el filtro (cargando toda la información posible de la capa, y borrando el texto de filtrado). |
|
140 |
* |
|
141 |
* Revision 1.27 2006/12/26 09:19:40 ppiqueras |
|
142 |
* 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). |
|
143 |
* |
|
144 |
* Revision 1.26 2006/12/20 14:22:06 ppiqueras |
|
145 |
* Añadido comentario |
|
146 |
* |
|
147 |
* Revision 1.25 2006/12/15 13:59:36 ppiqueras |
|
148 |
* -Permite que se almacenen y/o recojan todos los campos y valores conocidos de la capa actual. |
|
149 |
* |
|
150 |
* -Además, control frentre a consultas de filtro erróneas, (esto a medias aún). |
|
151 |
* |
|
152 |
* - Algún comentario más. |
|
153 |
* |
|
154 |
* Revision 1.24 2006/12/12 10:24:45 ppiqueras |
|
155 |
* 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'. |
|
156 |
* |
|
157 |
* Revision 1.23 2006/12/11 11:02:24 ppiqueras |
|
158 |
* Corregido bug -> que se mantenga la frase de filtrado |
|
159 |
* |
|
160 |
* Revision 1.22 2006/12/04 08:59:47 ppiqueras |
|
161 |
* Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todavía no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge). |
|
162 |
* |
|
163 |
* Revision 1.21 2006/11/28 08:05:13 jorpiell |
|
164 |
* Se escribe la query en la pesta?a del filtro |
|
165 |
* |
|
166 |
* Revision 1.20 2006/11/14 13:45:49 ppiqueras |
|
167 |
* Añadida pequeña funcionalidad: |
|
168 |
* Cuando se pulsa el botón "Aplicar", (al seleccionar un nuevo filtro), si el árbol de campos posee alguno seleccionado, actualiza los valores (con los nuevos), asociados a éste campo seleccionado. |
|
169 |
* |
|
170 |
* Revision 1.19 2006/10/27 12:10:02 ppiqueras |
|
171 |
* Nueva funcionalidad |
|
172 |
* |
|
173 |
* Revision 1.16 2006/10/23 07:37:04 jorpiell |
|
174 |
* Ya funciona el filterEncoding |
|
175 |
* |
|
176 |
* Revision 1.14 2006/10/13 13:05:32 ppiqueras |
|
177 |
* Permite el refrescado de datos del panel de filtrado sobre capa WFS. |
|
178 |
* |
|
179 |
* Revision 1.13 2006/10/10 12:55:06 jorpiell |
|
180 |
* Se ha a?adido el soporte de features complejas |
|
181 |
* |
|
182 |
* Revision 1.12 2006/10/02 09:17:48 jorpiell |
|
183 |
* A?adido el setCRS a la capa |
|
184 |
* |
|
185 |
* Revision 1.11 2006/09/29 13:02:38 ppiqueras |
|
186 |
* Filtro para WFS. De momento sólo interfaz gráfica. |
|
187 |
* |
|
188 |
* Revision 1.10 2006/07/21 11:50:31 jaume |
|
189 |
* improved appearance |
|
190 |
* |
|
191 |
* Revision 1.9 2006/06/21 12:35:45 jorpiell |
|
192 |
* 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 |
|
193 |
* |
|
194 |
* Revision 1.8 2006/06/15 07:50:58 jorpiell |
|
195 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz |
|
196 |
* |
|
197 |
* Revision 1.7 2006/05/25 16:22:47 jorpiell |
|
198 |
* Se limpia el panel cada vez que se conecta con un servidor distinto |
|
199 |
* |
|
200 |
* Revision 1.6 2006/05/25 16:01:43 jorpiell |
|
201 |
* Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos |
|
202 |
* |
|
203 |
* Revision 1.5 2006/05/25 10:31:06 jorpiell |
|
204 |
* Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados |
|
205 |
* |
|
206 |
* Revision 1.4 2006/05/23 08:09:39 jorpiell |
|
207 |
* 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 |
|
208 |
* |
|
209 |
* Revision 1.3 2006/05/19 12:57:08 jorpiell |
|
210 |
* Modificados algunos paneles |
|
211 |
* |
|
212 |
* Revision 1.2 2006/04/20 16:38:24 jorpiell |
|
213 |
* 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(). |
|
214 |
* |
|
215 |
* Revision 1.1 2006/04/19 12:50:16 jorpiell |
|
216 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor |
|
217 |
* |
|
218 |
*/ |
|
219 |
|
|
220 |
/** |
|
221 |
* <p>Container of the WFS panels, that works as a {@linkplain TabbedPanel TabbedPanel}.</p> |
|
222 |
* |
|
223 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es) |
|
224 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
225 |
*/ |
|
226 |
public class WFSParamsPanel extends TabbedPanel implements ILayerPanel { |
|
227 |
private static final long serialVersionUID = 150328995058481516L; |
|
228 |
|
|
229 |
private static Logger logger = LoggerFactory.getLogger(WFSParamsPanel.class); |
|
230 |
|
|
231 |
private WFSServerExplorer serverExplorer = null; |
|
232 |
private WFSSelectedFeatureManager selectedFeatureManager = null; |
|
233 |
|
|
234 |
private static final MapContextManager MAP_CONTEXT_MANAGER = MapContextLocator.getMapContextManager(); |
|
235 |
|
|
236 |
// Tab positions |
|
237 |
private int infoTabPosition = -1; |
|
238 |
private int featureTabPosition = -1; |
|
239 |
private int fieldsTabPosition = -1; |
|
240 |
private int optionsTabPosition = -1; |
|
241 |
private int filterTabPosition = -1; |
|
242 |
private int areaTabPosition = -1; |
|
243 |
|
|
244 |
// Tabs |
|
245 |
private WFSInfoPanel infoPanel = null; |
|
246 |
private WFSSelectFeaturePanel featurePanel = null; |
|
247 |
private WFSSelectFieldsPanel fieldsPanel = null; |
|
248 |
private WFSOptionsPanel optionsPanel = null; |
|
249 |
private WFSFilterPanel filterPanel = null; |
|
250 |
private WFSAreaPanel areaPanel = null; |
|
251 |
|
|
252 |
private String cacheSelected = null; |
|
253 |
|
|
254 |
/** |
|
255 |
* This method initializes jTabbedPane |
|
256 |
* |
|
257 |
* @return javax.swing.JTabbedPane |
|
258 |
*/ |
|
259 |
public WFSParamsPanel(Object reference) { |
|
260 |
super(reference); |
|
261 |
initialize(); |
|
262 |
} |
|
263 |
|
|
264 |
/* |
|
265 |
* (non-Javadoc) |
|
266 |
* @see org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel#initialize() |
|
267 |
*/ |
|
268 |
protected void initialize() { |
|
269 |
super.initialize(); |
|
270 |
|
|
271 |
this.setVisible(false); |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* Sets the focus to the next tab of the current one. |
|
276 |
*/ |
|
277 |
public void goToNextTab() { |
|
278 |
int tabIndex = getSelectedIndex(); |
|
279 |
|
|
280 |
if ((tabIndex - 1) < getPanelInGUICount()) { |
|
281 |
int nextIndex = nextPageEnabled(); |
|
282 |
|
|
283 |
if (nextIndex > -1) |
|
284 |
setSelectedIndex(nextIndex); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* Sets the focus to the tab previous to the current one. |
|
290 |
*/ |
|
291 |
public void goToPreviousTab(){ |
|
292 |
setSelectedIndex(previousEnabledPage()); |
|
293 |
} |
|
294 |
|
|
295 |
/** |
|
296 |
* @see JTabbedPane#getSelectedIndex() |
|
297 |
*/ |
|
298 |
public int getSelectedIndex(){ |
|
299 |
return this.getJTabbedPane().getSelectedIndex(); |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* @see JTabbedPane#setSelectedIndex(int) |
|
304 |
*/ |
|
305 |
public void setSelectedIndex(int index) { |
|
306 |
this.getJTabbedPane().setSelectedIndex(index); |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* This method initializes infoPanel |
|
311 |
* |
|
312 |
* @return the information panel |
|
313 |
*/ |
|
314 |
public WFSInfoPanel getInfoPanel() { |
|
315 |
if (infoPanel != null) |
|
316 |
return infoPanel; |
|
317 |
|
|
318 |
if (infoTabPosition == -1) |
|
319 |
return null; |
|
320 |
|
|
321 |
return (infoPanel = (WFSInfoPanel) values().toArray()[infoTabPosition]); |
|
322 |
} |
|
323 |
|
|
324 |
/** |
|
325 |
* This method initializes featurePanel |
|
326 |
* |
|
327 |
* @return javax.swing.JPanel |
|
328 |
*/ |
|
329 |
public WFSSelectFeaturePanel getFeaturesPanel() { |
|
330 |
if (featurePanel != null) |
|
331 |
return featurePanel; |
|
332 |
|
|
333 |
if (featureTabPosition == -1) |
|
334 |
return null; |
|
335 |
|
|
336 |
return (featurePanel = (WFSSelectFeaturePanel) values().toArray()[featureTabPosition]); |
|
337 |
} |
|
338 |
|
|
339 |
/** |
|
340 |
* This method initializes fieldsPanel |
|
341 |
* |
|
342 |
* @return javax.swing.JPanel |
|
343 |
*/ |
|
344 |
public WFSSelectFieldsPanel getFieldsPanel() { |
|
345 |
if (fieldsPanel != null) |
|
346 |
return fieldsPanel; |
|
347 |
|
|
348 |
if (fieldsTabPosition == -1) |
|
349 |
return null; |
|
350 |
|
|
351 |
return (fieldsPanel = (WFSSelectFieldsPanel) values().toArray()[fieldsTabPosition]); |
|
352 |
} |
|
353 |
|
|
354 |
/** |
|
355 |
* This method initializes optionsPanel |
|
356 |
* |
|
357 |
* @return javax.swing.JPanel |
|
358 |
*/ |
|
359 |
public WFSOptionsPanel getOptionsPanel() { |
|
360 |
if (optionsPanel != null) |
|
361 |
return optionsPanel; |
|
362 |
|
|
363 |
if (optionsTabPosition == -1) |
|
364 |
return null; |
|
365 |
|
|
366 |
return (optionsPanel = (WFSOptionsPanel) values().toArray()[optionsTabPosition]); |
|
367 |
} |
|
368 |
|
|
369 |
/** |
|
370 |
* This method initializes filterPanel |
|
371 |
* |
|
372 |
* @return javax.swing.JPanel |
|
373 |
*/ |
|
374 |
public WFSFilterPanel getFilterPanel(){ |
|
375 |
if (filterPanel != null) |
|
376 |
return filterPanel; |
|
377 |
|
|
378 |
if (filterTabPosition == -1) |
|
379 |
return null; |
|
380 |
|
|
381 |
return (filterPanel = (WFSFilterPanel) values().toArray()[filterTabPosition]); |
|
382 |
} |
|
383 |
|
|
384 |
/** |
|
385 |
* This method initializes areaPanel |
|
386 |
* |
|
387 |
* @return javax.swing.JPanel |
|
388 |
*/ |
|
389 |
public WFSAreaPanel getAreaPanel() { |
|
390 |
if (areaPanel != null) |
|
391 |
return areaPanel; |
|
392 |
|
|
393 |
if (areaTabPosition == -1) |
|
394 |
return null; |
|
395 |
|
|
396 |
return (areaPanel = (WFSAreaPanel) values().toArray()[areaTabPosition]); |
|
397 |
} |
|
398 |
|
|
399 |
/** |
|
400 |
* Verifies that the selected parameters are enough to request |
|
401 |
* the coverage to the server. |
|
402 |
* |
|
403 |
* @return boolean <code>true</code> if its correctly configured; |
|
404 |
* otherwise returns <code>false</code> |
|
405 |
*/ |
|
406 |
public boolean isCorretlyConfigured() { |
|
407 |
|
|
408 |
if (featurePanel == null) { |
|
409 |
return false; |
|
410 |
} |
|
411 |
|
|
412 |
int n_sel = featurePanel.getSelectedFeaturesCount(); |
|
413 |
return (n_sel > 0); |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* Enable or disable the default tabs |
|
418 |
*/ |
|
419 |
public void enableDefaultTabs(boolean isEnabled) { |
|
420 |
if (fieldsTabPosition != -1) |
|
421 |
setEnabledAt(fieldsTabPosition, isEnabled); |
|
422 |
|
|
423 |
if (filterTabPosition != -1) |
|
424 |
setEnabledAt(filterTabPosition, isEnabled); |
|
425 |
|
|
426 |
if (areaTabPosition != -1) |
|
427 |
setEnabledAt(areaTabPosition, isEnabled); |
|
428 |
} |
|
429 |
|
|
430 |
/* |
|
431 |
* (non-Javadoc) |
|
432 |
* @see org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel#loadPanel(org.gvsig.gui.beans.panelGroup.panels.IPanel) |
|
433 |
*/ |
|
434 |
protected void loadPanel(IPanel panel) { |
|
435 |
super.loadPanel(panel); |
|
436 |
|
|
437 |
if (((AbstractPanel)panel).getClass() == WFSInfoPanel.class) { |
|
438 |
infoTabPosition = getPanelInGUICount() - 1; |
|
439 |
return; |
|
440 |
} |
|
441 |
|
|
442 |
if (((AbstractPanel)panel).getClass() == WFSSelectFeaturePanel.class) { |
|
443 |
featureTabPosition = getPanelInGUICount() - 1; |
|
444 |
return; |
|
445 |
} |
|
446 |
|
|
447 |
if (((AbstractPanel)panel).getClass() == WFSSelectFieldsPanel.class) { |
|
448 |
fieldsTabPosition = getPanelInGUICount() - 1; |
|
449 |
return; |
|
450 |
} |
|
451 |
|
|
452 |
if (((AbstractPanel)panel).getClass() == WFSOptionsPanel.class) { |
|
453 |
optionsTabPosition = getPanelInGUICount() - 1; |
|
454 |
return; |
|
455 |
} |
|
456 |
|
|
457 |
if (((AbstractPanel)panel).getClass() == WFSFilterPanel.class) { |
|
458 |
filterTabPosition = getPanelInGUICount() - 1; |
|
459 |
return; |
|
460 |
} |
|
461 |
|
|
462 |
if (((AbstractPanel)panel).getClass() == WFSAreaPanel.class) { |
|
463 |
areaTabPosition = getPanelInGUICount() - 1; |
|
464 |
return; |
|
465 |
} |
|
466 |
} |
|
467 |
|
|
468 |
/** |
|
469 |
* Refresh all the panels with the WFS capabilities information. |
|
470 |
*/ |
|
471 |
public void refreshCapabilitiesInfo(){ |
|
472 |
WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature(); |
|
473 |
if (selectedFeature != null) { |
|
474 |
selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields()); |
|
475 |
} else { |
|
476 |
getFeaturesPanel().refresh(null); |
|
477 |
} |
|
478 |
serverExplorer.setUserName(getOptionsPanel().getUserName()); |
|
479 |
serverExplorer.setMaxFeatures(getOptionsPanel().getBuffer()); |
|
480 |
serverExplorer.setTimeOut(getOptionsPanel().getTimeout()); |
|
481 |
|
|
482 |
getInfoPanel().refresh(selectedFeature); |
|
483 |
} |
|
484 |
|
|
485 |
/** |
|
486 |
* Gets the information used to add or load a WFS layer. |
|
487 |
* |
|
488 |
* @return information used to add or load a WFS layer |
|
489 |
*/ |
|
490 |
public WFSServerExplorer getServerExplorer() { |
|
491 |
return serverExplorer; |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* Sets the information used to add or load a WFS layer. |
|
496 |
* |
|
497 |
* @param wizardData information used to add or load a WFS layer |
|
498 |
*/ |
|
499 |
public void setServerExplorer(WFSServerExplorer serverExplorer) { |
|
500 |
this.serverExplorer = serverExplorer; |
|
501 |
this.selectedFeatureManager = |
|
502 |
WFSSelectedFeatureManager.getInstance(serverExplorer); |
|
503 |
} |
|
504 |
|
|
505 |
/** |
|
506 |
* Returns the next enabled tab's index, or -1 if there isn't any. |
|
507 |
* |
|
508 |
* @return The index or -1 if there is no one. |
|
509 |
*/ |
|
510 |
public int nextPageEnabled() { |
|
511 |
int currentPage = getSelectedIndex(); |
|
512 |
int nPages = getPanelInGUICount(); |
|
513 |
|
|
514 |
if (currentPage == nPages) |
|
515 |
return -1; |
|
516 |
|
|
517 |
for (int i = currentPage + 1; i < nPages; i++){ |
|
518 |
if (getJTabbedPane().isEnabledAt(i)){ |
|
519 |
return i; |
|
520 |
} |
|
521 |
} |
|
522 |
|
|
523 |
return -1; |
|
524 |
} |
|
525 |
|
|
526 |
/** |
|
527 |
* Returns the index of the current tab. |
|
528 |
* |
|
529 |
* @return index of the current tab |
|
530 |
*/ |
|
531 |
public int currentPage() { |
|
532 |
return getSelectedIndex(); |
|
533 |
} |
|
534 |
|
|
535 |
/** |
|
536 |
* Returns the index of the previous enabled tab. |
|
537 |
* |
|
538 |
* @return The index, or -1 if there is no one. |
|
539 |
*/ |
|
540 |
public int previousEnabledPage() { |
|
541 |
int currentPage = getSelectedIndex(); |
|
542 |
|
|
543 |
if (currentPage == 0) |
|
544 |
return -1; |
|
545 |
|
|
546 |
for (int i = currentPage - 1; i > -1; i--) { |
|
547 |
if (isEnabledAt(i)) { |
|
548 |
return i; |
|
549 |
} |
|
550 |
} |
|
551 |
|
|
552 |
return -1; |
|
553 |
} |
|
554 |
|
|
555 |
/* |
|
556 |
* (non-Javadoc) |
|
557 |
* @see com.iver.cit.gvsig.gui.WizardPanel#initWizard() |
|
558 |
*/ |
|
559 |
public void initWizard() { |
|
560 |
|
|
561 |
} |
|
562 |
|
|
563 |
/* |
|
564 |
* (non-Javadoc) |
|
565 |
* @see com.iver.cit.gvsig.gui.WizardPanel#execute() |
|
566 |
*/ |
|
567 |
public void execute() { |
|
568 |
|
|
569 |
} |
|
570 |
|
|
571 |
/* |
|
572 |
* (non-Javadoc) |
|
573 |
* @see com.iver.cit.gvsig.gui.ILayerPanel#getLayer() |
|
574 |
*/ |
|
575 |
public FLayer getLayer() { |
|
576 |
try { |
|
577 |
FLayer layer = (FLyrVect) createLayer(); |
|
578 |
logger.warn("El flujo de la apliaci?n tal vez no deber?a haber pasado por aqu?."); |
|
579 |
return layer; |
|
580 |
} catch (CreateLayerException e) { |
|
581 |
// do nothing |
|
582 |
} |
|
583 |
return null; |
|
584 |
} |
|
585 |
|
|
586 |
public FLayer createLayer() throws CreateLayerException { |
|
587 |
try { |
|
588 |
FLyrVect layerAux = |
|
589 |
(FLyrVect)MAP_CONTEXT_MANAGER.createLayer(getFeaturesPanel().getLayerName(), getDataStoreParameters()); |
|
590 |
|
|
591 |
if((cacheSelected != null) && (!this.cacheSelected.equals(PluginServices.getText(this, "none")))){ |
|
592 |
layerAux.getFeatureStore().createCache(cacheSelected, getParameters(cacheSelected)); |
|
593 |
} |
|
594 |
return layerAux; |
|
595 |
} catch (Exception e) { |
|
596 |
logger.warn("Can't create layer.",e); |
|
597 |
throw new CreateLayerException(getFeaturesPanel().getLayerName(), e); |
|
598 |
} |
|
599 |
|
|
600 |
} |
|
601 |
|
|
602 |
|
|
603 |
protected DynObject getParameters(String nameCacheProvider) throws DataException { |
|
604 |
DataManager dataManager = DALLocator.getDataManager(); |
|
605 |
return dataManager.createCacheParameters(nameCacheProvider); |
|
606 |
} |
|
607 |
|
|
608 |
public DataStoreParameters getDataStoreParameters() throws InitializeException, ProviderNotRegisteredException{ |
|
609 |
DataManager dataManager = DALLocator.getDataManager(); |
|
610 |
WFSStoreParameters parameters = (WFSStoreParameters) dataManager |
|
611 |
.createStoreParameters(WFSStoreProvider.NAME); |
|
612 |
refreshDataStoreParameters(parameters); |
|
613 |
return parameters; |
|
614 |
} |
|
615 |
|
|
616 |
private void refreshDataStoreParameters(WFSStoreParameters parameters){ |
|
617 |
WFSSelectedFeature selectedFeature = getSelectedFeature(); |
|
618 |
parameters.setUrl(serverExplorer.getUrl()); |
|
619 |
parameters.setVersion(serverExplorer.getVersion()); |
|
620 |
parameters.setFeatureType(selectedFeature.getNameSpace(), |
|
621 |
selectedFeature.getName()); |
|
622 |
parameters.setFields(getFieldsPanel().getSelectedFieldsAsString()); |
|
623 |
parameters.setUser(getOptionsPanel().getUserName()); |
|
624 |
parameters.setPassword(getOptionsPanel().getPassword()); |
|
625 |
parameters.setMaxFeatures(getOptionsPanel().getBuffer()); |
|
626 |
parameters.setTimeOut(getOptionsPanel().getTimeout()); |
|
627 |
parameters.setFilterByAreaGeometry(getAreaPanel().getArea()); |
|
628 |
parameters.setFilterByAreaCrs(getOptionsPanel().getSRS()); |
|
629 |
parameters.setFilterByAreaOperation((int)AbstractFilter.GEOMETRY_INTERSECTS); |
|
630 |
parameters.setFilterByAreaAttribute(selectedFeature.getGeometryField().getName()); |
|
631 |
parameters.setFilterEncodingByAttribute(getFilterPanel().getQuery()); |
|
632 |
} |
|
633 |
|
|
634 |
/** |
|
635 |
* Sets the forms from a |
|
636 |
*/ |
|
637 |
public void setDataStore(DataStore dataStore){ |
|
638 |
WFSStoreParameters storeParameters = |
|
639 |
(WFSStoreParameters)dataStore.getParameters(); |
|
640 |
WFSSelectedFeature selectedFeature = |
|
641 |
selectedFeatureManager.getFeatureInfo(storeParameters.getFeatureNamespace(), |
|
642 |
storeParameters.getFeatureType()); |
|
643 |
getFeaturesPanel().setSelectedFeature(selectedFeature); |
|
644 |
getFieldsPanel().setSelectedFields(storeParameters.getFields()); |
|
645 |
getOptionsPanel().setUserName(storeParameters.getUser()); |
|
646 |
getOptionsPanel().setPassword(storeParameters.getPassword()); |
|
647 |
getOptionsPanel().setBuffer(storeParameters.getMaxFeatures()); |
|
648 |
getOptionsPanel().setTimeOut(storeParameters.getTimeOut()); |
|
649 |
getAreaPanel().setArea(storeParameters.getFilterByAreaGeometry()); |
|
650 |
getOptionsPanel().setSRS(storeParameters.getFilterByAreaCrs()); |
|
651 |
getFilterPanel().setFilterExpressionIntoInterface(storeParameters.getFilterEncodingByAttribute()); |
|
652 |
|
|
653 |
//The filter panel needs to store to update the attributes list |
|
654 |
getFilterPanel().setDataStore(dataStore); |
|
655 |
} |
|
656 |
|
|
657 |
/** |
|
658 |
* Gets the node of the layer selected as a feature, with the selected fields and the filter defined. |
|
659 |
* |
|
660 |
* @return gets the node of the layer selected as a feature, with the selected fields and the filter defined |
|
661 |
*/ |
|
662 |
private WFSSelectedFeature getSelectedFeature(){ |
|
663 |
WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature(); |
|
664 |
selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields()); |
|
665 |
selectedFeature.setFilter(getFilterPanel().getQuery()); |
|
666 |
return selectedFeature; |
|
667 |
} |
|
668 |
|
|
669 |
/** |
|
670 |
* @see WFSWizard#doClickOnNextButton() |
|
671 |
*/ |
|
672 |
public void doClickOnNextButton() { |
|
673 |
Object obj = this.getParent(); |
|
674 |
|
|
675 |
if (obj == null) |
|
676 |
return; |
|
677 |
|
|
678 |
// When we start to connect to a server -> the interface is the dialog WFSWizard |
|
679 |
if (obj instanceof WFSWizard) |
|
680 |
((WFSWizard)this.getParent()).doClickOnNextButton(); |
|
681 |
else { |
|
682 |
// When we are modifying a loaded layer -> the interface is the dialog WFSPropsDialog |
|
683 |
this.advanceCurrentTab(); |
|
684 |
} |
|
685 |
} |
|
686 |
|
|
687 |
/** |
|
688 |
* Selects the next tab |
|
689 |
*/ |
|
690 |
public void advanceCurrentTab() { |
|
691 |
int currentTabIndex = this.getJTabbedPane().getSelectedIndex(); |
|
692 |
|
|
693 |
// Ensure we can select next tab |
|
694 |
if ((currentTabIndex != -1) && (currentTabIndex < (values().size() -1))) |
|
695 |
setSelectedIndex(currentTabIndex + 1); |
|
696 |
} |
|
697 |
|
|
698 |
/** |
|
699 |
* Refreshes the data of the inner <code>WFSSelectFeaturePanel</code>. |
|
700 |
*/ |
|
701 |
public void refreshWFSSelectFeaturePanel() { |
|
702 |
WFSSelectFeaturePanel panel = getFeaturesPanel(); |
|
703 |
|
|
704 |
if (panel != null) { |
|
705 |
panel.refresh(null); |
|
706 |
} |
|
707 |
} |
|
708 |
|
|
709 |
/** |
|
710 |
* @return the selected projection |
|
711 |
*/ |
|
712 |
public IProjection getSelectedFeatureProjection(){ |
|
713 |
WFSSelectedFeature selectedFeature = getSelectedFeature(); |
|
714 |
if (selectedFeature.getSrs().size() > 0){ |
|
715 |
String crs = (String)selectedFeature.getSrs().get(0); |
|
716 |
crs = getSRS(crs); |
|
717 |
IProjection projection = CRSFactory.getCRS(crs); |
|
718 |
if (projection != null){ |
|
719 |
return projection; |
|
720 |
} |
|
721 |
} |
|
722 |
return null; |
|
723 |
} |
|
724 |
|
|
725 |
/** |
|
726 |
* Removing the URN prefix |
|
727 |
* @param srs |
|
728 |
* @return |
|
729 |
*/ |
|
730 |
private String getSRS(String srs){ |
|
731 |
if (srs == null){ |
|
732 |
return null; |
|
733 |
} |
|
734 |
if (srs.startsWith("urn:x-ogc:def:crs:")){ |
|
735 |
String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length()); |
|
736 |
if (srs.indexOf("EPSG") > 0){ |
|
737 |
if (newString.indexOf("EPSG") < 0){ |
|
738 |
newString = "EPSG:" + newString; |
|
739 |
} |
|
740 |
} |
|
741 |
return newString; |
|
742 |
} |
|
743 |
if (srs.toLowerCase().startsWith("crs:")){ |
|
744 |
return srs.substring(4, srs.length()); |
|
745 |
} |
|
746 |
return srs; |
|
747 |
} |
|
748 |
|
|
749 |
/** |
|
750 |
* Refresh all the panels every time that a different layer is selected. The info panel is refreshed every time the user |
|
751 |
* makes a click on it. |
|
752 |
* |
|
753 |
* @param selectedFeature the selected layer |
|
754 |
*/ |
|
755 |
public void refresh(WFSSelectedFeature selectedFeature){ |
|
756 |
boolean hasFields = false; |
|
757 |
|
|
758 |
if (selectedFeature!=null){ |
|
759 |
//Update the layer information |
|
760 |
selectedFeature = selectedFeatureManager.getFeatureInfo(selectedFeature.getNameSpace(), |
|
761 |
selectedFeature.getName()); |
|
762 |
|
|
763 |
// If there is no fields -> disable not necessary tabs |
|
764 |
if (selectedFeature.getWFSFeature().getFieldSize() == 0) { |
|
765 |
setApplicable(false); |
|
766 |
hasFields = false; |
|
767 |
}else{ |
|
768 |
getFieldsPanel().refresh(selectedFeature); |
|
769 |
getOptionsPanel().refresh(selectedFeature); |
|
770 |
getFilterPanel().refresh(selectedFeature); |
|
771 |
getAreaPanel().refresh(selectedFeature); |
|
772 |
hasFields = true; |
|
773 |
} |
|
774 |
} |
|
775 |
|
|
776 |
enableDefaultTabs(hasFields); |
|
777 |
} |
|
778 |
|
|
779 |
/** |
|
780 |
* Changes the <i>enable</i> status of the "<i>apply</i>" button |
|
781 |
* |
|
782 |
* @param isApplicable the <i>enable</i> status of the "<i>apply</i>" button |
|
783 |
*/ |
|
784 |
public void setApplicable(boolean isApplicable){ |
|
785 |
setEnabledApplyButton(isApplicable); |
|
786 |
} |
|
787 |
|
|
788 |
/* |
|
789 |
* (non-Javadoc) |
|
790 |
* @see org.gvsig.gui.beans.buttonspanel.IButtonsPanel#setEnabledApplyButton(boolean) |
|
791 |
*/ |
|
792 |
public void setEnabledApplyButton(boolean b) { |
|
793 |
super.setEnabledApplyButton(b); |
|
794 |
|
|
795 |
Container parent = getParent(); |
|
796 |
|
|
797 |
if ((parent != null) && (parent instanceof WizardPanel)) |
|
798 |
((WizardPanel)parent).callStateChanged(b); |
|
799 |
} |
|
800 |
|
|
801 |
/* |
|
802 |
* (non-Javadoc) |
|
803 |
* @see org.gvsig.gui.beans.panelGroup.AbstractPanelGroup#loadPanels(org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader) |
|
804 |
*/ |
|
805 |
public void loadPanels(IPanelGroupLoader loader) throws ListCouldntAddPanelException, EmptyPanelGroupException, EmptyPanelGroupGUIException { |
|
806 |
// This code will be executed when is creating the dialog of properties |
|
807 |
if (getReference() != null) { |
|
808 |
FLyrVect lyr = (FLyrVect) getReference(); |
|
809 |
|
|
810 |
DataManager dataManager = DALLocator.getDataManager(); |
|
811 |
//Create the datastore parameters and fill them |
|
812 |
WFSStoreParameters parameters; |
|
813 |
try { |
|
814 |
parameters = (WFSStoreParameters) dataManager |
|
815 |
.createStoreParameters(WFSStoreProvider.NAME); |
|
816 |
parameters.setUrl(serverExplorer.getUrl()); |
|
817 |
parameters.setVersion(serverExplorer.getVersion()); |
|
818 |
//parameters.setFeatureType(namespacePrefix, namespace, featureType); |
|
819 |
|
|
820 |
//dataSource.setDriver(lyr.getWfsDriver()); |
|
821 |
|
|
822 |
//setServerExplorer(dataSource); |
|
823 |
|
|
824 |
super.loadPanels(loader); |
|
825 |
|
|
826 |
// HashMap<String, Object> info = lyr.getProperties(); |
|
827 |
// setSelectedFeature((WFSLayerNode)info.get("wfsLayerNode")); |
|
828 |
// setStatus((WFSStatus)info.get("status")); |
|
829 |
// setLayerName(lyr.getName()); |
|
830 |
// setVisible(true); |
|
831 |
// refreshInfo(); |
|
832 |
} catch (InitializeException e) { |
|
833 |
// TODO Auto-generated catch block |
|
834 |
e.printStackTrace(); |
|
835 |
} catch (ProviderNotRegisteredException e) { |
|
836 |
// TODO Auto-generated catch block |
|
837 |
e.printStackTrace(); |
|
838 |
} |
|
839 |
return; |
|
840 |
} |
|
841 |
|
|
842 |
// This will executed when is adding a new WFS layer: |
|
843 |
super.loadPanels(loader); |
|
844 |
} |
|
845 |
|
|
846 |
///// BEGIN: METHODS FOR INITIALIZE THIS PANEL AS A COMPONENT OF A PROPERTIES DIALOG ///// |
|
847 |
|
|
848 |
|
|
849 |
/** |
|
850 |
* @see WFSSelectFeaturePanel#setLayerName(String) |
|
851 |
*/ |
|
852 |
public void setLayerName(String name) { |
|
853 |
getFeaturesPanel().setLayerName(name); |
|
854 |
} |
|
855 |
|
|
856 |
/** |
|
857 |
* Updates the information stored at the wizard's data and <i>info</i> panel. |
|
858 |
*/ |
|
859 |
public void refreshInfo(){ |
|
860 |
WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature(); |
|
861 |
|
|
862 |
if (selectedFeature != null) { |
|
863 |
selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields()); |
|
864 |
} |
|
865 |
|
|
866 |
serverExplorer.setUserName(getOptionsPanel().getUserName()); |
|
867 |
serverExplorer.setMaxFeatures(getOptionsPanel().getBuffer()); |
|
868 |
serverExplorer.setTimeOut(getOptionsPanel().getTimeout()); |
|
869 |
getInfoPanel().refresh(selectedFeature); |
|
870 |
} |
|
871 |
|
|
872 |
/** |
|
873 |
* @return the selectedFeatureManager |
|
874 |
*/ |
|
875 |
public WFSSelectedFeatureManager getSelectedFeatureManager() { |
|
876 |
return selectedFeatureManager; |
|
877 |
} |
|
878 |
|
|
879 |
public void setSelectedCache(String selectedCache) { |
|
880 |
this.cacheSelected = selectedCache; |
|
881 |
} |
|
882 |
} |
|
0 | 883 |
tags/v2_0_0_Build_2050/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSFilterPanel.java | ||
---|---|---|
1 |
package org.gvsig.wfs.gui.panels; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.event.MouseAdapter; |
|
5 |
import java.awt.event.MouseEvent; |
|
6 |
import java.io.ByteArrayInputStream; |
|
7 |
import java.io.InputStream; |
|
8 |
import java.text.DateFormat; |
|
9 |
import java.text.ParseException; |
|
10 |
import java.util.Comparator; |
|
11 |
import java.util.HashMap; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.Map; |
|
14 |
import java.util.Set; |
|
15 |
import java.util.StringTokenizer; |
|
16 |
import java.util.TreeSet; |
|
17 |
import java.util.Vector; |
|
18 |
|
|
19 |
import javax.swing.DefaultListModel; |
|
20 |
import javax.swing.JOptionPane; |
|
21 |
import javax.swing.event.DocumentEvent; |
|
22 |
import javax.swing.event.DocumentListener; |
|
23 |
import javax.swing.event.TreeSelectionEvent; |
|
24 |
import javax.swing.event.TreeSelectionListener; |
|
25 |
import javax.swing.tree.DefaultMutableTreeNode; |
|
26 |
import javax.swing.tree.DefaultTreeModel; |
|
27 |
import javax.swing.tree.TreePath; |
|
28 |
|
|
29 |
import org.gvsig.andami.PluginServices; |
|
30 |
import org.gvsig.andami.messages.NotificationManager; |
|
31 |
import org.gvsig.app.gui.filter.ExpressionDataSource; |
|
32 |
import org.gvsig.app.gui.filter.FilterException; |
|
33 |
import org.gvsig.app.sqlQueryValidation.SQLQueryValidation; |
|
34 |
import org.gvsig.fmap.dal.DataStore; |
|
35 |
import org.gvsig.fmap.dal.feature.Feature; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
38 |
import org.gvsig.gui.beans.Messages; |
|
39 |
import org.gvsig.gui.beans.filterPanel.filterQueryPanel.FilterQueryJPanel; |
|
40 |
import org.gvsig.gui.beans.panelGroup.IPanelGroup; |
|
41 |
import org.gvsig.remoteclient.wfs.WFSFeatureField; |
|
42 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
43 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
44 |
import org.gvsig.utils.stringNumberUtilities.StringNumberUtilities; |
|
45 |
import org.gvsig.wfs.gui.panels.fieldstree.FieldsTreeTableModel; |
|
46 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature; |
|
47 |
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration; |
|
48 |
import org.slf4j.Logger; |
|
49 |
import org.slf4j.LoggerFactory; |
|
50 |
|
|
51 |
import Zql.ZExp; |
|
52 |
import Zql.ZqlParser; |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
57 |
* |
|
58 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
59 |
* |
|
60 |
* This program is free software; you can redistribute it and/or |
|
61 |
* modify it under the terms of the GNU General Public License |
|
62 |
* as published by the Free Software Foundation; either version 2 |
|
63 |
* of the License, or (at your option) any later version. |
|
64 |
* |
|
65 |
* This program is distributed in the hope that it will be useful, |
|
66 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
67 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
68 |
* GNU General Public License for more details. |
|
69 |
* |
|
70 |
* You should have received a copy of the GNU General Public License |
|
71 |
* along with this program; if not, write to the Free Software |
|
72 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
73 |
* |
|
74 |
* For more information, contact: |
|
75 |
* |
|
76 |
* Generalitat Valenciana |
|
77 |
* Conselleria d'Infraestructures i Transport |
|
78 |
* Av. Blasco Ib??ez, 50 |
|
79 |
* 46010 VALENCIA |
|
80 |
* SPAIN |
|
81 |
* |
|
82 |
* +34 963862235 |
|
83 |
* gvsig@gva.es |
|
84 |
* www.gvsig.gva.es |
|
85 |
* |
|
86 |
* or |
|
87 |
* |
|
88 |
* IVER T.I. S.A |
|
89 |
* Salamanca 50 |
|
90 |
* 46005 Valencia |
|
91 |
* Spain |
|
92 |
* |
|
93 |
* +34 963163400 |
|
94 |
* dac@iver.es |
|
95 |
*/ |
|
96 |
|
|
97 |
/** |
|
98 |
* <p>Panel that provides tools to apply a filter to the values of a feature.</p> |
|
99 |
* <p>Improves the functionality of {@link FilterQueryJPanel FilterQueryJPanel}.</p> |
|
100 |
* |
|
101 |
* @see FilterQueryJPanel |
|
102 |
* |
|
103 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
104 |
*/ |
|
105 |
public class WFSFilterPanel extends FilterQueryJPanel implements IWFSPanel { |
|
106 |
private static final long serialVersionUID = -6041218260822015810L; |
|
107 |
private static final Logger LOG = LoggerFactory.getLogger(WFSFilterPanel.class); |
|
108 |
|
|
109 |
private static Logger logger = LoggerFactory.getLogger(WFSFilterPanel.class); |
|
110 |
private ExpressionDataSource model = null; |
|
111 |
private FieldsTreeTableModel fieldsTreeTableModel; |
|
112 |
private boolean panelAsATabForWFSLayersLoad; |
|
113 |
private TreePath currentPath; |
|
114 |
private Map<String, Map<String, String>> allFieldsAndValuesKnownOfCurrentLayer; // This will have all values (not repeated) known of all fields (not repeated) |
|
115 |
|
|
116 |
private DataStore dataStore = null; |
|
117 |
|
|
118 |
///// GUI METHODS //// |
|
119 |
|
|
120 |
/** |
|
121 |
* This method initializes |
|
122 |
* |
|
123 |
* @param parent A reference to the parent container component of this component |
|
124 |
*/ |
|
125 |
public WFSFilterPanel() { |
|
126 |
super(); |
|
127 |
currentPath = null; |
|
128 |
allFieldsAndValuesKnownOfCurrentLayer = new HashMap<String, Map<String, String>>(); // Initial capacity = 0 |
|
129 |
|
|
130 |
// At beginning, the JList is disabled (and its set a particular color for user could knew it) |
|
131 |
super.getValuesJList().setEnabled(false); |
|
132 |
//getValuesJList().setBackground(new Color(220, 220, 220)); |
|
133 |
|
|
134 |
//The validation option is disabled by default |
|
135 |
this.getValidateFilterExpressionJCheckBox().setSelected(false); |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* @see org.gvsig.gui.beans.filterPanel.AbstractFilterQueryJPanel#initialize() |
|
141 |
*/ |
|
142 |
protected void initialize() { |
|
143 |
setLabel(PluginServices.getText(this, "filter")); |
|
144 |
setLabelGroup(PluginServices.getText(this, "wfs")); |
|
145 |
super.initialize(); |
|
146 |
this.resizeHeight(380); |
|
147 |
|
|
148 |
defaultTreeModel = (DefaultTreeModel)fieldsJTree.getModel(); |
|
149 |
|
|
150 |
this.addNewListeners(); |
|
151 |
panelAsATabForWFSLayersLoad = true; |
|
152 |
getValidateFilterExpressionJCheckBox().setSelected(true); |
|
153 |
|
|
154 |
getValuesJLabel().setToolTipText(Messages.getText("values_of_the_selected_field_explanation")); |
|
155 |
getFieldsJLabel().setToolTipText(Messages.getText("fields_of_the_selected_feature_explanation")); |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* Adds some more listener to the components of the panel |
|
160 |
*/ |
|
161 |
private void addNewListeners() { |
|
162 |
// Enable "Apply" button when user changes the filter query |
|
163 |
txtExpression.getDocument().addDocumentListener(new DocumentListener() { |
|
164 |
/* |
|
165 |
* (non-Javadoc) |
|
166 |
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) |
|
167 |
*/ |
|
168 |
public void changedUpdate(DocumentEvent e) { |
|
169 |
} |
|
170 |
|
|
171 |
/* |
|
172 |
* (non-Javadoc) |
|
173 |
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) |
|
174 |
*/ |
|
175 |
public void insertUpdate(DocumentEvent e) { |
|
176 |
if (!panelAsATabForWFSLayersLoad) { |
|
177 |
IPanelGroup panelGroup = getPanelGroup(); |
|
178 |
|
|
179 |
if (panelGroup == null) |
|
180 |
return; |
|
181 |
|
|
182 |
((WFSParamsPanel)panelGroup).setApplicable(true); |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
/* |
|
187 |
* (non-Javadoc) |
|
188 |
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) |
|
189 |
*/ |
|
190 |
public void removeUpdate(DocumentEvent e) { |
|
191 |
if (!panelAsATabForWFSLayersLoad) { |
|
192 |
IPanelGroup panelGroup = getPanelGroup(); |
|
193 |
|
|
194 |
if (panelGroup == null) |
|
195 |
return; |
|
196 |
|
|
197 |
((WFSParamsPanel)panelGroup).setApplicable(true); |
|
198 |
} |
|
199 |
} |
|
200 |
}); |
|
201 |
|
|
202 |
// Listener for "fieldsJTree" |
|
203 |
getFieldsJTree().addMouseListener(new MouseAdapter() { |
|
204 |
/* |
|
205 |
* (non-Javadoc) |
|
206 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
207 |
*/ |
|
208 |
public void mouseClicked(MouseEvent e) { |
|
209 |
int row = fieldsJTree.getRowForLocation(e.getX(), e.getY()); |
|
210 |
TreePath treePath = fieldsJTree.getPathForLocation(e.getX(), e.getY()); |
|
211 |
|
|
212 |
if (row > -1) { |
|
213 |
switch (e.getClickCount()) { |
|
214 |
case 2: |
|
215 |
putSymbolOfSelectedByMouseBranch(treePath); |
|
216 |
break; |
|
217 |
} |
|
218 |
} |
|
219 |
} |
|
220 |
}); |
|
221 |
|
|
222 |
// Listener for "valuesJList" |
|
223 |
getValuesJList().addMouseListener(new MouseAdapter() { |
|
224 |
/* |
|
225 |
* (non-Javadoc) |
|
226 |
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
|
227 |
*/ |
|
228 |
public void mouseClicked(MouseEvent e) { |
|
229 |
int index = getValuesJList().getSelectedIndex(); |
|
230 |
|
|
231 |
// Avoids exception when no value is in the list |
|
232 |
if (index == -1) |
|
233 |
return; |
|
234 |
|
|
235 |
if (e.getClickCount() == 2){ |
|
236 |
String valor = valuesListModel.getElementAt(index).toString(); |
|
237 |
|
|
238 |
// If value is an string -> set it between apostrophes |
|
239 |
if (getNodeOfCurrentPath().getDataType().getType() == DataTypes.STRING) { |
|
240 |
putSymbol("'" + valor + "'"); |
|
241 |
} |
|
242 |
else { |
|
243 |
putSymbol(valor); |
|
244 |
} |
|
245 |
} |
|
246 |
} |
|
247 |
}); |
|
248 |
|
|
249 |
// Listener for a branch of the tree selection |
|
250 |
getFieldsJTree().addTreeSelectionListener(new TreeSelectionListener() { |
|
251 |
/* |
|
252 |
* (non-Javadoc) |
|
253 |
* @see javax.swing.event.TreeSelectionListener#valueChanged(javax.swing.event.TreeSelectionEvent) |
|
254 |
*/ |
|
255 |
public void valueChanged(TreeSelectionEvent e) { |
|
256 |
if (dataStore != null){ |
|
257 |
currentPath = e.getPath(); |
|
258 |
fillValuesByPath(currentPath); |
|
259 |
} |
|
260 |
} |
|
261 |
}); |
|
262 |
|
|
263 |
// Listener: when a user writes something on the textarea -> set it's foreground color to black |
|
264 |
getTxtExpression().getDocument().addDocumentListener(new DocumentListener() { |
|
265 |
/* |
|
266 |
* (non-Javadoc) |
|
267 |
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent) |
|
268 |
*/ |
|
269 |
public void changedUpdate(DocumentEvent e) { |
|
270 |
} |
|
271 |
|
|
272 |
/* |
|
273 |
* (non-Javadoc) |
|
274 |
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent) |
|
275 |
*/ |
|
276 |
public void insertUpdate(DocumentEvent e) { |
|
277 |
getTxtExpression().setForeground(Color.BLACK); |
|
278 |
} |
|
279 |
|
|
280 |
/* |
|
281 |
* (non-Javadoc) |
|
282 |
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent) |
|
283 |
*/ |
|
284 |
public void removeUpdate(DocumentEvent e) { |
|
285 |
getTxtExpression().setForeground(Color.BLACK); |
|
286 |
} |
|
287 |
}); |
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 |
* Gets the element that the 'currentPath' field aims |
|
292 |
* |
|
293 |
* @return An XMLElement |
|
294 |
*/ |
|
295 |
private WFSFeatureField getNodeOfCurrentPath() { |
|
296 |
|
|
297 |
if (currentPath != null) { |
|
298 |
Object node = currentPath.getLastPathComponent(); |
|
299 |
|
|
300 |
if ((node != null) && (node instanceof WFSFeatureField)) { |
|
301 |
return (WFSFeatureField) node; |
|
302 |
} |
|
303 |
} |
|
304 |
|
|
305 |
return null; |
|
306 |
} |
|
307 |
|
|
308 |
/** |
|
309 |
* Puts the symbol of selected branch |
|
310 |
* |
|
311 |
* @param mouseEvent A MouseEvent with information of the selected branch |
|
312 |
*/ |
|
313 |
public void putSymbolOfSelectedByMouseBranch(TreePath treePath) { |
|
314 |
// Sets the node selected |
|
315 |
if (treePath != null) { |
|
316 |
putSymbol("\"" + this.getPathOfLeafWithoutRoot(treePath.getLastPathComponent().toString()) + "\""); |
|
317 |
} |
|
318 |
} |
|
319 |
|
|
320 |
/** |
|
321 |
* This method returns the path without the root, of a node of a tree |
|
322 |
* Each node is separated from its parent with the symbol "/" |
|
323 |
* |
|
324 |
* @param node A leaf node |
|
325 |
* @return An string with the path |
|
326 |
*/ |
|
327 |
private String getPathOfLeafWithoutRoot(Object node) { |
|
328 |
String path = ""; |
|
329 |
|
|
330 |
if ((node != null) && (node instanceof IXSElementDeclaration)) { |
|
331 |
IXSElementDeclaration element = (IXSElementDeclaration) node; |
|
332 |
IXSElementDeclaration parent = element.getParentElement(); |
|
333 |
path = element.getNodeName(); |
|
334 |
|
|
335 |
while (parent.getParentElement() != null){ |
|
336 |
path = parent.getNodeName() + "/" + path; |
|
337 |
parent = parent.getParentElement(); |
|
338 |
} |
|
339 |
}else if (node instanceof String){ |
|
340 |
path = node.toString(); |
|
341 |
} |
|
342 |
|
|
343 |
return path; |
|
344 |
} |
|
345 |
|
|
346 |
/** |
|
347 |
* Gets the value of the inner attribute: 'panelAsATabForWFSLayersLoad' |
|
348 |
* |
|
349 |
* @return A boolean value |
|
350 |
*/ |
|
351 |
public boolean getWFSFilterPanelIsAsTabForWFSLayersLoad() { |
|
352 |
return this.panelAsATabForWFSLayersLoad; |
|
353 |
} |
|
354 |
|
|
355 |
/** |
|
356 |
* Refresh all information about fields |
|
357 |
* |
|
358 |
* @param feature a feature with fields |
|
359 |
*/ |
|
360 |
public void refresh(WFSSelectedFeature feature) { |
|
361 |
setFields(feature); |
|
362 |
} |
|
363 |
|
|
364 |
/** |
|
365 |
* Gets the query that will be send to the server |
|
366 |
* @return SQL query (just the where part) |
|
367 |
*/ |
|
368 |
public String getQuery(){ |
|
369 |
String writtenQuery = txtExpression.getText().trim(); |
|
370 |
|
|
371 |
// Validate expression |
|
372 |
if (!this.validateExpression(writtenQuery)) { |
|
373 |
getTxtExpression().setForeground(Color.red); |
|
374 |
return null; |
|
375 |
} |
|
376 |
else { |
|
377 |
logger.debug("Codified WFS filter query: " + writtenQuery); |
|
378 |
|
|
379 |
if (writtenQuery.trim().length() == 0){ |
|
380 |
return null; |
|
381 |
} |
|
382 |
// Codify expression (only if the validation has been successful) |
|
383 |
return formatResutl(writtenQuery); // Ignores the spaces at beginning and end of the chain of characters |
|
384 |
} |
|
385 |
} |
|
386 |
|
|
387 |
/** |
|
388 |
* Gets the filter expression from the user interface |
|
389 |
*/ |
|
390 |
public String getFilterExpressionFromInterface() { |
|
391 |
return getTxtExpression().getText(); |
|
392 |
} |
|
393 |
|
|
394 |
/** |
|
395 |
* Writes the filter expression into the user interface |
|
396 |
* @param filterExpression An string |
|
397 |
*/ |
|
398 |
public void setFilterExpressionIntoInterface(String filterExpression){ |
|
399 |
getTxtExpression().setText(filterExpression); |
|
400 |
} |
|
401 |
|
|
402 |
/** |
|
403 |
* Removes text in the JTextArea that has the filter subconsultation |
|
404 |
*/ |
|
405 |
public void removeFilterExpression() { |
|
406 |
getTxtExpression().setText(""); |
|
407 |
} |
|
408 |
|
|
409 |
private String formatResutl(String query) { |
|
410 |
if ((query == null) || (query.equals(""))){ |
|
411 |
return null; |
|
412 |
} |
|
413 |
InputStream is = new ByteArrayInputStream(query.getBytes()); |
|
414 |
ZqlParser parser = new ZqlParser(); |
|
415 |
parser.initParser(is); |
|
416 |
ZExp exp; |
|
417 |
try { |
|
418 |
exp = parser.readExpression(); |
|
419 |
return exp.toString(); |
|
420 |
} catch (Zql.ParseException e) { |
|
421 |
LOG.error("Formatting the filter request", e); |
|
422 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "filter_with_an_incorrect_format"), PluginServices.getText(null, "error_validating_filter_query"), JOptionPane.ERROR_MESSAGE); |
|
423 |
} |
|
424 |
return query; |
|
425 |
} |
|
426 |
|
|
427 |
/** |
|
428 |
* Checks the filter expression if it's correct |
|
429 |
* |
|
430 |
* @param query The query expression to analyze |
|
431 |
* @return True if it's valid or false if not |
|
432 |
*/ |
|
433 |
private boolean validateExpression(String query) { |
|
434 |
try { |
|
435 |
// If it's needed to validate the query |
|
436 |
if (getValidateFilterExpressionJCheckBox().isSelected()) { |
|
437 |
// If it's an empty query -> ok |
|
438 |
if (query.trim().length() == 0) |
|
439 |
return true; |
|
440 |
|
|
441 |
// Replace all Date(dd-mmm-yyyy) format to ddd-mmm-yyyy (characters will replaced to spaces) |
|
442 |
int index = 0; |
Also available in: Unified diff