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