root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSParamsPanel.java @ 6501
History | View | Annotate | Download (13.3 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.event.FocusEvent; |
4 |
import java.awt.event.FocusListener; |
5 |
import java.util.prefs.Preferences; |
6 |
|
7 |
import javax.swing.JTabbedPane; |
8 |
|
9 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
10 |
|
11 |
import com.iver.andami.PluginServices; |
12 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
13 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
14 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFS; |
15 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
16 |
import com.iver.cit.gvsig.gui.WizardPanel; |
17 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
18 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
19 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
20 |
|
21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
22 |
*
|
23 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
24 |
*
|
25 |
* This program is free software; you can redistribute it and/or
|
26 |
* modify it under the terms of the GNU General Public License
|
27 |
* as published by the Free Software Foundation; either version 2
|
28 |
* of the License, or (at your option) any later version.
|
29 |
*
|
30 |
* This program is distributed in the hope that it will be useful,
|
31 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
32 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
33 |
* GNU General Public License for more details.
|
34 |
*
|
35 |
* You should have received a copy of the GNU General Public License
|
36 |
* along with this program; if not, write to the Free Software
|
37 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
38 |
*
|
39 |
* For more information, contact:
|
40 |
*
|
41 |
* Generalitat Valenciana
|
42 |
* Conselleria d'Infraestructures i Transport
|
43 |
* Av. Blasco Ib??ez, 50
|
44 |
* 46010 VALENCIA
|
45 |
* SPAIN
|
46 |
*
|
47 |
* +34 963862235
|
48 |
* gvsig@gva.es
|
49 |
* www.gvsig.gva.es
|
50 |
*
|
51 |
* or
|
52 |
*
|
53 |
* IVER T.I. S.A
|
54 |
* Salamanca 50
|
55 |
* 46005 Valencia
|
56 |
* Spain
|
57 |
*
|
58 |
* +34 963163400
|
59 |
* dac@iver.es
|
60 |
*/
|
61 |
/* CVS MESSAGES:
|
62 |
*
|
63 |
* $Id: WFSParamsPanel.java 6501 2006-07-21 11:51:55Z jaume $
|
64 |
* $Log$
|
65 |
* Revision 1.10 2006-07-21 11:50:31 jaume
|
66 |
* improved appearance
|
67 |
*
|
68 |
* Revision 1.9 2006/06/21 12:35:45 jorpiell
|
69 |
* 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
|
70 |
*
|
71 |
* Revision 1.8 2006/06/15 07:50:58 jorpiell
|
72 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
|
73 |
*
|
74 |
* Revision 1.7 2006/05/25 16:22:47 jorpiell
|
75 |
* Se limpia el panel cada vez que se conecta con un servidor distinto
|
76 |
*
|
77 |
* Revision 1.6 2006/05/25 16:01:43 jorpiell
|
78 |
* Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
|
79 |
*
|
80 |
* Revision 1.5 2006/05/25 10:31:06 jorpiell
|
81 |
* Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
|
82 |
*
|
83 |
* Revision 1.4 2006/05/23 08:09:39 jorpiell
|
84 |
* 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
|
85 |
*
|
86 |
* Revision 1.3 2006/05/19 12:57:08 jorpiell
|
87 |
* Modificados algunos paneles
|
88 |
*
|
89 |
* Revision 1.2 2006/04/20 16:38:24 jorpiell
|
90 |
* 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().
|
91 |
*
|
92 |
* Revision 1.1 2006/04/19 12:50:16 jorpiell
|
93 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
|
94 |
*
|
95 |
*
|
96 |
*/
|
97 |
/**
|
98 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
99 |
*/
|
100 |
public class WFSParamsPanel extends WizardPanel{ |
101 |
private JTabbedPane jTabbedPane = null; // @jve:decl-index=0:visual-constraint="37,30" |
102 |
private WFSSelectFeaturePanel featurePanel = null; |
103 |
private WFSSelectAttributesPanel fieldsPanel = null; |
104 |
private WFSOptionsPanel optionsPanel = null; |
105 |
private WFSFormatPanel formatPanel = null; |
106 |
private WFSWizardData data;
|
107 |
private WizardListenerSupport listenerSupport;
|
108 |
public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
109 |
private WFSInfoPanel infoPanel;
|
110 |
private int indFields; |
111 |
private int indFormat; |
112 |
|
113 |
/**
|
114 |
* This method initializes jTabbedPane
|
115 |
*
|
116 |
* @return javax.swing.JTabbedPane
|
117 |
*/
|
118 |
|
119 |
public WFSParamsPanel(){
|
120 |
super();
|
121 |
initialize(); |
122 |
} |
123 |
/**
|
124 |
* Returns the tab amount that the WFSParamsPanel currently have
|
125 |
*
|
126 |
* Devuelve el n?mero de solapas que tiene actualmente el WFSParamsPanel
|
127 |
*
|
128 |
* @return int
|
129 |
*/
|
130 |
public int getNumTabs(){ |
131 |
return getJTabbedPane().getTabCount();
|
132 |
} |
133 |
|
134 |
private void initialize() { |
135 |
this.setLayout(null); |
136 |
this.setVisible(false); |
137 |
this.setBounds(0, 0, 510, 427); |
138 |
this.add(getJTabbedPane(), null); |
139 |
} |
140 |
|
141 |
/**
|
142 |
* Sets the focus to the tab next to the current one.
|
143 |
*
|
144 |
* Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
|
145 |
*
|
146 |
*/
|
147 |
public void avanzaTab(){ |
148 |
int currentPage = currentPage();
|
149 |
int nPages = getNumTabs();
|
150 |
if (nPages -1 > currentPage){ |
151 |
getJTabbedPane().setSelectedIndex(nextPageEnabled()); |
152 |
} |
153 |
} |
154 |
|
155 |
/**
|
156 |
* Sets the focus to the tab previous to the current one.
|
157 |
*
|
158 |
* Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
|
159 |
*
|
160 |
*/
|
161 |
public void retrocedeTab(){ |
162 |
this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
|
163 |
} |
164 |
|
165 |
/**
|
166 |
* Returns the current tab index.
|
167 |
*
|
168 |
* Devuelve el n?mero de solapa en que se encuentra
|
169 |
*
|
170 |
* @return
|
171 |
*/
|
172 |
public int getIndiceSolapaActual(){ |
173 |
return this.getJTabbedPane().getSelectedIndex(); |
174 |
} |
175 |
|
176 |
public JTabbedPane getJTabbedPane() { |
177 |
if (jTabbedPane == null) { |
178 |
jTabbedPane = new JTabbedPane(); |
179 |
jTabbedPane.setBounds(4, 4, 502, 415); |
180 |
jTabbedPane.addTab(PluginServices.getText(this, "info"), null, getInfoPanel()); |
181 |
jTabbedPane.addTab(PluginServices.getText(this, "feature"), null, getPanelFeatures(), null); |
182 |
jTabbedPane.addTab(PluginServices.getText(this, "attributes"),null, getPanelFields(), null); |
183 |
indFields = jTabbedPane.getTabCount() - 1;
|
184 |
jTabbedPane.setEnabledAt(indFields, false);
|
185 |
//jTabbedPane.addTab(PluginServices.getText(this,"formatos"),null,getFormatPanel(),null);
|
186 |
indFormat = jTabbedPane.getTabCount() - 1;
|
187 |
jTabbedPane.setEnabledAt(indFormat, false);
|
188 |
jTabbedPane.addTab(PluginServices.getText(this, "options"),null, getOptionsPanel(), null); |
189 |
} |
190 |
return jTabbedPane;
|
191 |
} |
192 |
|
193 |
private WFSInfoPanel getInfoPanel() {
|
194 |
if (infoPanel==null) { |
195 |
infoPanel = new WFSInfoPanel();
|
196 |
infoPanel.addFocusListener(new FocusListener() { |
197 |
public void focusGained(java.awt.event.FocusEvent e) { |
198 |
refreshInfo(); |
199 |
} |
200 |
|
201 |
private void refreshInfo() { |
202 |
WFSLayerNode selectedNode = featurePanel.getSelectedFeature(); |
203 |
if (selectedNode != null){ |
204 |
selectedNode.setSelectedFields(fieldsPanel.getSelectedFields()); |
205 |
} |
206 |
data.setUserName(optionsPanel.getUserName()); |
207 |
data.setBuffer(optionsPanel.getBuffer()); |
208 |
data.setTimeOut(optionsPanel.getTimeout()); |
209 |
infoPanel.refresh(data,selectedNode); |
210 |
} |
211 |
|
212 |
public void focusLost(FocusEvent e) { |
213 |
|
214 |
} |
215 |
}); |
216 |
} |
217 |
return infoPanel;
|
218 |
} |
219 |
|
220 |
/**
|
221 |
*
|
222 |
* @return the selected list
|
223 |
*/
|
224 |
private Object getSelectedFeature() { |
225 |
return featurePanel.getSelectedFeature();
|
226 |
} |
227 |
|
228 |
|
229 |
/**
|
230 |
* This method initializes panelFeatures
|
231 |
*
|
232 |
* @return javax.swing.JPanel
|
233 |
*/
|
234 |
private WFSSelectFeaturePanel getPanelFeatures() {
|
235 |
if (featurePanel == null) { |
236 |
featurePanel = new WFSSelectFeaturePanel(this); |
237 |
featurePanel.setLayout(null);
|
238 |
} |
239 |
return featurePanel;
|
240 |
} |
241 |
|
242 |
/**
|
243 |
* This method initializes fieldsPanel
|
244 |
*
|
245 |
* @return javax.swing.JPanel
|
246 |
*/
|
247 |
private WFSSelectAttributesPanel getPanelFields(){
|
248 |
if (fieldsPanel == null) { |
249 |
fieldsPanel = new WFSSelectAttributesPanel(this); |
250 |
fieldsPanel.setLayout(null);
|
251 |
} |
252 |
return fieldsPanel;
|
253 |
} |
254 |
|
255 |
|
256 |
|
257 |
/**
|
258 |
* This method initializes fieldsPanel
|
259 |
*
|
260 |
* @return javax.swing.JPanel
|
261 |
*/
|
262 |
private WFSOptionsPanel getOptionsPanel(){
|
263 |
if (optionsPanel == null) { |
264 |
optionsPanel = new WFSOptionsPanel(this); |
265 |
optionsPanel.setLayout(null);
|
266 |
} |
267 |
return optionsPanel;
|
268 |
} |
269 |
|
270 |
|
271 |
/**
|
272 |
* This method initializes formatPanel
|
273 |
*
|
274 |
* @return javax.swing.JPanel
|
275 |
*/
|
276 |
private WFSFormatPanel getFormatPanel(){
|
277 |
if (formatPanel == null) { |
278 |
formatPanel = new WFSFormatPanel();
|
279 |
formatPanel.setLayout(null);
|
280 |
} |
281 |
return formatPanel;
|
282 |
} |
283 |
|
284 |
/**
|
285 |
* Verifies that the selected parameters are enough to request the coverage
|
286 |
* to the server.
|
287 |
*
|
288 |
* Comprueba que los par?metros seleccionados son suficientes para pedir la
|
289 |
* cobertura al servidor.
|
290 |
*
|
291 |
* @return boolean
|
292 |
*/
|
293 |
public boolean isCorretlyConfigured() { |
294 |
if (featurePanel.getSelectedFeature()!= null){ |
295 |
return true; |
296 |
}else{
|
297 |
return false; |
298 |
} |
299 |
} |
300 |
|
301 |
/**
|
302 |
* Cleans up the wizard's components but the server's layers list.
|
303 |
*
|
304 |
* Limpia todos los componentes del wizard excepto la lista de capas del
|
305 |
* servidor.
|
306 |
*/
|
307 |
public void cleanupWizard() { |
308 |
jTabbedPane.setEnabledAt(indFields,false);
|
309 |
// jTabbedPane.setEnabledAt(indFormat,false);
|
310 |
} |
311 |
|
312 |
/**
|
313 |
* Refreshes the wizard components data each time a feature
|
314 |
* is selected.
|
315 |
*
|
316 |
* Actualiza los datos de los componentes del wizard cada vez
|
317 |
* que se selecciona una feature diferente.
|
318 |
*
|
319 |
* @param feature
|
320 |
* Selected feature
|
321 |
*/
|
322 |
public void refreshData(WFSLayerNode feature){ |
323 |
if (feature != null){ |
324 |
feature = (WFSLayerNode)data.getFeatureInfo(feature.getName()); |
325 |
fieldsPanel.refresh(feature); |
326 |
jTabbedPane.setEnabledAt(indFields,true);
|
327 |
// formatPanel.refresh(feature);
|
328 |
// jTabbedPane.setEnabledAt(indFormat,true);
|
329 |
optionsPanel.refresh(feature); |
330 |
} |
331 |
listenerSupport.callStateChanged(isCorretlyConfigured()); |
332 |
|
333 |
} |
334 |
|
335 |
public void refreshInfo(WFSLayerNode feature){ |
336 |
infoPanel.refresh(data,feature); |
337 |
} |
338 |
|
339 |
/**
|
340 |
* Sets the object that holds the wizard data.
|
341 |
*
|
342 |
* Establece el objeto que contiene los datos del wizard.
|
343 |
*
|
344 |
* @param data
|
345 |
*/
|
346 |
public void setWizardData(WFSWizardData data) { |
347 |
this.data = data;
|
348 |
//WFSLayerNode selectedNode = (WFSLayerNode)featurePanel.getSelectedFeature();
|
349 |
featurePanel.setWizardData(data); |
350 |
data.setBuffer(optionsPanel.getBuffer()); |
351 |
data.setTimeOut(optionsPanel.getTimeout()); |
352 |
infoPanel.refresh(data,null);
|
353 |
} |
354 |
|
355 |
/**
|
356 |
* Sets the wizard's data source
|
357 |
*
|
358 |
* Establece el origen de los datos del wizard
|
359 |
* @param dataSource
|
360 |
*/
|
361 |
public void setDataSource(WFSWizardData dataSource) { |
362 |
this.data = dataSource;
|
363 |
|
364 |
} |
365 |
|
366 |
|
367 |
/**
|
368 |
* Returns the next enabled tab's index.
|
369 |
*
|
370 |
* Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay
|
371 |
* ninguna.
|
372 |
*
|
373 |
* @return The index or -1 if there is no one.
|
374 |
*/
|
375 |
public int nextPageEnabled() { |
376 |
int currentPage = currentPage();
|
377 |
int nPages = getNumTabs();
|
378 |
if (currentPage == nPages)
|
379 |
return -1; |
380 |
for (int i=currentPage+1; i<nPages; i++){ |
381 |
if (getJTabbedPane().isEnabledAt(i)){
|
382 |
return i;
|
383 |
} |
384 |
} |
385 |
return -1; |
386 |
} |
387 |
|
388 |
/**
|
389 |
* Returns the index of the current tab.
|
390 |
*
|
391 |
* Devuelve el ?ndice de la p?gina actual del wizard.
|
392 |
*
|
393 |
* @return
|
394 |
*/
|
395 |
public int currentPage() { |
396 |
return getJTabbedPane().getSelectedIndex();
|
397 |
} |
398 |
|
399 |
/**
|
400 |
* Returns the index of the previous enabled tab.
|
401 |
*
|
402 |
* Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
|
403 |
* ninguna.
|
404 |
*
|
405 |
* @return The index, or -1 if there is no one.
|
406 |
*/
|
407 |
public int previousEnabledPage() { |
408 |
int currentPage = currentPage();
|
409 |
int j=0; |
410 |
if (currentPage == 0) |
411 |
j= -1;
|
412 |
for (int i = currentPage-1; i>-1; i--){ |
413 |
if (getJTabbedPane().isEnabledAt(i)){
|
414 |
j= i; |
415 |
break;
|
416 |
} |
417 |
} |
418 |
return j;
|
419 |
} |
420 |
|
421 |
public FMapWFSDriver getDriver() {
|
422 |
return data.getDriver();
|
423 |
} |
424 |
|
425 |
public void setListenerSupport(WizardListenerSupport support) { |
426 |
listenerSupport = support; |
427 |
} |
428 |
|
429 |
|
430 |
/*
|
431 |
* (non-Javadoc)
|
432 |
* @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
|
433 |
*/
|
434 |
public void initWizard() { |
435 |
|
436 |
} |
437 |
|
438 |
/*
|
439 |
* (non-Javadoc)
|
440 |
* @see com.iver.cit.gvsig.gui.WizardPanel#execute()
|
441 |
*/
|
442 |
public void execute() { |
443 |
|
444 |
} |
445 |
|
446 |
/*
|
447 |
* (non-Javadoc)
|
448 |
* @see com.iver.cit.gvsig.gui.ILayerPanel#getLayer()
|
449 |
*/
|
450 |
public FLayer getLayer() {
|
451 |
FLyrWFS layer = new FLyrWFS();
|
452 |
layer.setName(getPanelFeatures().getLayerText()); |
453 |
layer.setLayerName(getPanelFeatures().getLayerName()); |
454 |
layer.setWfsLayerNode(getLayerNode()); |
455 |
layer.setFields(getPanelFields().getSelectedFields()); |
456 |
layer.setUserName(getOptionsPanel().getUserName()); |
457 |
layer.setPassword(getOptionsPanel().getPassword()); |
458 |
layer.setNumfeatures(getOptionsPanel().getBuffer()); |
459 |
layer.setTimeout(getOptionsPanel().getTimeout()); |
460 |
layer.setWfsDriver(data.getDriver()); |
461 |
return layer;
|
462 |
} |
463 |
|
464 |
private WFSLayerNode getLayerNode(){
|
465 |
WFSLayerNode layerNode = getPanelFeatures().getWFSLayerNode(); |
466 |
layerNode.setSelectedFields(getPanelFields().getSelectedFields()); |
467 |
return layerNode;
|
468 |
} |
469 |
|
470 |
|
471 |
public void setSelectedFeature(WFSLayerNode layerNode){ |
472 |
getPanelFeatures().setSelectedFeature(layerNode); |
473 |
} |
474 |
public void setselectedAttributes(WFSLayerNode layerNode) { |
475 |
getPanelFields().setSelectedFields(layerNode); |
476 |
} |
477 |
/**
|
478 |
* @return Returns the data.
|
479 |
*/
|
480 |
public WFSWizardData getData() {
|
481 |
return data;
|
482 |
} |
483 |
public void setLayerName(String name) { |
484 |
getPanelFeatures().setLayerName(name); |
485 |
|
486 |
} |
487 |
|
488 |
public void addWizardListener(WizardListener listener) { |
489 |
listenerSupport.addWizardListener(listener); |
490 |
} |
491 |
|
492 |
public void isApplicable(boolean applicable){ |
493 |
listenerSupport.callStateChanged(applicable); |
494 |
} |
495 |
|
496 |
|
497 |
public void setStatus(WFSStatus status) { |
498 |
getOptionsPanel().setStatus(status); |
499 |
} |
500 |
|
501 |
|
502 |
} |