root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSParamsPanel.java @ 4886
History | View | Annotate | Download (10.2 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.JCheckBox; |
8 |
import javax.swing.JLabel; |
9 |
import javax.swing.JPanel; |
10 |
import javax.swing.JScrollPane; |
11 |
import javax.swing.JTabbedPane; |
12 |
import javax.swing.JTextField; |
13 |
|
14 |
import com.iver.andami.PluginServices; |
15 |
import com.iver.cit.gvsig.fmap.drivers.wfs.FMapWFSDriver; |
16 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
17 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
18 |
import com.iver.cit.gvsig.gui.WizardPanel; |
19 |
import com.iver.cit.gvsig.gui.wizards.WFSWizardData; |
20 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
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: WFSParamsPanel.java 4886 2006-04-19 12:50:16Z jorpiell $
|
65 |
* $Log$
|
66 |
* Revision 1.1 2006-04-19 12:50:16 jorpiell
|
67 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
|
68 |
*
|
69 |
*
|
70 |
*/
|
71 |
/**
|
72 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
73 |
*/
|
74 |
public class WFSParamsPanel extends WizardPanel{ |
75 |
|
76 |
private JTabbedPane jTabbedPane = null; // @jve:decl-index=0:visual-constraint="37,30" |
77 |
private WFSSelectFeaturePanel featurePanel = null; |
78 |
private WFSWizardData data;
|
79 |
private WizardListenerSupport listenerSupport;
|
80 |
public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
81 |
private InfoPanel infoPanel;
|
82 |
|
83 |
/**
|
84 |
* This method initializes jTabbedPane
|
85 |
*
|
86 |
* @return javax.swing.JTabbedPane
|
87 |
*/
|
88 |
|
89 |
public WFSParamsPanel(){
|
90 |
super();
|
91 |
initialize(); |
92 |
} |
93 |
/**
|
94 |
* Returns the tab amount that the WFSParamsPanel currently have
|
95 |
*
|
96 |
* Devuelve el n?mero de solapas que tiene actualmente el WFSParamsPanel
|
97 |
*
|
98 |
* @return int
|
99 |
*/
|
100 |
public int getNumTabs(){ |
101 |
return getJTabbedPane().getTabCount();
|
102 |
} |
103 |
|
104 |
private void initialize() { |
105 |
this.setLayout(null); |
106 |
this.setVisible(false); |
107 |
this.setBounds(10, 5, 481, 427); |
108 |
this.add(getJTabbedPane(), null); |
109 |
} |
110 |
|
111 |
/**
|
112 |
* Sets the focus to the tab next to the current one.
|
113 |
*
|
114 |
* Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
|
115 |
*
|
116 |
*/
|
117 |
public void avanzaTab(){ |
118 |
int currentPage = currentPage();
|
119 |
int nPages = getNumTabs();
|
120 |
if (nPages -1 > currentPage){ |
121 |
getJTabbedPane().setSelectedIndex(nextPageEnabled()); |
122 |
} |
123 |
} |
124 |
|
125 |
/**
|
126 |
* Sets the focus to the tab previous to the current one.
|
127 |
*
|
128 |
* Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
|
129 |
*
|
130 |
*/
|
131 |
public void retrocedeTab(){ |
132 |
this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
|
133 |
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* Returns the current tab index.
|
138 |
*
|
139 |
* Devuelve el n?mero de solapa en que se encuentra
|
140 |
*
|
141 |
* @return
|
142 |
*/
|
143 |
public int getIndiceSolapaActual(){ |
144 |
return this.getJTabbedPane().getSelectedIndex(); |
145 |
} |
146 |
|
147 |
private JTabbedPane getJTabbedPane() { |
148 |
if (jTabbedPane == null) { |
149 |
jTabbedPane = new JTabbedPane(); |
150 |
jTabbedPane.setSize(476, 422); |
151 |
jTabbedPane.addTab(PluginServices.getText(this, "info"), null, getInfoPanel()); |
152 |
jTabbedPane.addTab(PluginServices.getText(this, "feature"), null, getPanelCovertures(), null); |
153 |
} |
154 |
return jTabbedPane;
|
155 |
} |
156 |
|
157 |
private InfoPanel getInfoPanel() {
|
158 |
if (infoPanel==null) { |
159 |
infoPanel = new InfoPanel();
|
160 |
infoPanel.addFocusListener(new FocusListener() { |
161 |
public void focusGained(java.awt.event.FocusEvent e) { |
162 |
refreshInfo(); |
163 |
} |
164 |
|
165 |
public void focusLost(FocusEvent e) { |
166 |
|
167 |
} |
168 |
}); |
169 |
} |
170 |
return infoPanel;
|
171 |
} |
172 |
/**
|
173 |
* Fires a notification to this wizard listeners telling them if the
|
174 |
* configuration is fair enough to send a GetCoverage request.
|
175 |
* @param b
|
176 |
*/
|
177 |
private void fireWizardComplete(boolean b){ |
178 |
listenerSupport.callStateChanged(b); |
179 |
callStateChanged(b); |
180 |
} |
181 |
|
182 |
/**
|
183 |
* Refreshes the info shown in the info tab.
|
184 |
*/
|
185 |
public void refreshInfo() { |
186 |
infoPanel.refresh(data); |
187 |
|
188 |
} |
189 |
|
190 |
/**
|
191 |
*
|
192 |
* @return the features list
|
193 |
*/
|
194 |
private Object getLstFeatures() { |
195 |
return featurePanel.getLstSelectedLayers();
|
196 |
} |
197 |
|
198 |
|
199 |
/**
|
200 |
* This method initializes panelCovertures
|
201 |
*
|
202 |
* @return javax.swing.JPanel
|
203 |
*/
|
204 |
private JPanel getPanelCovertures() { |
205 |
if (featurePanel == null) { |
206 |
featurePanel = new WFSSelectFeaturePanel();
|
207 |
featurePanel.setLayout(null);
|
208 |
} |
209 |
return featurePanel;
|
210 |
} |
211 |
/**
|
212 |
* Verifies that the selected parameters are enough to request the coverage
|
213 |
* to the server.
|
214 |
*
|
215 |
* Comprueba que los par?metros seleccionados son suficientes para pedir la
|
216 |
* cobertura al servidor.
|
217 |
*
|
218 |
* @return boolean
|
219 |
*/
|
220 |
public boolean isCorretlyConfigured() { |
221 |
|
222 |
|
223 |
/*
|
224 |
* Seg?n el est?ndar WCS, si se especifica bounding box el par?metro TIME
|
225 |
* no es necesario. ?ste es el caso de gvSIG, que siempre especifica BBOX
|
226 |
* As? que, en teor?a, no deber?amos comprobar si se ha seleccionado algo
|
227 |
* o no. Pero en las pruebas, el servidor que us?bamos respond?a con una
|
228 |
* cobertura en blanco (negro) as? que se ha optado por evitar que se pueda
|
229 |
* consultar sin ninguna posici?n para el tiempo (siempre que la cobertura
|
230 |
* especifique posiciones para el tiempo).
|
231 |
*
|
232 |
* En cualquier caso con comentarizar la l?nea basta.
|
233 |
*/
|
234 |
|
235 |
|
236 |
return true; |
237 |
} |
238 |
|
239 |
|
240 |
/**
|
241 |
* Cleans up the wizard's components but the server's layers list.
|
242 |
*
|
243 |
* Limpia todos los componentes del wizard excepto la lista de capas del
|
244 |
* servidor.
|
245 |
*/
|
246 |
public void cleanupWizard() { |
247 |
|
248 |
} |
249 |
|
250 |
/**
|
251 |
* Refreshes the wizard components data each time a coverage is selected.
|
252 |
*
|
253 |
* Actualiza los datos de los componentes del wizard cada vez que se selecciona
|
254 |
* una cobertura diferente.
|
255 |
*/
|
256 |
public void refreshData(){ |
257 |
// String coverageName = getCurrentCoverageName();
|
258 |
// cleanupWizard();
|
259 |
// if (coverageName != null){
|
260 |
// WFSLayer lyr = data.getLayer(coverageName);
|
261 |
// getTxtName().setText(lyr.getTitle());
|
262 |
//
|
263 |
// // CRS
|
264 |
// getLstCRSs().clearSelection();
|
265 |
// getLstCRSs().setListData(lyr.getSRSs().toArray());
|
266 |
//
|
267 |
// // Formats
|
268 |
// getLstFormats().clearSelection();
|
269 |
// getLstFormats().setListData(lyr.getFormats().toArray());
|
270 |
//
|
271 |
// // InterpolationMethods
|
272 |
// boolean b = lyr.getInterpolationMethods() != null;
|
273 |
// cmbInterpolationMethods.removeAllItems();
|
274 |
// if (b) {
|
275 |
// ArrayList im = lyr.getInterpolationMethods();
|
276 |
// for (int i = 0; i < im.size(); i++)
|
277 |
// cmbInterpolationMethods.addItem(im.get(i));
|
278 |
// }
|
279 |
// getChkUseInterpolationMethod().setEnabled(b);
|
280 |
// getCmbInterpolationMethods().setEnabled(b);
|
281 |
//
|
282 |
// // Time
|
283 |
// getLstTimes().removeAll();
|
284 |
// ArrayList list = lyr.getTimePositions();
|
285 |
// b = !(list == null || list.isEmpty());
|
286 |
// if (b)
|
287 |
// getLstTimes().setListData(list.toArray());
|
288 |
// jTabbedPane.setEnabledAt(indTime, b);
|
289 |
//
|
290 |
// // Parameters
|
291 |
// cmbParam.removeAllItems();
|
292 |
// list = lyr.getParameterList();
|
293 |
// b = !(list == null || list.isEmpty());
|
294 |
// if (b) {
|
295 |
// for (int i = 0; i < list.size(); i++)
|
296 |
// cmbParam.addItem(list.get(i));
|
297 |
// getSingleParamValuesList().setListData(
|
298 |
// ((FMapWCSParameter) cmbParam.getSelectedItem()).getValueList().toArray()
|
299 |
// );
|
300 |
// }
|
301 |
// jTabbedPane.setEnabledAt(indParameter, b);
|
302 |
// fireWizardComplete(isCorretlyConfigured());
|
303 |
// }
|
304 |
} |
305 |
|
306 |
/**
|
307 |
* Sets the object that holds the wizard data.
|
308 |
*
|
309 |
* Establece el objeto que contiene los datos del wizard.
|
310 |
*
|
311 |
* @param data
|
312 |
*/
|
313 |
public void setWizardData(WFSWizardData data) { |
314 |
this.data = data;
|
315 |
featurePanel.setFeatures(data); |
316 |
refreshInfo(); |
317 |
} |
318 |
|
319 |
/**
|
320 |
* Sets the wizard's data source
|
321 |
*
|
322 |
* Establece el origen de los datos del wizard
|
323 |
* @param dataSource
|
324 |
*/
|
325 |
public void setDataSource(WFSWizardData dataSource) { |
326 |
this.data = dataSource;
|
327 |
|
328 |
} |
329 |
|
330 |
|
331 |
/**
|
332 |
* Returns the next enabled tab's index.
|
333 |
*
|
334 |
* Devuelve el ?ndicie de la siguiente pesta?a habilitada del wizard o -1 si no hay
|
335 |
* ninguna.
|
336 |
*
|
337 |
* @return The index or -1 if there is no one.
|
338 |
*/
|
339 |
public int nextPageEnabled() { |
340 |
int currentPage = currentPage();
|
341 |
int nPages = getNumTabs();
|
342 |
if (currentPage == nPages)
|
343 |
return -1; |
344 |
for (int i=currentPage+1; i<nPages; i++){ |
345 |
if (getJTabbedPane().isEnabledAt(i)){
|
346 |
return i;
|
347 |
} |
348 |
} |
349 |
return -1; |
350 |
} |
351 |
|
352 |
/**
|
353 |
* Returns the index of the current tab.
|
354 |
*
|
355 |
* Devuelve el ?ndice de la p?gina actual del wizard.
|
356 |
*
|
357 |
* @return
|
358 |
*/
|
359 |
public int currentPage() { |
360 |
return getJTabbedPane().getSelectedIndex();
|
361 |
} |
362 |
|
363 |
/**
|
364 |
* Returns the index of the previous enabled tab.
|
365 |
*
|
366 |
* Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1 si no hay
|
367 |
* ninguna.
|
368 |
*
|
369 |
* @return The index, or -1 if there is no one.
|
370 |
*/
|
371 |
public int previousEnabledPage() { |
372 |
int currentPage = currentPage();
|
373 |
int j=0; |
374 |
if (currentPage == 0) |
375 |
j= -1;
|
376 |
for (int i = currentPage-1; i>-1; i--){ |
377 |
if (getJTabbedPane().isEnabledAt(i)){
|
378 |
j= i; |
379 |
break;
|
380 |
} |
381 |
} |
382 |
return j;
|
383 |
} |
384 |
|
385 |
public FMapWFSDriver getDriver() {
|
386 |
return data.getDriver();
|
387 |
} |
388 |
|
389 |
public void initWizard() { } |
390 |
public void execute() { } |
391 |
public FLayer getLayer() { return null; } |
392 |
public void setListenerSupport(WizardListenerSupport support) { |
393 |
listenerSupport = support; |
394 |
} |
395 |
|
396 |
} |