root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / wizards / WFSWizard.java @ 6501
History | View | Annotate | Download (18.5 KB)
1 |
package com.iver.cit.gvsig.gui.wizards; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.geom.Rectangle2D; |
5 |
import java.net.MalformedURLException; |
6 |
import java.net.URL; |
7 |
import java.util.prefs.Preferences; |
8 |
|
9 |
import javax.swing.DefaultComboBoxModel; |
10 |
import org.gvsig.gui.beans.swing.JButton; |
11 |
import javax.swing.JCheckBox; |
12 |
import javax.swing.JLabel; |
13 |
import javax.swing.JOptionPane; |
14 |
|
15 |
import org.apache.log4j.Logger; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.andami.persistence.serverData.ServerDataPersistence; |
19 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
20 |
import com.iver.cit.gvsig.fmap.layers.FLyrWFS; |
21 |
import com.iver.cit.gvsig.gui.WizardPanel; |
22 |
import com.iver.cit.gvsig.gui.panels.WFSParamsPanel; |
23 |
import com.iver.utiles.NotExistInXMLEntity; |
24 |
import com.iver.utiles.XMLEntity; |
25 |
import com.iver.utiles.swing.jcomboServer.JComboServer; |
26 |
import com.iver.utiles.swing.jcomboServer.ServerData; |
27 |
|
28 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
29 |
*
|
30 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
31 |
*
|
32 |
* This program is free software; you can redistribute it and/or
|
33 |
* modify it under the terms of the GNU General Public License
|
34 |
* as published by the Free Software Foundation; either version 2
|
35 |
* of the License, or (at your option) any later version.
|
36 |
*
|
37 |
* This program is distributed in the hope that it will be useful,
|
38 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
39 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
40 |
* GNU General Public License for more details.
|
41 |
*
|
42 |
* You should have received a copy of the GNU General Public License
|
43 |
* along with this program; if not, write to the Free Software
|
44 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
45 |
*
|
46 |
* For more information, contact:
|
47 |
*
|
48 |
* Generalitat Valenciana
|
49 |
* Conselleria d'Infraestructures i Transport
|
50 |
* Av. Blasco Ib??ez, 50
|
51 |
* 46010 VALENCIA
|
52 |
* SPAIN
|
53 |
*
|
54 |
* +34 963862235
|
55 |
* gvsig@gva.es
|
56 |
* www.gvsig.gva.es
|
57 |
*
|
58 |
* or
|
59 |
*
|
60 |
* IVER T.I. S.A
|
61 |
* Salamanca 50
|
62 |
* 46005 Valencia
|
63 |
* Spain
|
64 |
*
|
65 |
* +34 963163400
|
66 |
* dac@iver.es
|
67 |
*/
|
68 |
/* CVS MESSAGES:
|
69 |
*
|
70 |
* $Id: WFSWizard.java 6501 2006-07-21 11:51:55Z jaume $
|
71 |
* $Log$
|
72 |
* Revision 1.12 2006-07-21 11:50:31 jaume
|
73 |
* improved appearance
|
74 |
*
|
75 |
* Revision 1.11 2006/07/11 11:55:41 jorpiell
|
76 |
* Se ha a?adido el fallo de tipo de dato en el log
|
77 |
*
|
78 |
* Revision 1.10 2006/06/15 11:17:06 jorpiell
|
79 |
* Se ha encontrado la forma de comprobar cuando se prodicia un error de parseo al hacer un hasnext (en la feature). Se atrapa y se lanza la excepci?n hacia arriba
|
80 |
*
|
81 |
* Revision 1.9 2006/06/14 08:46:24 jorpiell
|
82 |
* Se tiene en cuanta la opcion para refrescar las capabilities
|
83 |
*
|
84 |
* Revision 1.8 2006/05/25 16:22:59 jorpiell
|
85 |
* Se limpia el panel cada vez que se conecta con un servidor distinto
|
86 |
*
|
87 |
* Revision 1.7 2006/05/25 16:01:51 jorpiell
|
88 |
* Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
|
89 |
*
|
90 |
* Revision 1.6 2006/05/25 10:29:07 jorpiell
|
91 |
* A?adido el checkbox para que se haga uso de la cache
|
92 |
*
|
93 |
* Revision 1.5 2006/05/24 12:08:53 jorpiell
|
94 |
* Cambiado el nombre de la pesta?a a WFS
|
95 |
*
|
96 |
* Revision 1.4 2006/05/23 13:21:59 jorpiell
|
97 |
* Si hay alg?n problema en la carga se muestra un mensaje de error
|
98 |
*
|
99 |
* Revision 1.3 2006/05/23 08:09:53 jorpiell
|
100 |
* 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
|
101 |
*
|
102 |
* Revision 1.2 2006/05/19 12:58:03 jorpiell
|
103 |
* Modificados algunos paneles
|
104 |
*
|
105 |
* Revision 1.1 2006/04/19 12:50:16 jorpiell
|
106 |
* Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
|
107 |
*
|
108 |
*
|
109 |
*/
|
110 |
/**
|
111 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
112 |
*/
|
113 |
public class WFSWizard extends WizardPanel { |
114 |
private int page = 0; |
115 |
private boolean connected = false; |
116 |
private JComboServer cmbHost = null; |
117 |
private JButton btnConnect = null; |
118 |
private javax.swing.JPanel jPanel = null; |
119 |
private javax.swing.JLabel jLabel1 = null; |
120 |
private javax.swing.JLabel lblTitle = null; |
121 |
private javax.swing.JScrollPane jScrollPane = null; |
122 |
private javax.swing.JTextArea txtAbstract = null; |
123 |
private javax.swing.JPanel panelPage1 = null; |
124 |
private JButton btnSiguiente = null; |
125 |
private JButton btnAnterior = null; |
126 |
private javax.swing.JPanel jPanel1 = null; |
127 |
private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
128 |
private WFSParamsPanel wfsParamsPanel = null; |
129 |
private WFSWizardData dataSource = null; |
130 |
private JLabel lblServerType = null; |
131 |
private JLabel lblServerTypeValue = null; |
132 |
private JCheckBox chkCaching = null; |
133 |
private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wfs-wizard" ); |
134 |
private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false); |
135 |
|
136 |
/**
|
137 |
* This is the default constructor
|
138 |
*/
|
139 |
public WFSWizard() {
|
140 |
super();
|
141 |
initialize(); |
142 |
} |
143 |
|
144 |
/**
|
145 |
* This method initializes this
|
146 |
*/
|
147 |
private void initialize() { |
148 |
setTabName("WFS");
|
149 |
lblServerType = new JLabel(); |
150 |
lblServerType.setBounds(20, 444, 100, 20); |
151 |
lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
152 |
lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
153 |
lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); |
154 |
lblServerType.setText(PluginServices.getText(this, "server_type")+":"); |
155 |
lblServerTypeValue = new JLabel(); |
156 |
lblServerTypeValue.setBounds(128, 444, 148, 20); |
157 |
lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11)); |
158 |
lblServerTypeValue.setText("-");
|
159 |
this.setLayout(null); |
160 |
this.setPreferredSize(new java.awt.Dimension(750, 320)); |
161 |
this.setVisible(true); |
162 |
this.setSize(518, 468); |
163 |
this.add(getPanelPage1(), null); |
164 |
this.add(getPanelPage2(), null); |
165 |
this.add(getBtnAnterior(), null); |
166 |
this.add(getBtnSiguiente(), null); |
167 |
this.add(lblServerType, null); |
168 |
this.add(lblServerTypeValue, null); |
169 |
activarVisualizarBotones(); |
170 |
} |
171 |
|
172 |
/**
|
173 |
* Adds the host addres to a persistent data storage.
|
174 |
*
|
175 |
* con addHost guardamos la informaci?n del combo de servidores en un
|
176 |
* almac?n persistente
|
177 |
*
|
178 |
* @param host
|
179 |
*/
|
180 |
private void addHost(String host) { |
181 |
host = host.trim(); |
182 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WMS); |
183 |
persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WMS));
|
184 |
} |
185 |
|
186 |
/**
|
187 |
* Fills up the initial WCSWizard controls.
|
188 |
*
|
189 |
* Rellena los primeros controles del WCS Wizard
|
190 |
*
|
191 |
* jaume
|
192 |
*/
|
193 |
private void rellenarControles() { |
194 |
try {
|
195 |
String host = cmbHost.getModel().getSelectedItem().toString();
|
196 |
|
197 |
dataSource.setHost(new URL(host), refreshing); |
198 |
addHost(host); |
199 |
getLblTitle().setText(dataSource.getTitle()); |
200 |
getTxtAbstract().setText(dataSource.getAbstract()); |
201 |
lblServerTypeValue.setText(dataSource.getServerType()); |
202 |
wfsParamsPanel.setWizardData(dataSource); |
203 |
|
204 |
connected = true;
|
205 |
activarVisualizarBotones(); |
206 |
} catch (Exception e) { |
207 |
listenerSupport.callError(e); |
208 |
e.printStackTrace(); |
209 |
} |
210 |
} |
211 |
|
212 |
/**
|
213 |
* Enables or disables the Next and Previous buttons according with the current
|
214 |
* page and the enabled pages.
|
215 |
*/
|
216 |
private void activarVisualizarBotones() { |
217 |
if (page == 0) { |
218 |
getBtnAnterior().setEnabled(false);
|
219 |
getBtnSiguiente().setVisible(true);
|
220 |
if (connected) {
|
221 |
getBtnSiguiente().setEnabled(true);
|
222 |
} else {
|
223 |
getBtnSiguiente().setEnabled(false);
|
224 |
} |
225 |
} else if (page < wfsParamsPanel.getNumTabs()) { |
226 |
getBtnSiguiente().setEnabled(true);
|
227 |
getBtnSiguiente().setVisible(true);
|
228 |
getBtnAnterior().setEnabled(true);
|
229 |
getBtnAnterior().setVisible(true);
|
230 |
if (wfsParamsPanel.nextPageEnabled()==-1){ |
231 |
getBtnSiguiente().setEnabled(false);
|
232 |
} |
233 |
listenerSupport.callStateChanged(wfsParamsPanel.isCorretlyConfigured()); |
234 |
} else if (page == wfsParamsPanel.getNumTabs()) { |
235 |
getBtnSiguiente().setVisible(false);
|
236 |
getBtnSiguiente().setEnabled(false);
|
237 |
listenerSupport.callStateChanged(wfsParamsPanel |
238 |
.isCorretlyConfigured()); |
239 |
} |
240 |
|
241 |
} |
242 |
|
243 |
|
244 |
|
245 |
/**
|
246 |
* This method initializes txtHost from the persistent data storage
|
247 |
*
|
248 |
* @return javax.swing.JTextField
|
249 |
*/
|
250 |
private javax.swing.JComboBox getTxtHost() {
|
251 |
if (cmbHost == null) { |
252 |
cmbHost = new JComboServer();
|
253 |
cmbHost.setModel(new DefaultComboBoxModel()); |
254 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
255 |
cmbHost.setBounds(11, 26, 454, 20); |
256 |
cmbHost.setEditable(true);
|
257 |
|
258 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WFS); |
259 |
ServerData[] servers = persistence.getArrayOfServerData();
|
260 |
|
261 |
if (servers.length == 0){ |
262 |
PluginServices ps = PluginServices.getPluginServices(this);
|
263 |
XMLEntity xml = ps.getPersistentXML(); |
264 |
try {
|
265 |
String[] oldServers = xml.getStringArrayProperty("wfs-servers"); |
266 |
servers = new ServerData[oldServers.length];
|
267 |
for (int i=0; i<oldServers.length; i++) { |
268 |
servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WMS);
|
269 |
} |
270 |
xml.remove("wfs-servers");
|
271 |
ps.setPersistentXML(xml); |
272 |
} catch (NotExistInXMLEntity e) {
|
273 |
// Old servers doesn't exist
|
274 |
servers = new ServerData[1]; |
275 |
servers[0] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswfs_gmap",ServerData.SERVER_TYPE_WFS); |
276 |
} |
277 |
|
278 |
for (int i=0 ; i<servers.length ; i++){ |
279 |
persistence.addServerData(servers[i]); |
280 |
} |
281 |
persistence.setPersistent(); |
282 |
} |
283 |
|
284 |
cmbHost.setServerList(servers); |
285 |
} |
286 |
return cmbHost;
|
287 |
} |
288 |
|
289 |
|
290 |
/**
|
291 |
* This method initializes btnDetalles
|
292 |
*
|
293 |
* @return JButton
|
294 |
*/
|
295 |
private JButton getBtnConnect() { |
296 |
if (btnConnect == null) { |
297 |
btnConnect = new JButton(); |
298 |
btnConnect.setPreferredSize(new java.awt.Dimension(100, 20)); |
299 |
btnConnect.setBounds(366, 50, 100, 20); |
300 |
btnConnect.setText(PluginServices.getText(this, "connect")); |
301 |
btnConnect.addActionListener(new java.awt.event.ActionListener() {
|
302 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
303 |
rellenarControles(); |
304 |
} |
305 |
}); |
306 |
} |
307 |
|
308 |
return btnConnect;
|
309 |
} |
310 |
|
311 |
/**
|
312 |
* This method initializes jPanel
|
313 |
*
|
314 |
* @return javax.swing.JPanel
|
315 |
*/
|
316 |
private javax.swing.JPanel getJPanel() {
|
317 |
if (jPanel == null) { |
318 |
jPanel = new javax.swing.JPanel();
|
319 |
jPanel.setLayout(null);
|
320 |
jPanel.setPreferredSize(new java.awt.Dimension(470, 130)); |
321 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
|
322 |
PluginServices.getText(this, "descripcion"), |
323 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
324 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
325 |
null));
|
326 |
jPanel.setBounds(2, 96, 477, 324); |
327 |
jPanel.add(getJLabel1(), null);
|
328 |
jPanel.add(getLblTitle(), null);
|
329 |
jPanel.add(getJScrollPane(), null);
|
330 |
} |
331 |
|
332 |
return jPanel;
|
333 |
} |
334 |
|
335 |
/**
|
336 |
* This method initializes jLabel1
|
337 |
*
|
338 |
* @return javax.swing.JLabel
|
339 |
*/
|
340 |
private javax.swing.JLabel getJLabel1() {
|
341 |
if (jLabel1 == null) { |
342 |
jLabel1 = new javax.swing.JLabel();
|
343 |
jLabel1.setText(PluginServices.getText(this, "nombre") + ":"); |
344 |
jLabel1.setBounds(37, 26, 40, 15); |
345 |
} |
346 |
|
347 |
return jLabel1;
|
348 |
} |
349 |
|
350 |
/**
|
351 |
* This method initializes lblTitle
|
352 |
*
|
353 |
* @return javax.swing.JLabel
|
354 |
*/
|
355 |
private javax.swing.JLabel getLblTitle() {
|
356 |
if (lblTitle == null) { |
357 |
lblTitle = new javax.swing.JLabel();
|
358 |
lblTitle.setText("-");
|
359 |
lblTitle.setPreferredSize(new java.awt.Dimension(350, 16)); |
360 |
lblTitle.setBounds(82, 26, 350, 16); |
361 |
} |
362 |
|
363 |
return lblTitle;
|
364 |
} |
365 |
|
366 |
/**
|
367 |
* This method initializes jScrollPane
|
368 |
*
|
369 |
* @return javax.swing.JScrollPane
|
370 |
*/
|
371 |
private javax.swing.JScrollPane getJScrollPane() {
|
372 |
if (jScrollPane == null) { |
373 |
jScrollPane = new javax.swing.JScrollPane();
|
374 |
jScrollPane.setViewportView(getTxtAbstract()); |
375 |
jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60)); |
376 |
jScrollPane.setBounds(10, 47, 450, 267); |
377 |
} |
378 |
|
379 |
return jScrollPane;
|
380 |
} |
381 |
|
382 |
/**
|
383 |
* This method initializes txtAbstract
|
384 |
*
|
385 |
* @return javax.swing.JTextArea
|
386 |
*/
|
387 |
private javax.swing.JTextArea getTxtAbstract() {
|
388 |
if (txtAbstract == null) { |
389 |
txtAbstract = new javax.swing.JTextArea();
|
390 |
txtAbstract.setWrapStyleWord(true);
|
391 |
txtAbstract.setColumns(30);
|
392 |
txtAbstract.setLineWrap(true);
|
393 |
} |
394 |
|
395 |
return txtAbstract;
|
396 |
} |
397 |
|
398 |
/**
|
399 |
* This method initializes panelPage1
|
400 |
*
|
401 |
* @return javax.swing.JPanel
|
402 |
*/
|
403 |
private javax.swing.JPanel getPanelPage1() {
|
404 |
if (panelPage1 == null) { |
405 |
panelPage1 = new javax.swing.JPanel();
|
406 |
panelPage1.setLayout(null);
|
407 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
408 |
panelPage1.setVisible(true);
|
409 |
panelPage1.setBounds(15, 5, 480, 427); |
410 |
panelPage1.add(getJPanel1(), null);
|
411 |
panelPage1.add(getJPanel(), null);
|
412 |
} |
413 |
|
414 |
return panelPage1;
|
415 |
} |
416 |
|
417 |
/**
|
418 |
* This method initializes panelPage2
|
419 |
*
|
420 |
* @return javax.swing.JPanel
|
421 |
*/
|
422 |
private javax.swing.JPanel getPanelPage2() {
|
423 |
if (wfsParamsPanel == null) { |
424 |
wfsParamsPanel = new WFSParamsPanel();
|
425 |
wfsParamsPanel.setListenerSupport(this.listenerSupport);
|
426 |
wfsParamsPanel.setBounds(0, 5, 510, 428); |
427 |
wfsParamsPanel.getJTabbedPane().addMouseListener( |
428 |
new java.awt.event.MouseAdapter() {
|
429 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
430 |
page = wfsParamsPanel.currentPage() + 1;
|
431 |
activarVisualizarBotones(); |
432 |
} |
433 |
}); |
434 |
} |
435 |
|
436 |
return wfsParamsPanel;
|
437 |
} |
438 |
|
439 |
|
440 |
|
441 |
/**
|
442 |
* This method initializes btnSiguiente
|
443 |
*
|
444 |
* @return JButton
|
445 |
*/
|
446 |
private JButton getBtnSiguiente() { |
447 |
if (btnSiguiente == null) { |
448 |
btnSiguiente = new JButton(); |
449 |
btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30)); |
450 |
btnSiguiente.setBounds(395, 444, 100, 20); |
451 |
btnSiguiente.setText(PluginServices.getText(this, "siguiente")); |
452 |
btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
|
453 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
454 |
if (page > 0) { |
455 |
// si page es mayor que cero, vamos enfocando las
|
456 |
// sucesivas SOLAPAS del wfsParamsPanel
|
457 |
wfsParamsPanel.avanzaTab(); |
458 |
page = wfsParamsPanel.getIndiceSolapaActual(); |
459 |
} |
460 |
page++; |
461 |
|
462 |
getPanelPage1().setVisible(false);
|
463 |
getPanelPage2().setVisible(true);
|
464 |
activarVisualizarBotones(); |
465 |
} |
466 |
}); |
467 |
} |
468 |
return btnSiguiente;
|
469 |
} |
470 |
|
471 |
/**
|
472 |
* This method initializes btnAnterior
|
473 |
*
|
474 |
* @return JButton
|
475 |
*/
|
476 |
private JButton getBtnAnterior() { |
477 |
if (btnAnterior == null) { |
478 |
btnAnterior = new JButton(); |
479 |
btnAnterior.setBounds(292, 444, 100, 20); |
480 |
btnAnterior.setText(PluginServices.getText(this, "anterior")); |
481 |
btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30)); |
482 |
btnAnterior.addActionListener(new java.awt.event.ActionListener() {
|
483 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
484 |
page --; |
485 |
if (page > 0) { |
486 |
// Tenemos que retroceder en el wfsParamsPanel
|
487 |
wfsParamsPanel.retrocedeTab(); |
488 |
page = wfsParamsPanel.getIndiceSolapaActual() + 1;
|
489 |
activarVisualizarBotones(); |
490 |
} else if (page==0){ |
491 |
activarVisualizarBotones(); |
492 |
page = 1;
|
493 |
wfsParamsPanel.cleanupWizard(); |
494 |
getLblTitle().setText("-");
|
495 |
getTxtAbstract().setText("");
|
496 |
wfsParamsPanel.retrocedeTab(); |
497 |
getPanelPage1().setVisible(true);
|
498 |
getPanelPage2().setVisible(false);
|
499 |
getBtnSiguiente().setEnabled(false);
|
500 |
connected = false;
|
501 |
} |
502 |
listenerSupport.callStateChanged(wfsParamsPanel.isCorretlyConfigured()); |
503 |
} |
504 |
}); |
505 |
} |
506 |
return btnAnterior;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* This method initializes jPanel1
|
511 |
*
|
512 |
* @return javax.swing.JPanel
|
513 |
*/
|
514 |
private javax.swing.JPanel getJPanel1() {
|
515 |
if (jPanel1 == null) { |
516 |
jPanel1 = new javax.swing.JPanel();
|
517 |
jPanel1.setLayout(null);
|
518 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
519 |
null, PluginServices.getText(this, "server"), |
520 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
521 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
522 |
jPanel1.setBounds(2, 5, 477, 85); |
523 |
jPanel1.add(getTxtHost(), null);
|
524 |
jPanel1.add(getBtnConnect(), null);
|
525 |
jPanel1.add(getChkCaching(), null);
|
526 |
} |
527 |
|
528 |
return jPanel1;
|
529 |
} |
530 |
|
531 |
/**
|
532 |
* Adds the gvSIG's wizard listener
|
533 |
*
|
534 |
* @param listener
|
535 |
*/
|
536 |
public void addWizardListener(WizardListener listener) { |
537 |
listenerSupport.addWizardListener(listener); |
538 |
} |
539 |
|
540 |
/**
|
541 |
* Removes the gvSIG's wizard listener
|
542 |
*
|
543 |
* @param listener
|
544 |
*/
|
545 |
public void removeWizardListener(WizardListener listener) { |
546 |
listenerSupport.removeWizardListener(listener); |
547 |
} |
548 |
|
549 |
/**
|
550 |
* Returns the Wizard's data source
|
551 |
*
|
552 |
* @return
|
553 |
*/
|
554 |
public WFSWizardData getDataSource() {
|
555 |
return dataSource;
|
556 |
} |
557 |
|
558 |
/**
|
559 |
* sets the wizard's data source
|
560 |
*
|
561 |
* @param source
|
562 |
*/
|
563 |
public void setDataSource(WFSWizardData source) { |
564 |
dataSource = source; |
565 |
} |
566 |
|
567 |
/**
|
568 |
* Returns the rectangle that contains all the others
|
569 |
*
|
570 |
* Obtiene el rect?ngulo que contiene a todos los otros
|
571 |
*
|
572 |
* @param rects[] rectangulos
|
573 |
*
|
574 |
* @return Rectangle2D
|
575 |
*/
|
576 |
public static Rectangle2D getRectangle(Rectangle2D[] rects) { |
577 |
Rectangle2D ret = rects[0]; |
578 |
|
579 |
for (int i = 1; i < rects.length; i++) { |
580 |
ret.add(rects[i]); |
581 |
} |
582 |
|
583 |
return ret;
|
584 |
} |
585 |
|
586 |
/**
|
587 |
* Returns the host typed in the host text field or null if nothing is typed
|
588 |
* or it is not a valid URL.
|
589 |
*
|
590 |
* Devuelve el host que est? escrito en el cuadro de texto del host o null
|
591 |
* en caso de que no haya nada escrito o est? mal escrito
|
592 |
*
|
593 |
* @return URL del host
|
594 |
*/
|
595 |
public URL getHost() { |
596 |
try {
|
597 |
return new URL(cmbHost.getModel().getSelectedItem().toString()); |
598 |
} catch (MalformedURLException e) { |
599 |
return null; |
600 |
} |
601 |
} |
602 |
|
603 |
|
604 |
public void initWizard() { |
605 |
setDataSource(new WFSWizardData());
|
606 |
} |
607 |
|
608 |
public void execute() { |
609 |
} |
610 |
|
611 |
/* (non-Javadoc)
|
612 |
* @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
|
613 |
*/
|
614 |
public FLayer getLayer() {
|
615 |
FLyrWFS layer = (FLyrWFS)wfsParamsPanel.getLayer(); |
616 |
layer.setHost(this.getHost());
|
617 |
layer.setWfsDriver(dataSource.getDriver()); |
618 |
layer.setOnlineResource(dataSource.getOnlineResource()); |
619 |
try {
|
620 |
layer.load(); |
621 |
} catch (Exception e) { |
622 |
// TODO Auto-generated catch block
|
623 |
Logger.getLogger(getClass().getName()).error(e.getMessage());
|
624 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
625 |
PluginServices.getText(this,"cantLoad")); |
626 |
return null; |
627 |
} |
628 |
|
629 |
return layer;
|
630 |
} |
631 |
|
632 |
/**
|
633 |
* This method initializes chkCaching
|
634 |
*
|
635 |
* @return javax.swing.JCheckBox
|
636 |
*/
|
637 |
private JCheckBox getChkCaching() { |
638 |
if (chkCaching == null) { |
639 |
chkCaching = new JCheckBox(); |
640 |
chkCaching.setBounds(7, 51, 349, 20); |
641 |
chkCaching.setText(PluginServices.getText(this, "refresh_capabilities")); |
642 |
chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip")); |
643 |
chkCaching.setSelected(refreshing); |
644 |
chkCaching.addItemListener(new java.awt.event.ItemListener() {
|
645 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
646 |
refreshing = chkCaching.isSelected(); |
647 |
} |
648 |
}); |
649 |
chkCaching.addActionListener(new java.awt.event.ActionListener() {
|
650 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
651 |
fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
|
652 |
} |
653 |
}); |
654 |
|
655 |
} |
656 |
return chkCaching;
|
657 |
} |
658 |
|
659 |
|
660 |
|
661 |
} |