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