Revision 1890
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/wizards/WFSWizard.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/* |
|
42 |
* Created on 23-abr-2004 |
|
43 |
* |
|
44 |
* To change the template for this generated file go to |
|
45 |
* Window>Preferences>Java>Code Generation>Code and Comments |
|
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 |
package com.iver.cit.gvsig.gui.wizards; |
|
88 |
|
|
89 |
import com.iver.andami.PluginServices; |
|
90 |
import com.iver.andami.Utilities; |
|
91 |
|
|
92 |
|
|
93 |
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSDriver; |
|
94 |
import com.iver.cit.gvsig.gui.WizardPanel; |
|
95 |
import com.iver.cit.gvsig.gui.wms.LayerInfo; |
|
96 |
import com.iver.cit.gvsig.gui.wms.LayerListModel; |
|
97 |
import com.iver.cit.gvsig.gui.wms.LayerTreeModel; |
|
98 |
import com.iver.cit.gvsig.gui.wms.WizardData; |
|
99 |
import com.iver.cit.gvsig.gui.wms.WizardDataSource; |
|
100 |
import com.iver.cit.gvsig.gui.wms.WizardListener; |
|
101 |
import com.iver.cit.gvsig.gui.wms.WizardListenerSupport; |
|
102 |
|
|
103 |
import com.iver.utiles.NotExistInXMLEntity; |
|
104 |
import com.iver.utiles.XMLEntity; |
|
105 |
import com.iver.utiles.swing.JComboBox; |
|
106 |
|
|
107 |
import org.apache.log4j.Logger; |
|
108 |
import org.cresques.cts.IProjection; |
|
109 |
import org.cresques.cts.ProjectionPool; |
|
110 |
|
|
111 |
import java.awt.geom.Rectangle2D; |
|
112 |
|
|
113 |
import java.net.MalformedURLException; |
|
114 |
import java.net.URL; |
|
115 |
|
|
116 |
import java.util.ArrayList; |
|
117 |
import java.util.HashSet; |
|
118 |
import java.util.Iterator; |
|
119 |
import java.util.TreeSet; |
|
120 |
|
|
121 |
import javax.swing.DefaultComboBoxModel; |
|
122 |
import javax.swing.DefaultListModel; |
|
123 |
import javax.swing.JPanel; |
|
124 |
import javax.swing.JRadioButtonMenuItem; |
|
125 |
import javax.swing.JTextField; |
|
126 |
import javax.swing.tree.TreePath; |
|
127 |
|
|
128 |
|
|
129 |
import javax.swing.JLabel; |
|
130 |
import java.awt.BorderLayout; |
|
131 |
import java.awt.CardLayout; |
|
132 |
import java.awt.GridLayout; |
|
133 |
import javax.swing.JPasswordField; |
|
134 |
import javax.swing.JCheckBox; |
|
135 |
import javax.swing.JRadioButton; |
|
136 |
/** |
|
137 |
* DOCUMENT ME! |
|
138 |
* |
|
139 |
* @author Vicente Caballero Navarro |
|
140 |
*/ |
|
141 |
public class WFSWizard extends WizardPanel { |
|
142 |
private static Logger logger = Logger.getLogger(WFSWizard.class.getName()); |
|
143 |
private int page = 0; |
|
144 |
private boolean conectado = false; |
|
145 |
private javax.swing.JPanel jContentPane = null; |
|
146 |
private JComboBox cmbHost = null; |
|
147 |
private javax.swing.JPanel panelPage1 = null; |
|
148 |
private LayerListModel selectedLayersModel = new LayerListModel(); |
|
149 |
private javax.swing.JPanel jPanel1 = null; |
|
150 |
private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
|
151 |
private WizardDataSource dataSource; |
|
152 |
private JPanel jPanel = null; |
|
153 |
private JLabel jLabel = null; |
|
154 |
private JTextField jTxtUser = null; |
|
155 |
private JLabel jLabel1 = null; |
|
156 |
private JPasswordField jTxtPassword = null; |
|
157 |
private JRadioButton jRadioButton = null; |
|
158 |
private JRadioButton jRadioButton1 = null; |
|
159 |
private JTextField jTxtnumfeatures = null; |
|
160 |
private JLabel jLabel2 = null; |
|
161 |
private JLabel jLabel3 = null; |
|
162 |
private JTextField jTxttimeout = null; |
|
163 |
/** |
|
164 |
* This is the default constructor |
|
165 |
*/ |
|
166 |
public WFSWizard() { |
|
167 |
super(); |
|
168 |
initialize(); |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* This method initializes this |
|
173 |
*/ |
|
174 |
private void initialize() { |
|
175 |
this.setSize(510, 311); |
|
176 |
this.setLayout(null); |
|
177 |
this.setPreferredSize(new java.awt.Dimension(750, 320)); |
|
178 |
this.setVisible(true); |
|
179 |
this.add(getPanelPage1(), null); |
|
180 |
//JRadioButtonMenuItem jrmi=new JRadioButtonMenuItem(); |
|
181 |
//jrmi.add(getJRadioButton()); |
|
182 |
//jrmi.add(getJRadioButton1()); |
|
183 |
//this.add(jrmi); |
|
184 |
listenerSupport.callStateChanged(true); |
|
185 |
// activarVisualizarBotones(); |
|
186 |
} |
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
/** |
|
191 |
* DOCUMENT ME! |
|
192 |
* |
|
193 |
* @param host DOCUMENT ME! |
|
194 |
*/ |
|
195 |
private void addHost(String host) { |
|
196 |
host = host.trim(); |
|
197 |
|
|
198 |
DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost() |
|
199 |
.getModel(); |
|
200 |
|
|
201 |
if (model.getIndexOf(host) < 0) { |
|
202 |
model.addElement(host); |
|
203 |
|
|
204 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
205 |
XMLEntity xml = ps.getPersistentXML(); |
|
206 |
|
|
207 |
try { |
|
208 |
String[] servers = xml.getStringArrayProperty("wms-servers"); |
|
209 |
String[] newServers = new String[servers.length + 1]; |
|
210 |
System.arraycopy(servers, 0, newServers, 0, servers.length); |
|
211 |
newServers[servers.length] = host; |
|
212 |
xml.putProperty("wfs-servers", newServers); |
|
213 |
} catch (NotExistInXMLEntity e) { |
|
214 |
xml.putProperty("wfs-servers", new String[] { host }); |
|
215 |
} |
|
216 |
|
|
217 |
ps.setPersistentXML(xml); |
|
218 |
} |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* DOCUMENT ME! |
|
223 |
*/ |
|
224 |
private void rellenarControles() { |
|
225 |
try { |
|
226 |
String host = cmbHost.getModel().getSelectedItem().toString(); |
|
227 |
|
|
228 |
// if (!host.endsWith("?")) { |
|
229 |
// host += "?"; |
|
230 |
// } |
|
231 |
|
|
232 |
WizardData data = dataSource.detalles(new URL(host)); |
|
233 |
|
|
234 |
addHost(host); |
|
235 |
conectado = true; |
|
236 |
// activarVisualizarBotones(); |
|
237 |
} catch (Exception e) { |
|
238 |
listenerSupport.callError(e); |
|
239 |
} |
|
240 |
} |
|
241 |
|
|
242 |
|
|
243 |
/** |
|
244 |
* This method initializes txtHost |
|
245 |
* |
|
246 |
* @return javax.swing.JTextField |
|
247 |
*/ |
|
248 |
private javax.swing.JComboBox getTxtHost() { |
|
249 |
if (cmbHost == null) { |
|
250 |
cmbHost = new JComboBox(); |
|
251 |
cmbHost.setModel(new DefaultComboBoxModel()); |
|
252 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
|
253 |
cmbHost.setEditable(true); |
|
254 |
|
|
255 |
XMLEntity xml = PluginServices.getPluginServices(this) |
|
256 |
.getPersistentXML(); |
|
257 |
if (xml == null) |
|
258 |
xml = new XMLEntity(); |
|
259 |
String[] servers = null; |
|
260 |
if (!xml.contains("wfs-servers")) { |
|
261 |
servers = new String[1]; |
|
262 |
servers[0] = "http://localhost:8080/geoserver/wfs"; |
|
263 |
|
|
264 |
xml.putProperty("wfs-servers", servers); |
|
265 |
} |
|
266 |
|
|
267 |
try { |
|
268 |
servers = xml.getStringArrayProperty("wfs-servers"); |
|
269 |
|
|
270 |
for (int i = 0; i < servers.length; i++) { |
|
271 |
((DefaultComboBoxModel) cmbHost.getModel()).addElement(servers[i]); |
|
272 |
} |
|
273 |
} catch (NotExistInXMLEntity e) { |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
277 |
return cmbHost; |
|
278 |
} |
|
279 |
|
|
280 |
/** |
|
281 |
* This method initializes panelPage1 |
|
282 |
* |
|
283 |
* @return javax.swing.JPanel |
|
284 |
*/ |
|
285 |
private javax.swing.JPanel getPanelPage1() { |
|
286 |
if (panelPage1 == null) { |
|
287 |
panelPage1 = new javax.swing.JPanel(); |
|
288 |
panelPage1.setLayout(new BorderLayout()); |
|
289 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
|
290 |
panelPage1.setVisible(true); |
|
291 |
panelPage1.setBounds(15, 5, 480, 262); |
|
292 |
panelPage1.add(getJPanel1(), java.awt.BorderLayout.NORTH); |
|
293 |
panelPage1.add(getJPanel(), java.awt.BorderLayout.CENTER); |
|
294 |
} |
|
295 |
|
|
296 |
return panelPage1; |
|
297 |
} |
|
298 |
|
|
299 |
/** |
|
300 |
* This method initializes jPanel1 |
|
301 |
* |
|
302 |
* @return javax.swing.JPanel |
|
303 |
*/ |
|
304 |
private javax.swing.JPanel getJPanel1() { |
|
305 |
if (jPanel1 == null) { |
|
306 |
jPanel1 = new javax.swing.JPanel(); |
|
307 |
jPanel1.add(getTxtHost(), null); |
|
308 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
|
309 |
null, PluginServices.getText(this, "Cadena de conexi?n"), |
|
310 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
311 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
312 |
} |
|
313 |
|
|
314 |
return jPanel1; |
|
315 |
} |
|
316 |
|
|
317 |
/** |
|
318 |
* DOCUMENT ME! |
|
319 |
* |
|
320 |
* @param listener |
|
321 |
*/ |
|
322 |
public void addWizardListener(WizardListener listener) { |
|
323 |
listenerSupport.addWizardListener(listener); |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* DOCUMENT ME! |
|
328 |
* |
|
329 |
* @param listener |
|
330 |
*/ |
|
331 |
public void removeWizardListener(WizardListener listener) { |
|
332 |
listenerSupport.removeWizardListener(listener); |
|
333 |
} |
|
334 |
|
|
335 |
/** |
|
336 |
* DOCUMENT ME! |
|
337 |
* |
|
338 |
* @return |
|
339 |
*/ |
|
340 |
public WizardDataSource getDataSource() { |
|
341 |
return dataSource; |
|
342 |
} |
|
343 |
|
|
344 |
/** |
|
345 |
* DOCUMENT ME! |
|
346 |
* |
|
347 |
* @param source |
|
348 |
*/ |
|
349 |
public void setDataSource(WizardDataSource source) { |
|
350 |
dataSource = source; |
|
351 |
} |
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
public String getUrlConnect() { |
|
358 |
return cmbHost.getModel().getSelectedItem().toString(); |
|
359 |
} |
|
360 |
public String getUser() { |
|
361 |
return jTxtUser.getText(); |
|
362 |
} |
|
363 |
public String getPassword() { |
|
364 |
return jTxtPassword.getText(); |
|
365 |
} |
|
366 |
public String getLayerName(){ |
|
367 |
return "shapeName"; |
|
368 |
} |
|
369 |
public WFSDriver getWFSDriver(){ |
|
370 |
return null;// new FMapWFSDriver(); |
|
371 |
} |
|
372 |
public URL getHost(){ |
|
373 |
String urlS="http://localhost:8080/geoserver/wfs"; |
|
374 |
String versionS="version=1.0.0"; |
|
375 |
String requestS="request=getcapabilities"; |
|
376 |
String serviceS="service=wfs"; |
|
377 |
URL url=null; |
|
378 |
try { |
|
379 |
url = new URL(urlS+"?"+versionS+"&"+requestS+"&"+serviceS); |
|
380 |
} catch (MalformedURLException e) { |
|
381 |
e.printStackTrace(); |
|
382 |
} |
|
383 |
return url; |
|
384 |
} |
|
385 |
public IProjection getProjection(){ |
|
386 |
return ProjectionPool.get("EPSG:23030"); |
|
387 |
} |
|
388 |
/** |
|
389 |
* This method initializes jPanel |
|
390 |
* |
|
391 |
* @return javax.swing.JPanel |
|
392 |
*/ |
|
393 |
private JPanel getJPanel() { |
|
394 |
if (jPanel == null) { |
|
395 |
jLabel3 = new JLabel(); |
|
396 |
jLabel3.setBounds(241, 157, 121, 18); |
|
397 |
jLabel3.setText("Timeout"); |
|
398 |
jLabel2 = new JLabel(); |
|
399 |
jLabel2.setBounds(241, 129, 121, 18); |
|
400 |
jLabel2.setText("N. Features buffer"); |
|
401 |
jPanel = new JPanel(); |
|
402 |
jLabel = new JLabel(); |
|
403 |
jLabel1 = new JLabel(); |
|
404 |
jPanel.setLayout(null); |
|
405 |
jLabel.setText("Usuario:"); |
|
406 |
jLabel.setName("jLabel"); |
|
407 |
jLabel.setSize(80, 19); |
|
408 |
jLabel.setLocation(151, 12); |
|
409 |
jLabel1.setBounds(149, 41, 82, 19); |
|
410 |
jLabel1.setText("Contrase?a:"); |
|
411 |
jPanel.add(getJTxttimeout(), null); |
|
412 |
jPanel.add(jLabel3, null); |
|
413 |
jPanel.add(jLabel2, null); |
|
414 |
jPanel.add(getJTxtnumfeatures(), null); |
|
415 |
jPanel.add(getJRadioButton1(), null); |
|
416 |
jPanel.add(getJRadioButton(), null); |
|
417 |
jPanel.add(jLabel, null); |
|
418 |
jPanel.add(getJTxtUser(), null); |
|
419 |
jPanel.add(jLabel1, null); |
|
420 |
jPanel.add(getJTxtPassword(), null); |
|
421 |
} |
|
422 |
return jPanel; |
|
423 |
} |
|
424 |
/** |
|
425 |
* This method initializes jTextField |
|
426 |
* |
|
427 |
* @return javax.swing.JTextField |
|
428 |
*/ |
|
429 |
private JTextField getJTxtUser() { |
|
430 |
if (jTxtUser == null) { |
|
431 |
jTxtUser = new JTextField(); |
|
432 |
jTxtUser.setName("jTextField"); |
|
433 |
jTxtUser.setColumns(0); |
|
434 |
jTxtUser.setBounds(241, 12, 169, 19); |
|
435 |
jTxtUser.setText("admin"); |
|
436 |
jTxtUser.addFocusListener(new java.awt.event.FocusListener() { |
|
437 |
public void focusLost(java.awt.event.FocusEvent e) { |
|
438 |
listenerSupport.callStateChanged(true); |
|
439 |
System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
|
440 |
} |
|
441 |
public void focusGained(java.awt.event.FocusEvent e) {} |
|
442 |
}); |
|
443 |
} |
|
444 |
return jTxtUser; |
|
445 |
} |
|
446 |
/** |
|
447 |
* This method initializes jPasswordField |
|
448 |
* |
|
449 |
* @return javax.swing.JPasswordField |
|
450 |
*/ |
|
451 |
private JPasswordField getJTxtPassword() { |
|
452 |
if (jTxtPassword == null) { |
|
453 |
jTxtPassword = new JPasswordField(); |
|
454 |
jTxtPassword.setBounds(241, 39, 169, 20); |
|
455 |
} |
|
456 |
return jTxtPassword; |
|
457 |
} |
|
458 |
|
|
459 |
/** |
|
460 |
* This method initializes jRadioButton |
|
461 |
* |
|
462 |
* @return javax.swing.JRadioButton |
|
463 |
*/ |
|
464 |
private JRadioButton getJRadioButton() { |
|
465 |
if (jRadioButton == null) { |
|
466 |
jRadioButton = new JRadioButton(); |
|
467 |
jRadioButton.setBounds(241, 73, 121, 18); |
|
468 |
jRadioButton.setText("GET"); |
|
469 |
jRadioButton.setSelected(true); |
|
470 |
} |
|
471 |
return jRadioButton; |
|
472 |
} |
|
473 |
|
|
474 |
/** |
|
475 |
* This method initializes jRadioButton1 |
|
476 |
* |
|
477 |
* @return javax.swing.JRadioButton |
|
478 |
*/ |
|
479 |
private JRadioButton getJRadioButton1() { |
|
480 |
if (jRadioButton1 == null) { |
|
481 |
jRadioButton1 = new JRadioButton(); |
|
482 |
jRadioButton1.setBounds(241, 101, 121, 18); |
|
483 |
jRadioButton1.setText("POST"); |
|
484 |
} |
|
485 |
return jRadioButton1; |
|
486 |
} |
|
487 |
|
|
488 |
/** |
|
489 |
* This method initializes jTextField |
|
490 |
* |
|
491 |
* @return javax.swing.JTextField |
|
492 |
*/ |
|
493 |
private JTextField getJTxtnumfeatures() { |
|
494 |
if (jTxtnumfeatures == null) { |
|
495 |
jTxtnumfeatures = new JTextField(); |
|
496 |
jTxtnumfeatures.setBounds(372, 129, 38, 18); |
|
497 |
} |
|
498 |
return jTxtnumfeatures; |
|
499 |
} |
|
500 |
|
|
501 |
/** |
|
502 |
* This method initializes jTextField1 |
|
503 |
* |
|
504 |
* @return javax.swing.JTextField |
|
505 |
*/ |
|
506 |
private JTextField getJTxttimeout() { |
|
507 |
if (jTxttimeout == null) { |
|
508 |
jTxttimeout = new JTextField(); |
|
509 |
jTxttimeout.setBounds(371, 157, 39, 18); |
|
510 |
} |
|
511 |
return jTxttimeout; |
|
512 |
} |
|
513 |
} |
|
0 | 514 |
Also available in: Unified diff