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