root / trunk / extensions / extWFS / src / com / iver / cit / gvsig / wfs / gui / wfswizard / WizardWFS.java @ 2277
History | View | Annotate | Download (21 KB)
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.wfs.gui.wfswizard; |
88 |
|
89 |
import java.awt.BorderLayout; |
90 |
import java.awt.Component; |
91 |
import java.io.IOException; |
92 |
import java.net.MalformedURLException; |
93 |
import java.net.URL; |
94 |
import java.util.ArrayList; |
95 |
|
96 |
import javax.swing.DefaultComboBoxModel; |
97 |
import javax.swing.JButton; |
98 |
import javax.swing.JLabel; |
99 |
import javax.swing.JOptionPane; |
100 |
import javax.swing.JPanel; |
101 |
import javax.swing.JPasswordField; |
102 |
import javax.swing.JRadioButton; |
103 |
import javax.swing.JScrollPane; |
104 |
import javax.swing.JTextField; |
105 |
import javax.swing.ListModel; |
106 |
import javax.swing.tree.DefaultTreeSelectionModel; |
107 |
import javax.swing.tree.TreePath; |
108 |
import javax.swing.tree.TreeSelectionModel; |
109 |
|
110 |
import org.apache.log4j.Logger; |
111 |
import org.cresques.cts.IProjection; |
112 |
import org.cresques.cts.ProjectionPool; |
113 |
import org.exolab.castor.xml.ValidationException; |
114 |
|
115 |
import com.iver.andami.PluginServices; |
116 |
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSDriver; |
117 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
118 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
119 |
import com.iver.cit.gvsig.gui.WizardPanel; |
120 |
import com.iver.cit.gvsig.gui.wizards.LayerInfo; |
121 |
import com.iver.cit.gvsig.gui.wizards.LayerListModel; |
122 |
import com.iver.cit.gvsig.gui.wizards.LayerTreeModel; |
123 |
import com.iver.cit.gvsig.gui.wizards.WizardData; |
124 |
import com.iver.cit.gvsig.gui.wizards.WizardDataSource; |
125 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
126 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
127 |
import com.iver.utiles.NotExistInXMLEntity; |
128 |
import com.iver.utiles.XMLEntity; |
129 |
import com.iver.utiles.swing.JComboBox; |
130 |
import com.iver.wmsclient.UnsupportedVersionException; |
131 |
/**
|
132 |
* DOCUMENT ME!
|
133 |
*
|
134 |
* @author Vicente Caballero Navarro
|
135 |
*/
|
136 |
public class WizardWFS extends WizardPanel { |
137 |
private static Logger logger = Logger.getLogger(WizardWFS.class.getName()); |
138 |
private int page = 0; |
139 |
private boolean conectado = false; |
140 |
private javax.swing.JPanel jContentPane = null; |
141 |
private JComboBox cmbHost = null; |
142 |
private javax.swing.JPanel panelPage1 = null; |
143 |
private LayerListModel selectedLayersModel = new LayerListModel(); |
144 |
private javax.swing.JPanel jPanel1 = null; |
145 |
private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
146 |
private WizardDataSource dataSource;
|
147 |
private JPanel jPanel = null; |
148 |
private JLabel jLabel = null; |
149 |
private JTextField jTxtUser = null; |
150 |
private JLabel jLabel1 = null; |
151 |
private JPasswordField jTxtPassword = null; |
152 |
private JRadioButton jRadioButton = null; |
153 |
private JRadioButton jRadioButton1 = null; |
154 |
private JTextField jTxtnumfeatures = null; |
155 |
private JLabel jLabel2 = null; |
156 |
private JLabel jLabel3 = null; |
157 |
private JTextField jTxttimeout = null; |
158 |
private JButton jButton = null; |
159 |
private JButton jButton1 = null; |
160 |
private JScrollPane jScrollPane = null; |
161 |
private javax.swing.JTree treeLayers1 = null; |
162 |
private JPanel panePage2 = null; |
163 |
private String versionS="version=1.0.0"; |
164 |
private String requestS="request=getcapabilities"; |
165 |
private String serviceS="service=wfs"; |
166 |
private LayerListModel modelo;
|
167 |
/**
|
168 |
* This is the default constructor
|
169 |
*/
|
170 |
public WizardWFS() {
|
171 |
super();
|
172 |
initialize(); |
173 |
} |
174 |
|
175 |
/**
|
176 |
* This method initializes this
|
177 |
*/
|
178 |
private void initialize() { |
179 |
setTabName("WFS");
|
180 |
this.setSize(510, 311); |
181 |
this.setLayout(null); |
182 |
this.setPreferredSize(new java.awt.Dimension(750, 320)); |
183 |
this.setVisible(true); |
184 |
this.add(getPanePage2(), null); |
185 |
this.add(getJButton1(), null); |
186 |
this.add(getJButton(), null); |
187 |
this.add(getPanelPage1(), null); |
188 |
//JRadioButtonMenuItem jrmi=new JRadioButtonMenuItem();
|
189 |
//jrmi.add(getJRadioButton());
|
190 |
//jrmi.add(getJRadioButton1());
|
191 |
//this.add(jrmi);
|
192 |
listenerSupport.callStateChanged(true);
|
193 |
// activarVisualizarBotones();
|
194 |
} |
195 |
|
196 |
|
197 |
|
198 |
/**
|
199 |
* DOCUMENT ME!
|
200 |
*
|
201 |
* @param host DOCUMENT ME!
|
202 |
*/
|
203 |
private void addHost(String host) { |
204 |
host = host.trim(); |
205 |
|
206 |
DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost() |
207 |
.getModel(); |
208 |
|
209 |
if (model.getIndexOf(host) < 0) { |
210 |
model.addElement(host); |
211 |
|
212 |
PluginServices ps = PluginServices.getPluginServices(this);
|
213 |
XMLEntity xml = ps.getPersistentXML(); |
214 |
|
215 |
try {
|
216 |
String[] servers = xml.getStringArrayProperty("wms-servers"); |
217 |
String[] newServers = new String[servers.length + 1]; |
218 |
System.arraycopy(servers, 0, newServers, 0, servers.length); |
219 |
newServers[servers.length] = host; |
220 |
xml.putProperty("wfs-servers", newServers);
|
221 |
} catch (NotExistInXMLEntity e) {
|
222 |
xml.putProperty("wfs-servers", new String[] { host }); |
223 |
} |
224 |
|
225 |
ps.setPersistentXML(xml); |
226 |
} |
227 |
} |
228 |
|
229 |
|
230 |
|
231 |
/**
|
232 |
* This method initializes txtHost
|
233 |
*
|
234 |
* @return javax.swing.JTextField
|
235 |
*/
|
236 |
private javax.swing.JComboBox getTxtHost() {
|
237 |
if (cmbHost == null) { |
238 |
cmbHost = new JComboBox(); |
239 |
cmbHost.setModel(new DefaultComboBoxModel()); |
240 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
241 |
cmbHost.setEditable(true);
|
242 |
|
243 |
XMLEntity xml = PluginServices.getPluginServices(this)
|
244 |
.getPersistentXML(); |
245 |
if (xml == null) |
246 |
xml = new XMLEntity();
|
247 |
String[] servers = null; |
248 |
if (!xml.contains("wfs-servers")) { |
249 |
servers = new String[1]; |
250 |
servers[0] = "http://localhost:8080/geoserver/wfs"; |
251 |
|
252 |
xml.putProperty("wfs-servers", servers);
|
253 |
} |
254 |
|
255 |
try {
|
256 |
servers = xml.getStringArrayProperty("wfs-servers");
|
257 |
|
258 |
for (int i = 0; i < servers.length; i++) { |
259 |
((DefaultComboBoxModel) cmbHost.getModel()).addElement(servers[i]);
|
260 |
} |
261 |
} catch (NotExistInXMLEntity e) {
|
262 |
} |
263 |
} |
264 |
|
265 |
return cmbHost;
|
266 |
} |
267 |
|
268 |
/**
|
269 |
* This method initializes panelPage1
|
270 |
*
|
271 |
* @return javax.swing.JPanel
|
272 |
*/
|
273 |
private javax.swing.JPanel getPanelPage1() {
|
274 |
if (panelPage1 == null) { |
275 |
panelPage1 = new javax.swing.JPanel();
|
276 |
panelPage1.setLayout(new BorderLayout()); |
277 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
278 |
panelPage1.setVisible(true);
|
279 |
panelPage1.setBounds(15, 5, 480, 262); |
280 |
panelPage1.add(getJPanel1(), java.awt.BorderLayout.NORTH); |
281 |
panelPage1.add(getJPanel(), java.awt.BorderLayout.CENTER); |
282 |
} |
283 |
|
284 |
return panelPage1;
|
285 |
} |
286 |
|
287 |
/**
|
288 |
* This method initializes jPanel1
|
289 |
*
|
290 |
* @return javax.swing.JPanel
|
291 |
*/
|
292 |
private javax.swing.JPanel getJPanel1() {
|
293 |
if (jPanel1 == null) { |
294 |
jPanel1 = new javax.swing.JPanel();
|
295 |
jPanel1.add(getTxtHost(), null);
|
296 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
297 |
null, PluginServices.getText(this, "Cadena de conexi?n"), |
298 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
299 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
300 |
} |
301 |
|
302 |
return jPanel1;
|
303 |
} |
304 |
|
305 |
/**
|
306 |
* DOCUMENT ME!
|
307 |
*
|
308 |
* @param listener
|
309 |
*/
|
310 |
public void addWizardListener(WizardListener listener) { |
311 |
listenerSupport.addWizardListener(listener); |
312 |
} |
313 |
|
314 |
/**
|
315 |
* DOCUMENT ME!
|
316 |
*
|
317 |
* @param listener
|
318 |
*/
|
319 |
public void removeWizardListener(WizardListener listener) { |
320 |
listenerSupport.removeWizardListener(listener); |
321 |
} |
322 |
|
323 |
/**
|
324 |
* DOCUMENT ME!
|
325 |
*
|
326 |
* @return
|
327 |
*/
|
328 |
public WizardDataSource getDataSource() {
|
329 |
return dataSource;
|
330 |
} |
331 |
|
332 |
/**
|
333 |
* DOCUMENT ME!
|
334 |
*
|
335 |
* @param source
|
336 |
*/
|
337 |
public void setDataSource(WizardDataSource source) { |
338 |
dataSource = source; |
339 |
} |
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
public String getUrlConnect() { |
346 |
return cmbHost.getModel().getSelectedItem().toString();
|
347 |
} |
348 |
public String getUser() { |
349 |
return jTxtUser.getText();
|
350 |
} |
351 |
public String getPassword() { |
352 |
return jTxtPassword.getText();
|
353 |
} |
354 |
public String getLayerName(){ |
355 |
return getLayers()[0];//getLstSelectedLayers().getModel().toString(); |
356 |
} |
357 |
public String[] getLayers(){ |
358 |
ListModel listModel= modelo;
|
359 |
String[] layers=new String[listModel.getSize()]; |
360 |
for (int i=0;i<listModel.getSize();i++){ |
361 |
layers[i]=listModel.getElementAt(i).toString(); |
362 |
} |
363 |
return layers;
|
364 |
} |
365 |
public WFSDriver getWFSDriver(){
|
366 |
return null;// new FMapWFSDriver(); |
367 |
} |
368 |
public URL getHost(){ |
369 |
String urlS="http://localhost:8080/geoserver/wfs"; |
370 |
String versionS="version=1.0.0"; |
371 |
String requestS="request=getcapabilities"; |
372 |
String serviceS="service=wfs"; |
373 |
URL url=null; |
374 |
try {
|
375 |
url = new URL(urlS+"?"+versionS+"&"+requestS+"&"+serviceS); |
376 |
} catch (MalformedURLException e) { |
377 |
e.printStackTrace(); |
378 |
} |
379 |
return url;
|
380 |
} |
381 |
public IProjection getProjection(){
|
382 |
return ProjectionPool.get("EPSG:23030"); |
383 |
} |
384 |
/**
|
385 |
* This method initializes jPanel
|
386 |
*
|
387 |
* @return javax.swing.JPanel
|
388 |
*/
|
389 |
private JPanel getJPanel() { |
390 |
if (jPanel == null) { |
391 |
jLabel3 = new JLabel(); |
392 |
jLabel3.setBounds(241, 157, 121, 18); |
393 |
jLabel3.setText("Timeout");
|
394 |
jLabel2 = new JLabel(); |
395 |
jLabel2.setBounds(241, 129, 121, 18); |
396 |
jLabel2.setText("N. Features buffer");
|
397 |
jPanel = new JPanel(); |
398 |
jLabel = new JLabel(); |
399 |
jLabel1 = new JLabel(); |
400 |
jPanel.setLayout(null);
|
401 |
jLabel.setText("Usuario:");
|
402 |
jLabel.setName("jLabel");
|
403 |
jLabel.setSize(80, 19); |
404 |
jLabel.setLocation(151, 12); |
405 |
jLabel1.setBounds(149, 41, 82, 19); |
406 |
jLabel1.setText("Contrase?a:");
|
407 |
jPanel.add(getJTxttimeout(), null);
|
408 |
jPanel.add(jLabel3, null);
|
409 |
jPanel.add(jLabel2, null);
|
410 |
jPanel.add(getJTxtnumfeatures(), null);
|
411 |
jPanel.add(getJRadioButton1(), null);
|
412 |
jPanel.add(getJRadioButton(), null);
|
413 |
jPanel.add(jLabel, null);
|
414 |
jPanel.add(getJTxtUser(), null);
|
415 |
jPanel.add(jLabel1, null);
|
416 |
jPanel.add(getJTxtPassword(), null);
|
417 |
} |
418 |
return jPanel;
|
419 |
} |
420 |
/**
|
421 |
* This method initializes jTextField
|
422 |
*
|
423 |
* @return javax.swing.JTextField
|
424 |
*/
|
425 |
private JTextField getJTxtUser() { |
426 |
if (jTxtUser == null) { |
427 |
jTxtUser = new JTextField(); |
428 |
jTxtUser.setName("jTextField");
|
429 |
jTxtUser.setColumns(0);
|
430 |
jTxtUser.setBounds(241, 12, 169, 19); |
431 |
jTxtUser.addFocusListener(new java.awt.event.FocusListener() {
|
432 |
public void focusLost(java.awt.event.FocusEvent e) { |
433 |
listenerSupport.callStateChanged(true);
|
434 |
System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
435 |
} |
436 |
public void focusGained(java.awt.event.FocusEvent e) {} |
437 |
}); |
438 |
} |
439 |
return jTxtUser;
|
440 |
} |
441 |
/**
|
442 |
* This method initializes jPasswordField
|
443 |
*
|
444 |
* @return javax.swing.JPasswordField
|
445 |
*/
|
446 |
private JPasswordField getJTxtPassword() { |
447 |
if (jTxtPassword == null) { |
448 |
jTxtPassword = new JPasswordField(); |
449 |
jTxtPassword.setBounds(241, 39, 169, 20); |
450 |
} |
451 |
return jTxtPassword;
|
452 |
} |
453 |
|
454 |
/**
|
455 |
* This method initializes jRadioButton
|
456 |
*
|
457 |
* @return javax.swing.JRadioButton
|
458 |
*/
|
459 |
private JRadioButton getJRadioButton() { |
460 |
if (jRadioButton == null) { |
461 |
jRadioButton = new JRadioButton(); |
462 |
jRadioButton.setBounds(241, 73, 121, 18); |
463 |
jRadioButton.setText("GET");
|
464 |
jRadioButton.setSelected(true);
|
465 |
} |
466 |
return jRadioButton;
|
467 |
} |
468 |
|
469 |
/**
|
470 |
* This method initializes jRadioButton1
|
471 |
*
|
472 |
* @return javax.swing.JRadioButton
|
473 |
*/
|
474 |
private JRadioButton getJRadioButton1() { |
475 |
if (jRadioButton1 == null) { |
476 |
jRadioButton1 = new JRadioButton(); |
477 |
jRadioButton1.setBounds(241, 101, 121, 18); |
478 |
jRadioButton1.setText("POST");
|
479 |
} |
480 |
return jRadioButton1;
|
481 |
} |
482 |
|
483 |
/**
|
484 |
* This method initializes jTextField
|
485 |
*
|
486 |
* @return javax.swing.JTextField
|
487 |
*/
|
488 |
private JTextField getJTxtnumfeatures() { |
489 |
if (jTxtnumfeatures == null) { |
490 |
jTxtnumfeatures = new JTextField(); |
491 |
jTxtnumfeatures.setBounds(372, 129, 38, 18); |
492 |
jTxtnumfeatures.setText("100");
|
493 |
} |
494 |
return jTxtnumfeatures;
|
495 |
} |
496 |
|
497 |
/**
|
498 |
* This method initializes jTextField1
|
499 |
*
|
500 |
* @return javax.swing.JTextField
|
501 |
*/
|
502 |
private JTextField getJTxttimeout() { |
503 |
if (jTxttimeout == null) { |
504 |
jTxttimeout = new JTextField(); |
505 |
jTxttimeout.setBounds(371, 157, 39, 18); |
506 |
jTxttimeout.setText("10000");
|
507 |
} |
508 |
return jTxttimeout;
|
509 |
} |
510 |
|
511 |
/**
|
512 |
* This method initializes jButton
|
513 |
*
|
514 |
* @return javax.swing.JButton
|
515 |
*/
|
516 |
private JButton getJButton() { |
517 |
if (jButton == null) { |
518 |
jButton = new JButton(); |
519 |
jButton.setBounds(108, 275, 94, 22); |
520 |
jButton.setText(PluginServices.getText(this, "anterior")); |
521 |
jButton.setEnabled(false);
|
522 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
523 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
524 |
page--; |
525 |
//getPanelPage1().setVisible(true);
|
526 |
//getPanePage2().setVisible(false);
|
527 |
activarVisualizarBotones(); |
528 |
conectado=true;
|
529 |
} |
530 |
}); |
531 |
} |
532 |
return jButton;
|
533 |
} |
534 |
|
535 |
/**
|
536 |
* This method initializes jButton1
|
537 |
*
|
538 |
* @return javax.swing.JButton
|
539 |
*/
|
540 |
private JButton getJButton1() { |
541 |
if (jButton1 == null) { |
542 |
jButton1 = new JButton(); |
543 |
jButton1.setBounds(306, 275, 94, 22); |
544 |
jButton1.setText(PluginServices.getText(this, "siguiente")); |
545 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
546 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
547 |
try{
|
548 |
page++; |
549 |
rellenarControles(); |
550 |
//getPanelPage1().setVisible(false);
|
551 |
//getPanePage2().setVisible(true);
|
552 |
activarVisualizarBotones(); |
553 |
} catch (Exception e1) { |
554 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"Servidor WFS no v?lido."); |
555 |
page--; |
556 |
listenerSupport.callError(e1); |
557 |
} |
558 |
} |
559 |
}); |
560 |
} |
561 |
return jButton1;
|
562 |
} |
563 |
/**
|
564 |
* DOCUMENT ME!
|
565 |
*/
|
566 |
private void activarVisualizarBotones() { |
567 |
if (page == 0) { |
568 |
getPanePage2().setVisible(false);
|
569 |
getPanelPage1().setVisible(true);
|
570 |
|
571 |
getJButton().setEnabled(false);
|
572 |
getJButton1().setVisible(true);
|
573 |
|
574 |
if (conectado) {
|
575 |
getJButton1().setEnabled(true);
|
576 |
} else {
|
577 |
getJButton1().setEnabled(false);
|
578 |
} |
579 |
} else if (page == 1) { |
580 |
//rellenarControles();
|
581 |
|
582 |
getPanelPage1().setVisible(false);
|
583 |
getPanePage2().setVisible(true);
|
584 |
getJButton1().setVisible(false);
|
585 |
getJButton().setEnabled(true);
|
586 |
|
587 |
listenerSupport.callStateChanged(true);
|
588 |
|
589 |
/*if ((getLstSRSs().getSelectedIndex() != -1) &&
|
590 |
(getLstFormats1().getSelectedIndex() != -1) &&
|
591 |
(getLstSelectedLayers().getModel().getSize() > 0)) {
|
592 |
listenerSupport.callStateChanged(true);
|
593 |
} else {
|
594 |
listenerSupport.callStateChanged(false);
|
595 |
}
|
596 |
*/
|
597 |
if (getTreeLayers1().getSelectionCount() > 0) { |
598 |
LayerInfo nodo = (LayerInfo) getTreeLayers1().getSelectionPath() |
599 |
.getLastPathComponent(); |
600 |
String name = nodo.name;
|
601 |
|
602 |
if (name != null) { |
603 |
//getBtnAdd().setEnabled(true);
|
604 |
} else {
|
605 |
//getBtnAdd().setEnabled(false);
|
606 |
} |
607 |
} else {
|
608 |
//getBtnAdd().setEnabled(false);
|
609 |
} |
610 |
|
611 |
//if (getLstSelectedLayers().getSelectedIndex() != -1) {
|
612 |
// getBtnDel().setEnabled(true);
|
613 |
//} else {
|
614 |
// getBtnDel().setEnabled(false);
|
615 |
//}
|
616 |
} |
617 |
} |
618 |
|
619 |
/**
|
620 |
* This method initializes jScrollPane
|
621 |
*
|
622 |
* @return javax.swing.JScrollPane
|
623 |
*/
|
624 |
private JScrollPane getJScrollPane() { |
625 |
if (jScrollPane == null) { |
626 |
jScrollPane = new JScrollPane(); |
627 |
jScrollPane.setViewportView(getTreeLayers1()); |
628 |
jScrollPane.setPreferredSize(new java.awt.Dimension(150,200)); |
629 |
} |
630 |
return jScrollPane;
|
631 |
} |
632 |
private javax.swing.JTree getTreeLayers1() {
|
633 |
if (treeLayers1 == null) { |
634 |
treeLayers1 = new javax.swing.JTree();
|
635 |
treeLayers1.setRootVisible(false);
|
636 |
TreeSelectionModel tsm=new DefaultTreeSelectionModel(); |
637 |
tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
638 |
treeLayers1.setSelectionModel(tsm); |
639 |
treeLayers1.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
640 |
public void valueChanged( |
641 |
javax.swing.event.TreeSelectionEvent e) { |
642 |
addLayer(); |
643 |
///activarVisualizarBotones();
|
644 |
} |
645 |
}); |
646 |
} |
647 |
|
648 |
return treeLayers1;
|
649 |
} |
650 |
/**
|
651 |
* DOCUMENT ME!
|
652 |
*/
|
653 |
private void addLayer() { |
654 |
boolean alguno = false; |
655 |
|
656 |
TreePath[] selecciones = getTreeLayers1().getSelectionPaths(); |
657 |
|
658 |
for (int i = 0; i < selecciones.length; i++) { |
659 |
LayerInfo nodo = (LayerInfo) selecciones[i].getLastPathComponent(); |
660 |
|
661 |
String name = nodo.name;
|
662 |
String text = nodo.text;
|
663 |
|
664 |
//Se a?ade a la lista de layers seleccionados
|
665 |
modelo = new LayerListModel();//(LayerListModel) lstSelectedLayers.getModel(); |
666 |
|
667 |
if (modelo.addElement(nodo)) {
|
668 |
alguno = true;
|
669 |
} |
670 |
} |
671 |
|
672 |
if (alguno) {
|
673 |
activarVisualizarBotones(); |
674 |
//actualizarSRS();
|
675 |
} |
676 |
} |
677 |
|
678 |
/**
|
679 |
* DOCUMENT ME!
|
680 |
*/
|
681 |
private void delLayer() { |
682 |
//int[] index = lstSelectedLayers.getSelectedIndices();
|
683 |
|
684 |
ArrayList removeList = new ArrayList(); |
685 |
//LayerListModel modelo = (LayerListModel) lstSelectedLayers.getModel();
|
686 |
LayerInfo[] infos = modelo.getElements();
|
687 |
|
688 |
//for (int i = 0; i < index.length; i++) {
|
689 |
// removeList.add(infos[index[i]]);
|
690 |
//}
|
691 |
|
692 |
modelo.delElements(removeList); |
693 |
//lstSelectedLayers.clearSelection();
|
694 |
|
695 |
activarVisualizarBotones(); |
696 |
|
697 |
//actualizarSRS();
|
698 |
} |
699 |
/**
|
700 |
* DOCUMENT ME!
|
701 |
* @throws IOException
|
702 |
* @throws UnsupportedVersionException
|
703 |
* @throws MalformedURLException
|
704 |
* @throws ValidationException
|
705 |
* @throws IllegalStateException
|
706 |
*/
|
707 |
private void rellenarControles() throws IllegalStateException, ValidationException, MalformedURLException, UnsupportedVersionException, IOException { |
708 |
String host = cmbHost.getModel().getSelectedItem().toString();
|
709 |
((WFSDataSourceAdapter)dataSource).setData(getUser(),getPassword(),getProtocol(),getNumFeatures(),getTimeout()); |
710 |
WizardData data = dataSource.detalles(new URL(host+"?"+versionS+"&"+requestS+"&"+serviceS)); |
711 |
|
712 |
addHost(host); |
713 |
treeLayers1.setModel(new LayerTreeModel(data.getLayer()));
|
714 |
conectado = true;
|
715 |
|
716 |
} |
717 |
|
718 |
/**
|
719 |
* This method initializes jPanel3
|
720 |
*
|
721 |
* @return javax.swing.JPanel
|
722 |
*/
|
723 |
private JPanel getPanePage2() { |
724 |
if (panePage2 == null) { |
725 |
panePage2 = new JPanel(); |
726 |
panePage2.setBounds(0, 2, 495, 266); |
727 |
panePage2.setVisible(false);
|
728 |
panePage2.add(getJScrollPane(), null);
|
729 |
} |
730 |
return panePage2;
|
731 |
} |
732 |
|
733 |
public boolean getProtocol(){ |
734 |
if (getJRadioButton().isSelected()){
|
735 |
return true; |
736 |
} |
737 |
return false; |
738 |
} |
739 |
public int getNumFeatures(){ |
740 |
return Integer.parseInt(getJTxtnumfeatures().getText()); |
741 |
} |
742 |
public int getTimeout(){ |
743 |
return Integer.parseInt(getJTxttimeout().getText()); |
744 |
} |
745 |
public void initWizard() { |
746 |
setDataSource(new WFSDataSourceAdapter());
|
747 |
} |
748 |
|
749 |
/* (non-Javadoc)
|
750 |
* @see com.iver.cit.gvsig.gui.WizardPanel#execute()
|
751 |
*/
|
752 |
public void execute() { |
753 |
} |
754 |
|
755 |
/* (non-Javadoc)
|
756 |
* @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
|
757 |
*/
|
758 |
public FLayer getLayer() {
|
759 |
WizardWFS wfs = this;
|
760 |
String[] layers=wfs.getLayers(); |
761 |
if (layers.length>0) { |
762 |
String layerName = wfs.getLayerName();
|
763 |
String user = wfs.getUser();
|
764 |
String pwd = wfs.getPassword();
|
765 |
String url = wfs.getUrlConnect();
|
766 |
|
767 |
boolean protocol=wfs.getProtocol();
|
768 |
int numfeatures=wfs.getNumFeatures();
|
769 |
int timeout=wfs.getTimeout();
|
770 |
//String fields = wfs.getSqlFields();
|
771 |
//String whereClause = dbWiz.getSqlWhere();
|
772 |
WFSDriver driver = new WFSDriver();
|
773 |
try{
|
774 |
driver.setData(url,user,pwd,layers,protocol,numfeatures,timeout,2);
|
775 |
}catch (IOException e) { |
776 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),"Fallo de la conexi?n con el servidor"); |
777 |
return null; |
778 |
} |
779 |
return LayerFactory.createWFSLayer(layerName,driver,wfs.getHost(),
|
780 |
wfs.getProjection()); |
781 |
} |
782 |
return null; |
783 |
} |
784 |
} |