Revision 38727

View differences:

tags/v2_0_0_Build_2051/extensions/extWFS2/src/org/gvsig/wfs/WFSClientExtension.java
1
package org.gvsig.wfs;
2

  
3
import org.gvsig.andami.IconThemeHelper;
4
import org.gvsig.andami.plugins.Extension;
5
import org.gvsig.app.extension.AddLayer;
6
import org.gvsig.app.project.documents.view.legend.gui.ThemeManagerWindow;
7
import org.gvsig.fmap.dal.store.wfs.WFSStoreProvider;
8
import org.gvsig.fmap.mapcontext.MapContextLocator;
9
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
10
import org.gvsig.gui.beans.panelGroup.PanelGroupManager;
11
import org.gvsig.tools.ToolsLocator;
12
import org.gvsig.tools.extensionpoint.ExtensionPoint;
13
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
14
import org.gvsig.wfs.gui.panels.WFSAreaPanel;
15
import org.gvsig.wfs.gui.panels.WFSFilterPanel;
16
import org.gvsig.wfs.gui.panels.WFSInfoPanel;
17
import org.gvsig.wfs.gui.panels.WFSOptionsPanel;
18
import org.gvsig.wfs.gui.panels.WFSParamsPanel;
19
import org.gvsig.wfs.gui.panels.WFSSelectFeaturePanel;
20
import org.gvsig.wfs.gui.panels.WFSSelectFieldsPanel;
21
import org.gvsig.wfs.gui.toc.WFSProperties;
22
import org.gvsig.wfs.gui.wizards.WFSWizard;
23

  
24

  
25
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
26
 *
27
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
28
 *
29
 * This program is free software; you can redistribute it and/or
30
 * modify it under the terms of the GNU General Public License
31
 * as published by the Free Software Foundation; either version 2
32
 * of the License, or (at your option) any later version.
33
 *
34
 * This program is distributed in the hope that it will be useful,
35
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
 * GNU General Public License for more details.
38
 *
39
 * You should have received a copy of the GNU General Public License
40
 * along with this program; if not, write to the Free Software
41
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
42
 *
43
 * For more information, contact:
44
 *
45
 *  Generalitat Valenciana
46
 *   Conselleria d'Infraestructures i Transport
47
 *   Av. Blasco Ib??ez, 50
48
 *   46010 VALENCIA
49
 *   SPAIN
50
 *
51
 *      +34 963862235
52
 *   gvsig@gva.es
53
 *      www.gvsig.gva.es
54
 *
55
 *    or
56
 *
57
 *   IVER T.I. S.A
58
 *   Salamanca 50
59
 *   46005 Valencia
60
 *   Spain
61
 *
62
 *   +34 963163400
63
 *   dac@iver.es
64
 */
65
/* CVS MESSAGES:
66
 *
67
 * $Id: WFSClientExtension.java 18381 2008-01-30 12:00:25Z jpiera $
68
 * $Log$
69
 * Revision 1.6.2.2  2006-11-17 11:28:45  ppiqueras
70
 * Corregidos bugs y añadida nueva funcionalidad.
71
 *
72
 * Revision 1.8  2006/10/02 09:09:45  jorpiell
73
 * Cambios del 10 copiados al head
74
 *
75
 * Revision 1.6  2006/09/05 15:41:52  jorpiell
76
 * A?adida la funcionalidad de cargar WFS desde el cat?logo
77
 *
78
 * Revision 1.5  2006/07/05 12:04:50  jorpiell
79
 * A?adida la opci?n de propiedades vectoriales
80
 *
81
 * Revision 1.4  2006/06/21 12:35:45  jorpiell
82
 * 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
83
 *
84
 * Revision 1.3  2006/05/19 12:57:34  jorpiell
85
 * Ahora hereda de Extension
86
 *
87
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
88
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
89
 *
90
 *
91
 */
92
/**
93
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
94
 */
95
public class WFSClientExtension extends Extension{
96

  
97
	public void initialize() {
98
		// Adds a new tab to the "add layer" wizard for WFS layer creation
99
		AddLayer.addWizard(WFSWizard.class);
100
		
101
		ExtensionPointManager extensionPointManager = ToolsLocator
102
		.getExtensionPointManager();
103
     	
104
		//WFS properties tabs:
105
		ExtensionPoint wfsTabExtensionPoint = extensionPointManager.add("WFSPropertiesDialog");
106
		wfsTabExtensionPoint.append("info", "", WFSInfoPanel.class);
107
		wfsTabExtensionPoint.append("features", "", WFSSelectFeaturePanel.class);
108
		wfsTabExtensionPoint.append("fields", "", WFSSelectFieldsPanel.class);
109
		wfsTabExtensionPoint.append("options", "", WFSOptionsPanel.class);
110
		wfsTabExtensionPoint.append("filter", "", WFSFilterPanel.class);
111
		wfsTabExtensionPoint.append("area", "", WFSAreaPanel.class);
112
		
113
		//Adding forms to the generic vectorial properties
114
		ThemeManagerWindow.addPage(WFSProperties.class);
115
		ThemeManagerWindow.setTabEnabledForLayer(WFSProperties.class, FLyrVect.class, true);
116
		
117
	      // Registers this class as a "PanelGroup" type
118
        PanelGroupManager.getManager().registerPanelGroup(WFSParamsPanel.class);
119

  
120
        // Sets this class as the default "PanelGroup" type
121
        PanelGroupManager.getManager().setDefaultType(WFSParamsPanel.class);
122
		
123
    	initilizeIcons();		
124
	}
125

  
126
	/*
127
	 * (non-Javadoc)
128
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
129
	 */
130
	public void execute(String actionCommand) {
131
		// TODO Auto-generated method stub
132
		
133
	}	
134

  
135
	/*
136
	 * (non-Javadoc)
137
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
138
	 */
139
	public boolean isEnabled() {
140
		// TODO Auto-generated method stub
141
		return false;
142
	}
143

  
144
	/*
145
	 * (non-Javadoc)
146
	 * @see com.iver.andami.plugins.IExtension#isVisible()
147
	 */
148
	public boolean isVisible() {
149
		// TODO Auto-generated method stub
150
		return false;
151
	}
152
	
153
	/**
154
	 * Prepares support for the icons that can be used in the WFS extension.
155
	 */
156
	void initilizeIcons(){
157
		IconThemeHelper.registerIcon("layer", "layer-icon-wfs", this);
158
		MapContextLocator.getMapContextManager().registerIconLayer(WFSStoreProvider.NAME, "layer-icon-wfs");
159

  
160
		// WFSAreaPanel.java
161
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-undo", this);
162
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-move", this);
163
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-scaling", this); // ???
164
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-pan", this);
165
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-zoom-in", this);
166
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-zoom-out", this);
167
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-zoom-back", this);
168
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-zoom-all", this);
169
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-zoom-plus", this);
170
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-zoom-minus", this);
171
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-query-area", this);
172
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-query-distance", this);
173
		IconThemeHelper.registerIcon("wfs-properties", "wfs-properties-validate-area", this); // ???
174
	}
175

  
176
}
0 177

  
tags/v2_0_0_Build_2051/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSInfoPanel.java
1
package org.gvsig.wfs.gui.panels;
2

  
3
import java.awt.Dimension;
4
import java.awt.Graphics;
5
import java.util.Vector;
6

  
7
import org.gvsig.andami.PluginServices;
8
import org.gvsig.app.project.documents.view.toc.gui.HTMLInfoPanel;
9
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
10
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
11
import org.gvsig.remoteclient.wfs.WFSFeatureField;
12
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
13

  
14

  
15
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
16
 *
17
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
18
 *
19
 * This program is free software; you can redistribute it and/or
20
 * modify it under the terms of the GNU General Public License
21
 * as published by the Free Software Foundation; either version 2
22
 * of the License, or (at your option) any later version.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
 * GNU General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU General Public License
30
 * along with this program; if not, write to the Free Software
31
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
32
 *
33
 * For more information, contact:
34
 *
35
 *  Generalitat Valenciana
36
 *   Conselleria d'Infraestructures i Transport
37
 *   Av. Blasco Ib??ez, 50
38
 *   46010 VALENCIA
39
 *   SPAIN
40
 *
41
 *      +34 963862235
42
 *   gvsig@gva.es
43
 *      www.gvsig.gva.es
44
 *
45
 *    or
46
 *
47
 *   IVER T.I. S.A
48
 *   Salamanca 50
49
 *   46005 Valencia
50
 *   Spain
51
 *
52
 *   +34 963163400
53
 *   dac@iver.es
54
 */
55
/* CVS MESSAGES:
56
 *
57
 * $Id: WFSInfoPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $
58
 * $Log$
59
 * Revision 1.16  2006-12-26 10:25:37  ppiqueras
60
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
61
 *
62
 * Revision 1.15  2006/12/26 09:23:23  ppiqueras
63
 * 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).
64
 *
65
 * Revision 1.13  2006/10/10 12:55:06  jorpiell
66
 * Se ha a?adido el soporte de features complejas
67
 *
68
 * Revision 1.12  2006/10/05 12:49:57  jorpiell
69
 * Cambiada la cadena buffer por max_features
70
 *
71
 * Revision 1.11  2006/10/02 09:09:45  jorpiell
72
 * Cambios del 10 copiados al head
73
 *
74
 * Revision 1.9.2.1  2006/09/19 12:28:11  jorpiell
75
 * Ya no se depende de geotools
76
 *
77
 * Revision 1.10  2006/09/18 12:07:31  jorpiell
78
 * Se ha sustituido geotools por el driver de remoteservices
79
 *
80
 * Revision 1.9  2006/07/24 07:30:33  jorpiell
81
 * Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
82
 *
83
 * Revision 1.8  2006/07/21 11:50:31  jaume
84
 * improved appearance
85
 *
86
 * Revision 1.7  2006/06/21 12:35:45  jorpiell
87
 * 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
88
 *
89
 * Revision 1.6  2006/06/15 07:50:58  jorpiell
90
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
91
 *
92
 * Revision 1.5  2006/05/25 16:22:23  jorpiell
93
 * Cambio para eliminar el namespace de los atributos
94
 *
95
 * Revision 1.4  2006/05/25 16:01:43  jorpiell
96
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
97
 *
98
 * Revision 1.3  2006/05/25 10:31:06  jorpiell
99
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
100
 *
101
 * Revision 1.2  2006/05/23 08:09:39  jorpiell
102
 * 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
103
 *
104
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
105
 * 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().
106
 *
107
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
108
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
109
 *
110
 *
111
 */
112

  
113
/**
114
 * <p>Panel that provides information about the service offered by the WFS server connected.</p>
115
 * 
116
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
117
 */
118
public class WFSInfoPanel extends HTMLInfoPanel implements IWFSPanel {
119
	private static final long serialVersionUID = 2605168444543321684L;
120

  
121
	private final String service_title       = PluginServices.getText(this, "service_info");
122
	private final String server              = PluginServices.getText(this, "server");
123
	private final String server_type         = PluginServices.getText(this, "server_type");
124
	private final String server_abstract     = PluginServices.getText(this, "server_abstract");
125
	private final String server_title        = PluginServices.getText(this, "server_title");
126
	private final String layers_title        = PluginServices.getText(this, "selected_layer");
127
	private final String layer_title         = PluginServices.getText(this, "layer_title");
128
	private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
129
	private final String options			 = PluginServices.getText(this, "properties");
130
	private final String layer_fields 	 	 = PluginServices.getText(this, "fields");
131
	private final String layer_name			 = PluginServices.getText(this, "name");
132
	private final String timeout 			 = PluginServices.getText(this, "timeout");
133
	private final String buffer				 = PluginServices.getText(this, "max_features");
134
	private final String layer_geometry		 = PluginServices.getText(this, "geometry");
135
	private final String layer_srs			 = PluginServices.getText(this, "srs");
136
	
137
	/**
138
	 * Creates a new instance of InfoPanel with double buffer and null layout
139
	 */
140
	public WFSInfoPanel() {
141
		super();
142
		initialize();
143
		this.setPreferredSize(new Dimension(10,10));
144
	}	
145
	
146
	/*
147
	 * (non-Javadoc)
148
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
149
	 */
150
	protected void paintComponent(Graphics g) {
151
		IPanelGroup panelGroup = getPanelGroup();
152
		
153
		if (panelGroup == null)
154
			return;
155
		
156
		((WFSParamsPanel)panelGroup).refreshCapabilitiesInfo();
157
		super.paintComponent(g);
158
	}
159

  
160
	/**
161
	 * Fills the text pane with a data table describing the
162
	 * service and the selected settings.
163
	 *
164
	 * @param WFSWizardData dataSource: connection info
165
	 * @param WFSLayer layer: the selected layer
166
	 */
167
	public void refresh(WFSSelectedFeature layer) {
168
		WFSServerExplorer serverExplorer = getServerExplorer();
169
		
170
		String server_text = serverExplorer.getUrl();
171
		String server_type_text = serverExplorer.getServerType();
172
		String server_title_text = serverExplorer.getTitle();
173
		String server_abstract_text = serverExplorer.getAbstract();
174
		
175
		if (server_text == null)
176
			server_text = "-";
177
		if (server_type_text == null)
178
			server_type_text = "-";
179
		if (server_title_text == null)
180
			server_title_text = "-";
181
		if (server_abstract_text == null)
182
			server_abstract_text = "-";
183

  
184
		String layers_html = "";
185
		if (layer!=null) {
186
			String layer_name_text = layer.getName();
187
			String layer_abstract_text = layer.getAbstract();
188
			String layer_title_text = layer.getTitle();
189
			String layer_fields_text = "-";
190
			String layer_geometry_text = "-";
191
			String layer_srs_text = "-";
192

  
193
			Vector<Object> fields = layer.getSelectedFields();
194
			layer_fields_text = "";
195

  
196
			for (int i=0 ; i<fields.size() ; i++){
197
				WFSFeatureField field = (WFSFeatureField)fields.get(i);
198
				if (field.isGeometry()){
199
					layer_fields_text = layer_fields_text + field.getName() +
200
					" (" +
201
					PluginServices.getText(this, field.getType()) + ")";
202
				}else{
203
					layer_fields_text = layer_fields_text + field.getName();
204
				}
205
				if (i < fields.size() -1){
206
					layer_fields_text = layer_fields_text + ", ";
207
				}
208
			}
209

  
210
			layer_geometry_text = PluginServices.getText(this, layer.getGeometryField().getType());
211
			if (layer_geometry_text.equals("")){
212
				layer_geometry_text = "-";
213
			}
214

  
215
			if (layer.getSrs().size() > 0){
216
				layer_srs_text = (String)layer.getSrs().get(0);
217
			}
218

  
219
			if (layer_name_text ==null)
220
				layer_name_text = "-";
221
			if (layer_abstract_text==null)
222
				layer_abstract_text = "-";
223
			if (layer_title_text == null)
224
				layer_title_text = "-";
225
			StringBuffer layer_html = new StringBuffer();
226
			layer_html.append(setHTMLBasicProperty(layer_name, layer_name_text));
227
			layer_html.append(setHTMLBasicProperty(layer_title, layer_title_text));
228
			layer_html.append(setHTMLBasicProperty(layer_abstract, layer_abstract_text));
229
			layer_html.append(setHTMLBasicProperty(layer_geometry, layer_geometry_text));
230
			layer_html.append(setHTMLBasicProperty(layer_fields, layer_fields_text));
231
			layer_html.append(setHTMLBasicProperty(layer_srs, layer_srs_text));
232
			layers_html += layer_html.toString();
233
		}
234
		if (!layers_html.equals(""))
235
			layers_html = setHTMLTitleTable(layers_title, 2) + layers_html;
236

  
237
		String buffer_text = String.valueOf(serverExplorer.getMaxFeatures());
238
		String timeout_text = String.valueOf(serverExplorer.getTimeOut());
239

  
240
		StringBuffer options_html = new StringBuffer();
241
		options_html.append(setHTMLTitleTable(options , 2));
242
		options_html.append(setHTMLBasicProperty(timeout, timeout_text));
243
		options_html.append(setHTMLBasicProperty(buffer, buffer_text));
244
			
245
		StringBuffer service_html = new StringBuffer();
246
		service_html.append(setHTMLTitleTable(service_title, 2));
247
		service_html.append(setHTMLBasicProperty(server, server_text));
248
		service_html.append(setHTMLBasicProperty(server_type, server_type_text));
249
		service_html.append(setHTMLBasicProperty(server_title, server_title_text));
250
		service_html.append(setHTMLBasicProperty(server_abstract, server_abstract_text));
251
			
252
		StringBuffer html = new StringBuffer();
253
		html.append(setHTMLTable(service_html.toString()));
254
		html.append(setHTMLTable(layers_html.toString()));
255
		html.append(setHTMLTable(options_html.toString()));	
256
		
257
		addHTMLToPanel(setHTMLBody(html.toString()));		
258
	}	
259

  
260
	/* (non-Javadoc)
261
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
262
	 */
263
	public void accept() {
264
		// TODO Auto-generated method stub
265
		
266
	}
267

  
268
	/* (non-Javadoc)
269
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply()
270
	 */
271
	public void apply() {
272
		// TODO Auto-generated method stub
273
		
274
	}
275

  
276
	/* (non-Javadoc)
277
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel()
278
	 */
279
	public void cancel() {
280
		// TODO Auto-generated method stub
281
		
282
	}
283

  
284
	/* (non-Javadoc)
285
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected()
286
	 */
287
	public void selected() {
288
		// TODO Auto-generated method stub
289
		
290
	}
291
	
292
	/**
293
	 * <p>Gets the information of the wizard used to add or load panels.</p>
294
	 * 
295
	 * @return the wizard data
296
	 */
297
	public WFSServerExplorer getServerExplorer(){
298
		return (getPanelGroup() == null)? null: ((WFSParamsPanel)getPanelGroup()).getServerExplorer();  
299
	}
300
}
0 301

  
tags/v2_0_0_Build_2051/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSOptionsPanel.java
1
package org.gvsig.wfs.gui.panels;
2

  
3
import java.awt.Rectangle;
4
import java.text.NumberFormat;
5
import java.util.Vector;
6

  
7
import javax.swing.BorderFactory;
8
import javax.swing.JCheckBox;
9
import javax.swing.JFormattedTextField;
10
import javax.swing.JLabel;
11
import javax.swing.JPanel;
12
import javax.swing.JPasswordField;
13
import javax.swing.JTextField;
14
import javax.swing.border.TitledBorder;
15

  
16
import org.gvsig.andami.PluginServices;
17
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
18
import org.gvsig.utils.StringUtilities;
19
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
20

  
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: WFSOptionsPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $
65
 * $Log$
66
 * Revision 1.12  2007-02-22 12:25:39  ppiqueras
67
 * A?adidas tool tip text y etiqueta para de milisegundos.
68
 *
69
 * Revision 1.11  2006/10/05 12:49:57  jorpiell
70
 * Cambiada la cadena buffer por max_features
71
 *
72
 * Revision 1.10  2006/10/02 09:09:45  jorpiell
73
 * Cambios del 10 copiados al head
74
 *
75
 * Revision 1.9.2.1  2006/09/26 07:36:24  jorpiell
76
 * El WFS no reproyectaba porque no se le asignaba a la capa un sistema de referencia. Ahora ya se hace.
77
 *
78
 * Revision 1.9  2006/09/05 14:25:05  jorpiell
79
 * Eliminado el nombre de usuario y la contrase?a del panel de opciones
80
 *
81
 * Revision 1.8  2006/07/21 11:50:31  jaume
82
 * improved appearance
83
 *
84
 * Revision 1.7  2006/06/22 06:54:14  jorpiell
85
 * Se ha desabilitado el cuadro de di?logo del sistema de referencia
86
 *
87
 * Revision 1.6  2006/06/21 12:35:45  jorpiell
88
 * 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
89
 *
90
 * Revision 1.5  2006/06/15 07:50:58  jorpiell
91
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
92
 *
93
 * Revision 1.4  2006/06/01 15:40:50  jorpiell
94
 * Se ha capturado una excepci?n que saltaba al ejecutar la extensi?n en igl?s provocada por el signo "," que aparece en lo n?meros (en castellano ".").
95
 *
96
 * Revision 1.3  2006/05/23 08:09:39  jorpiell
97
 * 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
98
 *
99
 * Revision 1.2  2006/05/19 12:57:08  jorpiell
100
 * Modificados algunos paneles
101
 *
102
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
103
 * 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().
104
 *
105
 *
106
 */
107

  
108
/**
109
 * <p>Panel with options about the timeout, maximum number of features, the projection reference system, and
110
 *  if it's implemented, user and password.</p>
111
 * 
112
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
113
 * @author Pablo Piqueras Bartolom?
114
 */
115
public class WFSOptionsPanel extends AbstractWFSPanel {
116
	private static final long serialVersionUID = -769956995699452173L;
117

  
118
	private JPanel credentialsPanel = null;
119
	private JLabel usernameLabel = null;
120
	private JTextField usernameText = null;
121
	private JLabel passwordLabel = null;
122
	private JPasswordField passwordText = null;
123
	private JPanel connectionParamsPanel = null;
124
	private JLabel timeoutLabel = null;
125
	private JFormattedTextField bufferText = null;
126
	private JLabel bufferLabel = null;
127
	private JFormattedTextField timeOutText = null;
128
	private JPanel formatPanel = null;
129
	private JLabel srsLabel = null;
130
	private JTextField srsText = null;
131
	private JLabel jLabelMiliSeconds = null;
132
	private JPanel bufferPanel = null;
133
	private JPanel timeOutPanel = null;
134
	private JPanel northPanel = null;
135
	//Cache panel
136
	private JPanel cachePanel = null;
137
	private JCheckBox enableCacheCheckBox = null;
138

  
139
	/**
140
	 * Creates a new WFS options panel.
141
	 */
142
	public WFSOptionsPanel() {
143
		super();
144
		initialize();
145
	}
146

  
147
	/**
148
	 * This method initializes usernameText
149
	 *
150
	 * @return javax.swing.JTextField
151
	 */
152
	private JTextField getUsernameText() {
153
		if (usernameText == null) {
154
			usernameText = new JTextField();
155
			usernameText.setBounds(new java.awt.Rectangle(100,25,200,20));
156
			usernameText.addKeyListener(new java.awt.event.KeyAdapter() {
157
				public void keyTyped(java.awt.event.KeyEvent e) {
158
					IPanelGroup panelGroup = getPanelGroup();
159

  
160
					if (panelGroup == null)
161
						return;
162

  
163
					((WFSParamsPanel)panelGroup).setApplicable(true);
164
				}
165
			});
166
		}
167
		return usernameText;
168
	}
169

  
170
	/**
171
	 * This method initializes passwordText
172
	 *
173
	 * @return javax.swing.JTextField
174
	 */
175
	private JPasswordField getPasswordText() {
176
		if (passwordText == null) {
177
			passwordText = new JPasswordField();
178
			passwordText.setBounds(new java.awt.Rectangle(100,50,200,20));
179
			passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
180
				public void keyTyped(java.awt.event.KeyEvent e) {
181
					IPanelGroup panelGroup = getPanelGroup();
182

  
183
					if (panelGroup == null)
184
						return;
185

  
186
					((WFSParamsPanel)panelGroup).setApplicable(true);
187
				}
188
			});
189
		}
190
		return passwordText;
191
	}
192

  
193
	/**
194
	 * This method initializes jPanel
195
	 *
196
	 * @return javax.swing.JPanel
197
	 */
198
	private JPanel getConnectionParamsPanel() {
199
		if (connectionParamsPanel == null) {
200
			java.awt.GridBagConstraints gridBagConstraints;
201

  
202
			bufferPanel = new JPanel();
203
			bufferLabel = new JLabel();
204
			bufferLabel.setText(PluginServices.getText(this, "max_features"));
205
			bufferPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
206
			bufferPanel.add(bufferLabel);
207
			bufferPanel.add(getBufferText());
208

  
209
			timeOutPanel = new JPanel();
210
			timeoutLabel = new JLabel();
211
			timeoutLabel.setText(PluginServices.getText(this, "timeout"));
212
			timeOutPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
213
			timeOutPanel.add(timeoutLabel);
214
			timeOutPanel.add(getTimeOutText());
215
			timeOutPanel.add(getJLabelMiliSeconds());
216

  
217
			connectionParamsPanel = new JPanel();
218
			connectionParamsPanel.setLayout(new java.awt.GridBagLayout());
219
			connectionParamsPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "conection"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
220

  
221
			gridBagConstraints = new java.awt.GridBagConstraints();
222
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
223
			gridBagConstraints.weightx = 1.0;
224
			connectionParamsPanel.add(bufferPanel, gridBagConstraints);
225

  
226
			gridBagConstraints = new java.awt.GridBagConstraints();
227
			gridBagConstraints.gridx = 0;
228
			gridBagConstraints.gridy = 1;
229
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
230
			gridBagConstraints.weightx = 1.0;
231
			connectionParamsPanel.add(timeOutPanel, gridBagConstraints);		
232
		}
233

  
234
		return connectionParamsPanel;
235
	}
236

  
237
	/**
238
	 * This method initializes jTextField
239
	 *
240
	 * @return javax.swing.JTextField
241
	 */
242
	private JFormattedTextField getBufferText() {
243
		if (bufferText == null) {
244
			bufferText = new JFormattedTextField(NumberFormat.getIntegerInstance());
245
			bufferText.setValue(new Integer(1000));
246
			bufferText.setBounds(new Rectangle(100, 25, 70, 20));
247
			bufferText.setToolTipText(PluginServices.getText(bufferText, "set_Max_Number_Of_Features_Will_Be_Loaded"));
248
			bufferText.addKeyListener(new java.awt.event.KeyAdapter() {
249
				public void keyTyped(java.awt.event.KeyEvent e) {
250
					IPanelGroup panelGroup = getPanelGroup();
251

  
252
					if (panelGroup == null)
253
						return;
254

  
255
					((WFSParamsPanel)panelGroup).setApplicable(true);
256
				}
257
			});
258
		}
259

  
260
		return bufferText;
261
	}
262

  
263
	/**
264
	 * This method initializes jTextField1
265
	 *
266
	 * @return javax.swing.JTextField
267
	 */
268
	private JFormattedTextField getTimeOutText() {
269
		if (timeOutText == null) {
270
			timeOutText = new JFormattedTextField(NumberFormat.getIntegerInstance());
271
			timeOutText.setValue(new Integer(10000));
272
			timeOutText.setBounds(new Rectangle(100, 50, 70, 20));
273
			timeOutText.setToolTipText(PluginServices.getText(timeOutText, "set_TimeOut_Explanation"));
274
			timeOutText.addKeyListener(new java.awt.event.KeyAdapter() {
275
				public void keyTyped(java.awt.event.KeyEvent e) {
276
					IPanelGroup panelGroup = getPanelGroup();
277

  
278
					if (panelGroup == null)
279
						return;
280

  
281
					((WFSParamsPanel)panelGroup).setApplicable(true);
282
				}
283
			});
284
		}
285

  
286
		return timeOutText;
287
	}
288

  
289
	/**
290
	 * Gets the name of the user.
291
	 * 
292
	 * @return name of the user
293
	 */
294
	public String getUserName(){
295
		return getUsernameText().getText();
296
	}
297
	
298
	public void setUserName(String userName){
299
	    getUsernameText().setText(userName);	      
300
	}
301

  
302
	/**
303
	 * Gets the password of the user.
304
	 * 
305
	 * @return password of the user
306
	 */
307
	public String getPassword(){
308
		return getPasswordText().getText();
309
	}
310
	
311
	public void setPassword(String password){	    
312
	    getPasswordText().setText(password);
313
	}
314

  
315
	/**
316
	 * Gets the maximum number of values that can load.
317
	 *
318
	 * @return the maximum number of values that can load
319
	 */
320
	public int getBuffer(){
321
		try {
322
			String buffer = StringUtilities.replace(getBufferText().getText(),".","");
323
			buffer = StringUtilities.replace(buffer,",","");
324
			return Integer.parseInt(buffer);
325
		} catch (NumberFormatException e) {
326
			return 10000;
327
		}
328
	}
329
	
330
	public void setBuffer(int buffer){
331
	    getBufferText().setText(String.valueOf(buffer));
332
	}
333

  
334
	/**
335
	 * Gets the timeout used during the loading process.
336
	 *
337
	 * @return the timeout used during the loading process
338
	 */
339
	public int getTimeout(){
340
		try {
341
			String timeOut = StringUtilities.replace(getTimeOutText().getText(),".","");
342
			timeOut = StringUtilities.replace(timeOut,",","");
343
			return Integer.parseInt(timeOut);
344
		} catch (NumberFormatException e) {
345
			return 10000;
346
		}
347
	}
348
	
349
	public void setTimeOut(int timeOut){
350
	      getTimeOutText().setText(String.valueOf(timeOut));	       
351
	}
352

  
353
	/**
354
	 * Gets the reference system of the layer.
355
	 *
356
	 * @return the reference system of the layer
357
	 */
358
	public String getSRS(){
359
		return getSrsText().getText();
360
	}
361
	
362
	public void setSRS(String srs){
363
	    getSrsText().setText(srs);
364
	}
365

  
366
	/**
367
	 * This method initializes formatPanel
368
	 *
369
	 * @return javax.swing.JPanel
370
	 */
371
	private JPanel getFormatPanel() {
372
		if (formatPanel == null) {
373
			formatPanel = new JPanel();
374
			formatPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
375
			formatPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "srs"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
376
			formatPanel.add(getSRSLabel());
377
			formatPanel.add(getSrsText());
378
		}
379
		return formatPanel;
380
	}
381
	
382
	/**
383
	 * This method initializes srsLabel
384
	 *
385
	 * @return javax.swing.JLabel
386
	 */
387
	private JLabel getSRSLabel() {
388
		if (srsLabel == null) {
389
			srsLabel = new JLabel();
390
			srsLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
391
			srsLabel.setText(PluginServices.getText(this, "srs"));
392
			srsLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
393
			srsLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
394
			srsLabel.setBounds(new java.awt.Rectangle(10, 25, 85, 16));
395
		}
396

  
397
		return srsLabel;
398
	}
399

  
400
	/**
401
	 * This method initializes srsText
402
	 *
403
	 * @return javax.swing.JTextField
404
	 */
405
	private JTextField getSrsText() {
406
		if (srsText == null) {
407
			srsText = new JTextField();
408
			srsText.setBounds(new java.awt.Rectangle(98, 25, 100, 20));
409
			srsText.setEnabled(false);
410
			srsText.setEditable(false);
411
			srsText.setToolTipText(PluginServices.getText(srsText, "select_Feature_Reference_System"));
412
		}
413
		return srsText;
414
	}
415

  
416
	/**
417
	 * Refresh the panel
418
	 * 
419
	 * @param feature
420
	 */
421
	public void refresh(WFSSelectedFeature layer) {
422
		Vector srs = layer.getSrs();
423

  
424
		if (srs.size() > 0) {
425
			getSrsText().setText((String)srs.get(0));
426
		}
427
	}
428

  
429
	/**
430
	 * This method initializes jLabelMiliSeconds
431
	 *
432
	 * @return javax.swing.JLabel
433
	 */
434
	public JLabel getJLabelMiliSeconds() {
435
		if (jLabelMiliSeconds == null) {
436
			jLabelMiliSeconds = new JLabel();
437
			jLabelMiliSeconds.setText(PluginServices.getText(jLabelMiliSeconds, "miliSeconds"));
438
			jLabelMiliSeconds.setBounds(new Rectangle(175, 50, 40, 16));
439
		}
440

  
441
		return jLabelMiliSeconds;
442
	}
443
	
444
	private JPanel getCachePanel() {
445
		if (cachePanel == null) {
446
			cachePanel = new JPanel();
447
			cachePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
448
			cachePanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "vectorial_cache"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
449
			cachePanel.add(getEnableCacheCheckBox());			
450
		}
451
		return formatPanel;
452
	}
453
	
454
	public JLabel getEnableCacheCheckBox() {
455
		if (enableCacheCheckBox == null) {
456
			enableCacheCheckBox = new JCheckBox();
457
			enableCacheCheckBox.setText(PluginServices.getText(null, "enable_cache"));
458
			enableCacheCheckBox.setBounds(new Rectangle(175, 50, 40, 16));
459
		}
460

  
461
		return jLabelMiliSeconds;
462
	}
463

  
464
	/*
465
	 * (non-Javadoc)
466
	 * @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#initialize()
467
	 */
468
	protected void initialize() {
469
		setLabel(PluginServices.getText(this, "options"));
470
		setLabelGroup(PluginServices.getText(this, "wfs"));		
471
		this.setLayout(new java.awt.BorderLayout());
472
		java.awt.GridBagConstraints gridBagConstraints;
473

  
474
		northPanel = new JPanel();
475
		northPanel.setLayout(new java.awt.GridBagLayout());
476
		
477
		gridBagConstraints = new java.awt.GridBagConstraints();
478
		gridBagConstraints.gridx = 0;
479
		gridBagConstraints.gridy = 0;
480
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
481
		gridBagConstraints.weightx = 1.0;	
482
		northPanel.add(getConnectionParamsPanel(), gridBagConstraints);
483

  
484
		gridBagConstraints = new java.awt.GridBagConstraints();
485
		gridBagConstraints.gridx = 0;
486
		gridBagConstraints.gridy = 1;
487
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
488
		gridBagConstraints.weightx = 1.0;
489
		northPanel.add(getFormatPanel(), gridBagConstraints);
490
		
491
		gridBagConstraints = new java.awt.GridBagConstraints();
492
		gridBagConstraints.gridx = 0;
493
		gridBagConstraints.gridy = 2;
494
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
495
		gridBagConstraints.weightx = 1.0;
496
		northPanel.add(getCachePanel(), gridBagConstraints);
497
		
498
		add(northPanel, java.awt.BorderLayout.NORTH);
499
	}
500
}
0 501

  
tags/v2_0_0_Build_2051/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSSelectFeaturePanel.java
1
package org.gvsig.wfs.gui.panels;
2

  
3
import java.awt.Color;
4
import java.awt.Component;
5
import java.awt.Graphics;
6
import java.awt.Point;
7
import java.awt.Rectangle;
8
import java.awt.event.MouseAdapter;
9
import java.awt.event.MouseEvent;
10
import java.text.Collator;
11
import java.util.Collections;
12
import java.util.Locale;
13
import java.util.Vector;
14

  
15
import javax.swing.DefaultListSelectionModel;
16
import javax.swing.JCheckBox;
17
import javax.swing.JComponent;
18
import javax.swing.JLabel;
19
import javax.swing.JPanel;
20
import javax.swing.JScrollPane;
21
import javax.swing.JTable;
22
import javax.swing.JTextField;
23
import javax.swing.ListSelectionModel;
24
import javax.swing.UIManager;
25
import javax.swing.event.DocumentEvent;
26
import javax.swing.event.DocumentListener;
27
import javax.swing.event.ListSelectionListener;
28
import javax.swing.plaf.basic.BasicTableHeaderUI;
29
import javax.swing.table.AbstractTableModel;
30
import javax.swing.table.DefaultTableCellRenderer;
31
import javax.swing.table.TableCellRenderer;
32
import javax.swing.table.TableColumn;
33
import javax.swing.table.TableColumnModel;
34
import javax.swing.table.TableModel;
35

  
36
import org.gvsig.andami.PluginServices;
37
import org.gvsig.andami.messages.NotificationManager;
38
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
39
import org.gvsig.remoteclient.wfs.WFSFeatureField;
40
import org.gvsig.utils.StringComparator;
41
import org.gvsig.wfs.gui.panels.WFSSelectFeaturePanel.LayerTable.LayerTableModel;
42
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
43
import org.gvsig.wfs.gui.wizards.WFSWizard;
44

  
45

  
46
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
47
 *
48
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
49
 *
50
 * This program is free software; you can redistribute it and/or
51
 * modify it under the terms of the GNU General Public License
52
 * as published by the Free Software Foundation; either version 2
53
 * of the License, or (at your option) any later version.
54
 *
55
 * This program is distributed in the hope that it will be useful,
56
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
58
 * GNU General Public License for more details.
59
 *
60
 * You should have received a copy of the GNU General Public License
61
 * along with this program; if not, write to the Free Software
62
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
63
 *
64
 * For more information, contact:
65
 *
66
 *  Generalitat Valenciana
67
 *   Conselleria d'Infraestructures i Transport
68
 *   Av. Blasco Ib??ez, 50
69
 *   46010 VALENCIA
70
 *   SPAIN
71
 *
72
 *      +34 963862235
73
 *   gvsig@gva.es
74
 *      www.gvsig.gva.es
75
 *
76
 *    or
77
 *
78
 *   IVER T.I. S.A
79
 *   Salamanca 50
80
 *   46005 Valencia
81
 *   Spain
82
 *
83
 *   +34 963163400
84
 *   dac@iver.es
85
 */
86
/* CVS MESSAGES:
87
 *
88
 * $Id: WFSSelectFeaturePanel.java 18799 2008-02-12 16:53:03Z vcaballero $
89
 * $Log$
90
 * Revision 1.19  2007-09-19 16:14:50  jaume
91
 * removed unnecessary imports
92
 *
93
 * Revision 1.18  2007/03/15 13:34:16  ppiqueras
94
 * Eliminado mensaje de aviso no necesario.
95
 *
96
 * Revision 1.17  2007/03/05 13:49:42  ppiqueras
97
 * 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.
98
 *
99
 * Revision 1.16  2007/02/22 12:25:09  ppiqueras
100
 * A?adidas tool tip text.
101
 *
102
 * Revision 1.15  2007/02/09 14:12:39  jorpiell
103
 * Soporte para WFS 1.1 y WFS-T
104
 *
105
 * Revision 1.14  2007/02/07 13:26:23  ppiqueras
106
 * Corregido bug: al seleccionar una feature, pero sin cerrar el di?logo, se retrocede y se conecta a otro servidor,  se manten?a la posici?n seleccionada en la tabla de features. Se ha solucionado haciendo que se quede deseleccionada toda la tabla de features.
107
 *
108
 * Revision 1.13  2007/01/23 13:12:43  ppiqueras
109
 * Corregido un peque?o bug: el ?rea de texto del nombre de la feature no debe ser editable, dado que si se edita no procesa el texto escrito.
110
 *
111
 * Revision 1.12  2007/01/15 14:16:22  ppiqueras
112
 * Corregido bug: no cargaba los campos al principio y además se ejecutaba más de una vez.
113
 *
114
 * Revision 1.11  2006/12/15 13:57:34  ppiqueras
115
 * eliminado un import que sobraba
116
 *
117
 * Revision 1.10  2006/12/12 10:24:45  ppiqueras
118
 * 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'.
119
 *
120
 * Revision 1.9  2006/12/04 08:59:47  ppiqueras
121
 * Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todavía no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
122
 *
123
 * Revision 1.8  2006/10/27 06:44:56  jorpiell
124
 * Se han cambiado algunas etiquetas de texto que sal?an recortadas
125
 *
126
 * Revision 1.7  2006/07/21 11:50:31  jaume
127
 * improved appearance
128
 *
129
 * Revision 1.6  2006/06/21 12:35:45  jorpiell
130
 * 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
131
 *
132
 * Revision 1.5  2006/05/25 10:31:06  jorpiell
133
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
134
 *
135
 * Revision 1.4  2006/05/23 08:09:39  jorpiell
136
 * 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
137
 *
138
 * Revision 1.3  2006/05/19 12:57:08  jorpiell
139
 * Modificados algunos paneles
140
 *
141
 * Revision 1.2  2006/04/20 16:38:24  jorpiell
142
 * 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().
143
 *
144
 *
145
 */
146

  
147

  
148
/**
149
 * <p>Panel where user can select a feature type to load as a WFS layer.</p>
150
 * 
151
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
152
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
153
 */
154
public class WFSSelectFeaturePanel extends AbstractWFSPanel {
155
	private static final long serialVersionUID = -3781080396069038450L;
156
	private JPanel featureListPanel = null;
157
	private JScrollPane jScrollPane = null;
158
	private LayerTable lstFeatures = null;
159
	private JTextField txtName = null;
160
	private JCheckBox chkExtendedNames = null;
161
	private JPanel layerNamePanel = null;
162
	private WFSSelectedFeature layerNode = null;
163
	private ListSelectionListener listSelectionListener = null;
164

  
165
	/**
166
	 * Creates a new WFS select feature panel.
167
	 */
168
	public WFSSelectFeaturePanel() {
169
		super();
170
		initialize();
171
	}
172

  
173
	/**
174
	 * This method initializes coveragesListPanel
175
	 *
176
	 * @return javax.swing.JPanel
177
	 */
178
	private JPanel getFeaturesListPanel() {
179
		if (featureListPanel == null) {
180
			java.awt.GridBagConstraints gridBagConstraints;
181
			featureListPanel = new JPanel();
182
			featureListPanel.setLayout(new java.awt.GridBagLayout());
183
			featureListPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
184
					null, PluginServices.getText(this, "select_features"),
185
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
186
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
187

  
188
			gridBagConstraints = new java.awt.GridBagConstraints();
189
			gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
190
			gridBagConstraints.weightx = 1.0;
191
			gridBagConstraints.weighty = 1.0;
192
			featureListPanel.add(getJScrollPane(), gridBagConstraints);
193
		}
194

  
195
		return featureListPanel;
196
	}
197

  
198
	/**
199
	 * This method initializes jScrollPane
200
	 *
201
	 * @return javax.swing.JScrollPane
202
	 */
203
	private JScrollPane getJScrollPane() {
204
		if (jScrollPane == null) {
205
			jScrollPane = new JScrollPane();		
206
			jScrollPane.setViewportView(getLstFeatures());
207
			jScrollPane.setToolTipText(PluginServices.getText(jScrollPane, "feature_Selection_Info"));
208
		}
209

  
210
		return jScrollPane;
211
	}
212

  
213
	/**
214
	 * This method initializes lstFeatures
215
	 *
216
	 * @return javax.swing.LayerTable
217
	 */
218
	public LayerTable getLstFeatures() {
219
		if (lstFeatures == null) {
220
			lstFeatures = new LayerTable();
221
			lstFeatures.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
222
			lstFeatures.getSelectionModel().addListSelectionListener(getListSelectionListener());
223
			lstFeatures.setToolTipText(PluginServices.getText(lstFeatures, "feature_Selection_Info"));
224

  
225
			// Double-click -> click the 'Next' button
226
			lstFeatures.addMouseListener(new MouseAdapter() {
227
				/*
228
				 *  (non-Javadoc)
229
				 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
230
				 */
231
				public void mouseClicked(MouseEvent e) {
232
					if (e.getClickCount() == 2) {
233
						Object obj = getPanelGroup();
234

  
235
						if ((obj != null) && (obj instanceof WFSParamsPanel))
236
							((WFSParamsPanel)obj).doClickOnNextButton();
237
					}
238
				}			
239
			});
240
		}
241

  
242
		return lstFeatures;
243
	}
244
	
245
    public int getSelectedFeaturesCount() {
246

  
247
        if (lstFeatures == null) {
248
            return 0;
249
        }
250
        
251
        ListSelectionModel m = lstFeatures.getSelectionModel();
252
        if (m == null || m.isSelectionEmpty()) {
253
            return 0;
254
        } else {
255
            int resp = 0;
256
            for (int i = m.getMinSelectionIndex();
257
                i <= m.getMaxSelectionIndex();
258
                i++) {
259

  
260
                if (m.isSelectedIndex(i)) {
261
                    resp++;
262
                }
263
            }
264
            return resp;
265
        }
266

  
267
    }
268

  
269
	/**
270
	 * Creates the list selection listener for the layers list
271
	 * 
272
	 * @return the listener
273
	 */
274
	private ListSelectionListener getListSelectionListener(){
275
		if (listSelectionListener == null){
276
			listSelectionListener = new ListSelectionListener(){
277
				public void valueChanged(javax.swing.event.ListSelectionEvent e) {
278
					DefaultListSelectionModel model = (DefaultListSelectionModel) e.getSource();
279
					LayerTableModel t_model = ((LayerTableModel)lstFeatures.getModel());
280
					if (t_model.isUpdatingSelection())
281
						return;
282

  
283
					// With this condition we force to execute the updating only when a row has been selected by the user
284
					if ((model.getMinSelectionIndex() > -1) && (e.getValueIsAdjusting() == false)) {
285
						// Indicate that now we are loading a new layer
286
						IPanelGroup panelGroup = getPanelGroup();
287

  
288
						if (panelGroup == null)
289
							return;
290

  
291
						if (((WFSParamsPanel)panelGroup).getFilterPanel() == null)
292
							return;
293
			
294
						refreshData();
295
					}
296
					
297
                    // =============================================
298
                    // If zero selected, settings are invalid
299
					int n_sel = getSelectedFeaturesCount();
300
					if (n_sel == 0) {
301
	                       Object obj = getPanelGroup();
302
	                       if (obj != null && obj instanceof WFSParamsPanel) {
303
	                           obj = ((WFSParamsPanel) obj).getParent();
304
	                           if (obj instanceof WFSWizard) {
305
	                               ((WFSWizard) obj).callStateChanged(false); 
306
	                           }
307
	                       }
308
					}
309
					// =============================================
310
				}
311
			};	
312
		}
313

  
314
		return listSelectionListener;
315
	}
316

  
317
	/**
318
	 * This method initializes jTextField
319
	 *
320
	 * @return javax.swing.JTextField
321
	 */
322
	public JTextField getTxtName() {
323
		if (txtName == null) {
324
			txtName = new JTextField();
325
			txtName.setBounds(6, 19, 472, 20);
326
			txtName.setText(PluginServices.getText(this, "WFSLayer"));
327
			txtName.setEditable(false);
328
			txtName.setBackground(Color.WHITE);
329
			txtName.setToolTipText(PluginServices.getText(txtName, "feature_to_load"));
330

  
331
			txtName.getDocument().addDocumentListener(new DocumentListener() {
332
				/*
333
				 * (non-Javadoc)
334
				 * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
335
				 */
336
				public void changedUpdate(DocumentEvent e) {
337
				}
338

  
339
				/*
340
				 * (non-Javadoc)
341
				 * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
342
				 */
343
				public void insertUpdate(DocumentEvent e) {
344
					IPanelGroup panelGroup = getPanelGroup();
345

  
346
					if (panelGroup == null)
347
						return;
348

  
349
					((WFSParamsPanel)panelGroup).setApplicable(true);
350
				}
351

  
352
				/*
353
				 * (non-Javadoc)
354
				 * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
355
				 */
356
				public void removeUpdate(DocumentEvent e) {
357
				}
358
			});
359
		}
360

  
361
		return txtName;
362
	}
363

  
364
	/**
365
	 * This method initializes chkExtendedNames
366
	 *
367
	 * @return javax.swing.JCheckBox
368
	 */
369
	private JCheckBox getChkExtendedNames() {
370
		if (chkExtendedNames == null) {
371
			chkExtendedNames = new JCheckBox();
372
			chkExtendedNames.setText(PluginServices.getText(this, "show_layer_names"));
373
			chkExtendedNames.setBounds(10, 372, 382, 20);
374
			chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
375
				/*
376
				 * (non-Javadoc)
377
				 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
378
				 */
379
				public void itemStateChanged(java.awt.event.ItemEvent e) {
380
					boolean b = chkExtendedNames.isSelected();
381
					getLstFeatures().setShowLayerNames(b);
382
					getLstFeatures().repaint();
383
				}
384
			});
385
		}
386

  
387
		return chkExtendedNames;
388
	}
389

  
390
	/**
391
	 * Set the selected layer node
392
	 * 
393
	 * @param layerNode the layer to select
394
	 */
395
	public void setSelectedFeature(WFSSelectedFeature layerNode){
396
		int index = -1;
397

  
398
		for (int i=0; i<getLstFeatures().getRowCount(); i++){
399
			WFSSelectedFeature node = (WFSSelectedFeature)getLstFeatures().getValueAt(i);
400

  
401
			if (node != null && layerNode.getName().equals(node.getName())){
402
				index = i;
403
			}
404
		}
405

  
406
		if (index != -1){
407
			getLstFeatures().changeSelection(index, 0, false, false);
408
		}
409
	}
410

  
411
	/**
412
	 * Refresh the features list
413
	 */
414
	public void refresh(WFSSelectedFeature layer) {
415
		// Unselects all features
416
		unselectAllFeatures();
417

  
418
		// Add the new features
419
		getLstFeatures().addFeatures(getSelectedFeatureManager().getLayerList());
420

  
421
		if (layer != null) {
422
			layerNode = layer;
423
			setLayerName(layer.getName());
424
			setSelectedFeature(layer);			
425
		}		
426
	}
427

  
428
	/**
429
	 * Refreshes the wizard components data each time a feature
430
	 * is selected. The <i>describeFeatureType</i> operation must be sent.
431
	 */
432
	public void refreshData() {
433
		WFSSelectedFeature lyr = (WFSSelectedFeature)getLstFeatures().getSelectedValue();
434

  
435
		try {
436
			getTxtName().setText(lyr.getTitle());
437
		} catch (NullPointerException e){
438
			getTxtName().setText(PluginServices.getText(this,"default_name"));
439
			NotificationManager.addError(PluginServices.getText(this,"default_name"), e);
440
		}
441

  
442
		IPanelGroup panelGroup = getPanelGroup();
443

  
444
		if (panelGroup == null)
445
			return;
446

  
447
		((WFSParamsPanel)panelGroup).refresh(lyr);
448

  
449
		repaint();
450
	}
451

  
452
	/**
453
	 * This method initializes layerNamePanel
454
	 *
455
	 * @return javax.swing.JPanel
456
	 */
457
	private JPanel getLayerNamePanel() {
458
		if (layerNamePanel == null) {
459
			java.awt.GridBagConstraints gridBagConstraints;
460
			layerNamePanel = new JPanel();
461
			layerNamePanel.setLayout(new java.awt.GridBagLayout());
462
			layerNamePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
463
					null, PluginServices.getText(this, "layer_name"),
464
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
465
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));			
466
			gridBagConstraints = new java.awt.GridBagConstraints();
467
			gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
468
			gridBagConstraints.weightx = 1.0;
469
			layerNamePanel.add(getTxtName(), gridBagConstraints);
470
		}
471

  
472
		return layerNamePanel;
473
	}
474

  
475
	/**
476
	 * Gets the name of the layer (feature) selected.
477
	 *
478
	 * @return the layer name
479
	 */
480
	public String getLayerName() {
481
		if ((WFSSelectedFeature)getLstFeatures().getSelectedValue() != null){
482
			return ((WFSSelectedFeature)getLstFeatures().getSelectedValue()).getName();
483
		}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff