svn-gvsig-desktop / trunk / extensions / extWMS / src / com / iver / cit / gvsig / gui / wizards / WMSWizard.java @ 4624
History | View | Annotate | Download (28.7 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 |
package com.iver.cit.gvsig.gui.wizards; |
42 |
|
43 |
import java.awt.Component; |
44 |
import java.awt.Dimension; |
45 |
import java.awt.geom.Rectangle2D; |
46 |
import java.net.MalformedURLException; |
47 |
import java.net.URL; |
48 |
import java.util.Hashtable; |
49 |
import java.util.Vector; |
50 |
import java.util.prefs.Preferences; |
51 |
|
52 |
import javax.swing.DefaultComboBoxModel; |
53 |
import javax.swing.JCheckBox; |
54 |
import javax.swing.JLabel; |
55 |
import javax.swing.JOptionPane; |
56 |
import javax.swing.JPanel; |
57 |
import javax.swing.tree.TreePath; |
58 |
|
59 |
import org.apache.log4j.Logger; |
60 |
|
61 |
import com.iver.andami.PluginServices; |
62 |
import com.iver.andami.persistence.serverData.ServerDataPersistence; |
63 |
import com.iver.cit.gvsig.fmap.drivers.wms.FMapWMSDriver; |
64 |
import com.iver.cit.gvsig.fmap.exceptions.CannotReprojectException; |
65 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
66 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
67 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
68 |
import com.iver.cit.gvsig.fmap.layers.WMSLayerNode; |
69 |
import com.iver.cit.gvsig.gui.WizardPanel; |
70 |
import com.iver.cit.gvsig.gui.panels.LayerTree; |
71 |
import com.iver.cit.gvsig.gui.panels.WMSParamsPanel; |
72 |
import com.iver.utiles.NotExistInXMLEntity; |
73 |
import com.iver.utiles.XMLEntity; |
74 |
import com.iver.utiles.swing.jcomboServer.JComboServer; |
75 |
import com.iver.utiles.swing.jcomboServer.ServerData; |
76 |
|
77 |
|
78 |
/**
|
79 |
* The WMS properties container panel.
|
80 |
*
|
81 |
* @author Jaume Dominguez Faus
|
82 |
*/
|
83 |
public class WMSWizard extends WizardPanel { |
84 |
private static Logger logger = Logger.getLogger(WMSWizard.class.getName()); |
85 |
protected int page; |
86 |
protected boolean connected = false; |
87 |
private JComboServer cmbHost = null; |
88 |
private javax.swing.JButton btnConnect = null; |
89 |
private javax.swing.JPanel jPanel = null; |
90 |
private javax.swing.JLabel jLabel1 = null; |
91 |
private javax.swing.JLabel lblTitle = null; |
92 |
private javax.swing.JScrollPane jScrollPane = null; |
93 |
private javax.swing.JTextArea txtAbstract = null; |
94 |
private javax.swing.JPanel panelPage1 = null; |
95 |
private javax.swing.JButton btnSiguiente = null; |
96 |
private javax.swing.JButton btnAnterior = null; |
97 |
private javax.swing.JPanel jPanel1 = null; |
98 |
protected WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
99 |
protected WMSWizardData dataSource;
|
100 |
protected WMSParamsPanel wmsParamsPanel = null; |
101 |
protected JLabel lblServerType = null; |
102 |
protected JLabel lblServerTypeValue = null; |
103 |
private JCheckBox chkCaching = null; |
104 |
private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wms-wizard" ); |
105 |
private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false); |
106 |
protected int firstPage; |
107 |
|
108 |
public WMSWizard (WMSParamsPanel params){
|
109 |
|
110 |
super();
|
111 |
firstPage = 1;
|
112 |
page = firstPage; |
113 |
this.wmsParamsPanel = params;
|
114 |
this.dataSource = wmsParamsPanel.dataSource;
|
115 |
|
116 |
setTabName("WMS");
|
117 |
lblServerType = new JLabel(); |
118 |
lblServerType.setBounds(20, 444, 100, 20); |
119 |
lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
120 |
lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
121 |
lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); |
122 |
lblServerType.setText(PluginServices.getText(this, "server_type")+":"); |
123 |
lblServerTypeValue = new JLabel(); |
124 |
lblServerTypeValue.setBounds(128, 444, 148, 20); |
125 |
lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11)); |
126 |
lblServerTypeValue.setText("-");
|
127 |
this.setSize(510, 468); |
128 |
this.setLayout(null); |
129 |
this.setPreferredSize(new java.awt.Dimension(750, 420)); |
130 |
this.setVisible(true); |
131 |
|
132 |
wmsParamsPanel.setListenerSupport(this.listenerSupport);
|
133 |
wmsParamsPanel.setBounds(15, 5, 480, 428); |
134 |
wmsParamsPanel.getJTabbedPane().addMouseListener( |
135 |
new java.awt.event.MouseAdapter() {
|
136 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
137 |
page = wmsParamsPanel.currentPage() + 1;
|
138 |
activarVisualizarBotones(); |
139 |
} |
140 |
}); |
141 |
this.add(wmsParamsPanel, null); |
142 |
this.add(lblServerType, null); |
143 |
this.add(lblServerTypeValue, null); |
144 |
getPanelPage2().setVisible(true);
|
145 |
connected = true;
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* This is the default constructor
|
150 |
*/
|
151 |
public WMSWizard() {
|
152 |
super();
|
153 |
firstPage = 0;
|
154 |
page = firstPage; |
155 |
initialize(); |
156 |
} |
157 |
/**
|
158 |
* This method initializes this
|
159 |
*/
|
160 |
private void initialize() { |
161 |
setTabName("WMS");
|
162 |
|
163 |
lblServerType = new JLabel(); |
164 |
lblServerType.setBounds(20, 444, 100, 20); |
165 |
lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
166 |
lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
167 |
lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); |
168 |
lblServerType.setText(PluginServices.getText(this, "server_type")+":"); |
169 |
lblServerTypeValue = new JLabel(); |
170 |
lblServerTypeValue.setBounds(128, 444, 148, 20); |
171 |
lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11)); |
172 |
lblServerTypeValue.setText("-");
|
173 |
this.setSize(510, 468); |
174 |
this.setLayout(null); |
175 |
this.setPreferredSize(new java.awt.Dimension(750, 420)); |
176 |
this.setVisible(true); |
177 |
this.add(getPanelPage1(), null); |
178 |
this.add(getPanelPage2(), null); |
179 |
this.add(getBtnAnterior(), null); |
180 |
this.add(getBtnSiguiente(), null); |
181 |
this.add(lblServerType, null); |
182 |
this.add(lblServerTypeValue, null); |
183 |
activarVisualizarBotones(); |
184 |
} |
185 |
|
186 |
|
187 |
protected JPanel getPanelPage2(){ |
188 |
if (wmsParamsPanel == null){ |
189 |
wmsParamsPanel = new WMSParamsPanel();
|
190 |
wmsParamsPanel.setListenerSupport(this.listenerSupport);
|
191 |
wmsParamsPanel.setBounds(15, 5, 480, 428); |
192 |
wmsParamsPanel.getJTabbedPane().addMouseListener( |
193 |
new java.awt.event.MouseAdapter() {
|
194 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
195 |
page = wmsParamsPanel.currentPage() + 1;
|
196 |
activarVisualizarBotones(); |
197 |
} |
198 |
}); |
199 |
} |
200 |
return wmsParamsPanel;
|
201 |
} |
202 |
/**
|
203 |
* DOCUMENT ME!
|
204 |
*
|
205 |
* @param host DOCUMENT ME!
|
206 |
*/
|
207 |
private void addHost(String host) { |
208 |
host = host.trim(); |
209 |
|
210 |
// DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost()
|
211 |
// .getModel();
|
212 |
|
213 |
// if (model.getIndexOf(host) < 0) {
|
214 |
// model.addElement(host);
|
215 |
|
216 |
// PluginServices ps = PluginServices.getPluginServices(this);
|
217 |
// XMLEntity xml = ps.getPersistentXML();
|
218 |
|
219 |
// try {
|
220 |
// String[] servers = xml.getStringArrayProperty("wms-servers");
|
221 |
// String[] newServers = new String[servers.length + 1];
|
222 |
// System.arraycopy(servers, 0, newServers, 0, servers.length);
|
223 |
// newServers[servers.length] = host;
|
224 |
// xml.putProperty("wms-servers", newServers);
|
225 |
// } catch (NotExistInXMLEntity e) {
|
226 |
// xml.putProperty("wms-servers", new String[] { host });
|
227 |
// }
|
228 |
|
229 |
// ps.setPersistentXML(xml);
|
230 |
// }
|
231 |
|
232 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WMS); |
233 |
persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WMS));
|
234 |
|
235 |
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* DOCUMENT ME!
|
240 |
*/
|
241 |
private void rellenarControles() { |
242 |
try {
|
243 |
String host = cmbHost.getModel().getSelectedItem().toString();
|
244 |
|
245 |
dataSource.setHost(new URL(host), refreshing); |
246 |
lblTitle.setText(dataSource.getTitle()); |
247 |
lblServerTypeValue.setText(dataSource.getServerType()); |
248 |
txtAbstract.setText(dataSource.getAbstract()); |
249 |
|
250 |
addHost(host); |
251 |
wmsParamsPanel.setWizardData(dataSource); |
252 |
connected = true;
|
253 |
activarVisualizarBotones(); |
254 |
} catch (Exception e) { |
255 |
listenerSupport.callError(e); |
256 |
e.printStackTrace(); |
257 |
} |
258 |
} |
259 |
|
260 |
/**
|
261 |
* DOCUMENT ME!
|
262 |
*/
|
263 |
protected void activarVisualizarBotones() { |
264 |
if (page == firstPage) {
|
265 |
getBtnAnterior().setEnabled(false);
|
266 |
getBtnSiguiente().setVisible(true);
|
267 |
|
268 |
if (connected) {
|
269 |
getBtnSiguiente().setEnabled(true);
|
270 |
} else {
|
271 |
getBtnSiguiente().setEnabled(false);
|
272 |
} |
273 |
} else if (page < wmsParamsPanel.getNumTabs()) { |
274 |
getBtnSiguiente().setEnabled(true);
|
275 |
getBtnSiguiente().setVisible(true);
|
276 |
getBtnAnterior().setEnabled(true);
|
277 |
getBtnAnterior().setVisible(true);
|
278 |
if (wmsParamsPanel.nextEnabledPage()==-1){ |
279 |
getBtnSiguiente().setEnabled(false);
|
280 |
} |
281 |
listenerSupport.callStateChanged(wmsParamsPanel.isCorrectlyConfigured()); |
282 |
} else if (page == wmsParamsPanel.getNumTabs()) { |
283 |
getBtnSiguiente().setVisible(false);
|
284 |
getBtnSiguiente().setEnabled(false);
|
285 |
listenerSupport.callStateChanged(wmsParamsPanel |
286 |
.isCorrectlyConfigured()); |
287 |
} |
288 |
} |
289 |
|
290 |
/**
|
291 |
* This method initializes txtHost
|
292 |
*
|
293 |
* @return javax.swing.JTextField
|
294 |
*/
|
295 |
private javax.swing.JComboBox getTxtHost() {
|
296 |
if (cmbHost == null) { |
297 |
cmbHost = new JComboServer();
|
298 |
cmbHost.setModel(new DefaultComboBoxModel()); |
299 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
300 |
cmbHost.setBounds(11, 26, 454, 20); |
301 |
cmbHost.setEditable(true);
|
302 |
|
303 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WMS); |
304 |
ServerData[] servers = persistence.getArrayOfServerData();
|
305 |
|
306 |
if (servers.length == 0){ |
307 |
PluginServices ps = PluginServices.getPluginServices(this);
|
308 |
XMLEntity xml = ps.getPersistentXML(); |
309 |
try {
|
310 |
String[] oldServers = xml.getStringArrayProperty("wms-servers"); |
311 |
servers = new ServerData[oldServers.length];
|
312 |
for (int i=0; i<oldServers.length; i++) { |
313 |
servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WMS);
|
314 |
} |
315 |
xml.remove("wms-servers");
|
316 |
ps.setPersistentXML(xml); |
317 |
} catch (NotExistInXMLEntity e) {
|
318 |
// Old servers doesn't exist
|
319 |
servers = new ServerData[12]; |
320 |
servers[0] = new ServerData("http://www.idee.es/wms/IDEE-Base/IDEE-Base",ServerData.SERVER_TYPE_WMS); |
321 |
servers[1] = new ServerData("http://wms.jpl.nasa.gov/wms.cgi",ServerData.SERVER_TYPE_WMS); |
322 |
servers[2] = new ServerData("http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?",ServerData.SERVER_TYPE_WMS); |
323 |
servers[3] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_patricova",ServerData.SERVER_TYPE_WMS); |
324 |
servers[4] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_parque_fondo_prug",ServerData.SERVER_TYPE_WMS); |
325 |
servers[5] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_pgof",ServerData.SERVER_TYPE_WMS); |
326 |
servers[6] = new ServerData("http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos",ServerData.SERVER_TYPE_WMS); |
327 |
servers[7] = new ServerData("http://onearth.jpl.nasa.gov/wms.cgi",ServerData.SERVER_TYPE_WMS); |
328 |
servers[8] = new ServerData("http://www.demis.nl/wms/wms.asp?WMS=WorldMap",ServerData.SERVER_TYPE_WMS); |
329 |
servers[9] = new ServerData("http://aes.gsfc.nasa.gov/cgi-bin/wms",ServerData.SERVER_TYPE_WMS); |
330 |
servers[10] = new ServerData("http://mapas.euitto.upm.es/cgi-bin/cnauticas",ServerData.SERVER_TYPE_WMS); |
331 |
servers[11] = new ServerData("http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx", ServerData.SERVER_TYPE_WMS); |
332 |
} |
333 |
|
334 |
for (int i=0 ; i<servers.length ; i++){ |
335 |
persistence.addServerData(servers[i]); |
336 |
} |
337 |
persistence.setPersistent(); |
338 |
} |
339 |
|
340 |
cmbHost.setServerList(servers); |
341 |
|
342 |
|
343 |
// XMLEntity xml = PluginServices.getPluginServices(this)
|
344 |
// .getPersistentXML();
|
345 |
// if (xml == null)
|
346 |
// xml = new XMLEntity();
|
347 |
|
348 |
// if (!xml.contains("wms-servers")) {
|
349 |
// String[] servers = new String[11];
|
350 |
// // Begining of rubbish code
|
351 |
// //
|
352 |
// // The following block should not exist and it only will live in the
|
353 |
// // 0.6 version. It fixes an error that has been happening since the 0.4 version
|
354 |
// // and recovers the user's server data from the wrong location that has been used to use.
|
355 |
// // This code will be removed from the 0.7 version
|
356 |
// boolean bool = false;
|
357 |
// {
|
358 |
// Class gvSIGClass = AddLayer.class; // for example... (we only need to use a class that has been loaded by gvSIG's class loader
|
359 |
// XMLEntity xml2 = PluginServices.getPluginServices(PluginServices.getExtension(gvSIGClass)).getPersistentXML();
|
360 |
// if (xml2.contains("wms-servers")) {
|
361 |
// String oldServers[] = xml2.getStringArrayProperty("wms-servers");
|
362 |
// servers = new String[servers.length+oldServers.length];
|
363 |
// for (int i = 0; i < oldServers.length; i++) {
|
364 |
// servers[oldServers.length+i] = oldServers[i];
|
365 |
// }
|
366 |
// xml2.remove("wms-servers");
|
367 |
// bool = true;
|
368 |
// }
|
369 |
// }
|
370 |
// if (!bool) {
|
371 |
// // end of the rubbish code (don't forget to remove the closing bracket)
|
372 |
|
373 |
// servers[0] = "http://www.idee.es/wms/IDEE-Base/IDEE-Base";
|
374 |
// servers[1] = "http://wms.jpl.nasa.gov/wms.cgi";
|
375 |
// servers[2] = "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?";
|
376 |
// servers[3] = "http://demo.deegree.org:8080/deegree/wms";
|
377 |
// servers[4] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_patricova";
|
378 |
// servers[5] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_parque_fondo_prug";
|
379 |
// servers[6] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_pgof";
|
380 |
// servers[7] = "http://orto.cth.gva.es/wmsconnector/com.esri.wms.Esrimap/wms_urbanismo_tematicos";
|
381 |
// servers[8] = "http://onearth.jpl.nasa.gov/wms.cgi";
|
382 |
// servers[9] = "http://www.demis.nl/wms/wms.asp?WMS=WorldMap";
|
383 |
// servers[9] = "http://aes.gsfc.nasa.gov/cgi-bin/wms";
|
384 |
// servers[10]= "http://mapas.euitto.upm.es/cgi-bin/cnauticas";
|
385 |
|
386 |
// } // this bracket will be removed too in version <= 0.7
|
387 |
// xml.putProperty("wms-servers", servers);
|
388 |
// }
|
389 |
// try {
|
390 |
// String[] servers = xml.getStringArrayProperty("wms-servers");
|
391 |
// for (int i = 0; i < servers.length; i++) {
|
392 |
// ((DefaultComboBoxModel) cmbHost.getModel()).addElement(servers[i]);
|
393 |
// }
|
394 |
// } catch (NotExistInXMLEntity e) {
|
395 |
// }
|
396 |
} |
397 |
|
398 |
return cmbHost;
|
399 |
} |
400 |
|
401 |
|
402 |
/**
|
403 |
* This method initializes btnDetalles
|
404 |
*
|
405 |
* @return javax.swing.JButton
|
406 |
*/
|
407 |
private javax.swing.JButton getBtnConnect() {
|
408 |
if (btnConnect == null) { |
409 |
btnConnect = new javax.swing.JButton();
|
410 |
btnConnect.setPreferredSize(new java.awt.Dimension(100, 20)); |
411 |
btnConnect.setBounds(366, 50, 100, 20); |
412 |
btnConnect.setText(PluginServices.getText(this, "conectar")); |
413 |
btnConnect.addActionListener(new java.awt.event.ActionListener() {
|
414 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
415 |
rellenarControles(); |
416 |
} |
417 |
}); |
418 |
} |
419 |
|
420 |
return btnConnect;
|
421 |
} |
422 |
|
423 |
/**
|
424 |
* This method initializes jPanel
|
425 |
*
|
426 |
* @return javax.swing.JPanel
|
427 |
*/
|
428 |
private javax.swing.JPanel getJPanel() {
|
429 |
if (jPanel == null) { |
430 |
jPanel = new javax.swing.JPanel();
|
431 |
jPanel.setLayout(null);
|
432 |
jPanel.setPreferredSize(new java.awt.Dimension(470, 130)); |
433 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
434 |
null, PluginServices.getText(this, "description"), |
435 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
436 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
437 |
jPanel.setBounds(2, 96, 477, 324); |
438 |
jPanel.add(getJLabel1(), null);
|
439 |
jPanel.add(getLblTitle(), null);
|
440 |
jPanel.add(getJScrollPane(), null);
|
441 |
} |
442 |
|
443 |
return jPanel;
|
444 |
} |
445 |
|
446 |
/**
|
447 |
* This method initializes jLabel1
|
448 |
*
|
449 |
* @return javax.swing.JLabel
|
450 |
*/
|
451 |
private javax.swing.JLabel getJLabel1() {
|
452 |
if (jLabel1 == null) { |
453 |
jLabel1 = new javax.swing.JLabel();
|
454 |
jLabel1.setText(PluginServices.getText(this, "name") + ":"); |
455 |
jLabel1.setBounds(37, 26, 40, 15); |
456 |
} |
457 |
|
458 |
return jLabel1;
|
459 |
} |
460 |
|
461 |
/**
|
462 |
* This method initializes lblTitle
|
463 |
*
|
464 |
* @return javax.swing.JLabel
|
465 |
*/
|
466 |
private javax.swing.JLabel getLblTitle() {
|
467 |
if (lblTitle == null) { |
468 |
lblTitle = new javax.swing.JLabel();
|
469 |
lblTitle.setText("-");
|
470 |
lblTitle.setPreferredSize(new java.awt.Dimension(350, 16)); |
471 |
lblTitle.setBounds(82, 26, 350, 16); |
472 |
} |
473 |
|
474 |
return lblTitle;
|
475 |
} |
476 |
|
477 |
/**
|
478 |
* This method initializes jScrollPane
|
479 |
*
|
480 |
* @return javax.swing.JScrollPane
|
481 |
*/
|
482 |
private javax.swing.JScrollPane getJScrollPane() {
|
483 |
if (jScrollPane == null) { |
484 |
jScrollPane = new javax.swing.JScrollPane();
|
485 |
jScrollPane.setViewportView(getTxtAbstract()); |
486 |
jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60)); |
487 |
jScrollPane.setBounds(10, 47, 450, 267); |
488 |
} |
489 |
|
490 |
return jScrollPane;
|
491 |
} |
492 |
|
493 |
/**
|
494 |
* This method initializes txtAbstract
|
495 |
*
|
496 |
* @return javax.swing.JTextArea
|
497 |
*/
|
498 |
private javax.swing.JTextArea getTxtAbstract() {
|
499 |
if (txtAbstract == null) { |
500 |
txtAbstract = new javax.swing.JTextArea();
|
501 |
txtAbstract.setWrapStyleWord(true);
|
502 |
txtAbstract.setColumns(30);
|
503 |
txtAbstract.setLineWrap(true);
|
504 |
} |
505 |
|
506 |
return txtAbstract;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* This method initializes panelPage1
|
511 |
*
|
512 |
* @return javax.swing.JPanel
|
513 |
*/
|
514 |
private javax.swing.JPanel getPanelPage1() {
|
515 |
if (panelPage1 == null) { |
516 |
panelPage1 = new javax.swing.JPanel();
|
517 |
panelPage1.setLayout(null);
|
518 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
519 |
panelPage1.setVisible(true);
|
520 |
panelPage1.setBounds(15, 5, 480, 427); |
521 |
panelPage1.add(getJPanel1(), null);
|
522 |
panelPage1.add(getJPanel(), null);
|
523 |
} |
524 |
|
525 |
return panelPage1;
|
526 |
} |
527 |
|
528 |
/**
|
529 |
* This method initializes btnSiguiente
|
530 |
*
|
531 |
* @return javax.swing.JButton
|
532 |
*/
|
533 |
private javax.swing.JButton getBtnSiguiente() {
|
534 |
if (btnSiguiente == null) { |
535 |
btnSiguiente = new javax.swing.JButton();
|
536 |
btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30)); |
537 |
btnSiguiente.setBounds(395, 444, 100, 20); |
538 |
btnSiguiente.setText(PluginServices.getText(this, "siguiente")); |
539 |
btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
|
540 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
541 |
if (page > firstPage) {
|
542 |
// si page es mayor que cero, vamos enfocando las
|
543 |
// sucesivas SOLAPAS del WCSParamsPanel
|
544 |
wmsParamsPanel.avanzaTab(); |
545 |
page = wmsParamsPanel.currentPage(); |
546 |
} |
547 |
page++; |
548 |
getPanelPage1().setVisible(false);
|
549 |
getPanelPage2().setVisible(true);
|
550 |
activarVisualizarBotones(); |
551 |
} |
552 |
}); |
553 |
} |
554 |
return btnSiguiente;
|
555 |
} |
556 |
|
557 |
/**
|
558 |
* This method initializes btnAnterior
|
559 |
*
|
560 |
* @return javax.swing.JButton
|
561 |
*/
|
562 |
private javax.swing.JButton getBtnAnterior() {
|
563 |
if (btnAnterior == null) { |
564 |
btnAnterior = new javax.swing.JButton();
|
565 |
btnAnterior.setText(PluginServices.getText(this, "anterior")); |
566 |
btnAnterior.setBounds(292, 444, 100, 20); |
567 |
btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30)); |
568 |
btnAnterior.addActionListener(new java.awt.event.ActionListener() {
|
569 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
570 |
page --; |
571 |
if (page > firstPage) {
|
572 |
// Tenemos que retroceder en el wcsParamsPanel
|
573 |
wmsParamsPanel.retrocedeTab(); |
574 |
page = wmsParamsPanel.currentPage() + 1;
|
575 |
activarVisualizarBotones(); |
576 |
} else if (page==firstPage){ |
577 |
activarVisualizarBotones(); |
578 |
page = firstPage +1;
|
579 |
//wmsParamsPanel.limpiaWizard();
|
580 |
getLblTitle().setText("-");
|
581 |
getTxtAbstract().setText("");
|
582 |
wmsParamsPanel.retrocedeTab(); |
583 |
getPanelPage1().setVisible(true);
|
584 |
getPanelPage2().setVisible(false);
|
585 |
getBtnSiguiente().setEnabled(false);
|
586 |
connected = false;
|
587 |
} |
588 |
listenerSupport.callStateChanged(wmsParamsPanel.isCorrectlyConfigured()); |
589 |
} |
590 |
}); |
591 |
} |
592 |
|
593 |
return btnAnterior;
|
594 |
} |
595 |
|
596 |
/**
|
597 |
* This method initializes jPanel1
|
598 |
*
|
599 |
* @return javax.swing.JPanel
|
600 |
*/
|
601 |
private javax.swing.JPanel getJPanel1() {
|
602 |
if (jPanel1 == null) { |
603 |
jPanel1 = new javax.swing.JPanel();
|
604 |
jPanel1.setLayout(null);
|
605 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
606 |
null, PluginServices.getText(this, "server"), |
607 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
608 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
609 |
jPanel1.setBounds(2, 5, 477, 85); |
610 |
jPanel1.add(getTxtHost(), null);
|
611 |
jPanel1.add(getBtnConnect(), null);
|
612 |
jPanel1.add(getChkCaching(), null);
|
613 |
} |
614 |
|
615 |
return jPanel1;
|
616 |
} |
617 |
|
618 |
/**
|
619 |
* DOCUMENT ME!
|
620 |
*
|
621 |
* @param listener
|
622 |
*/
|
623 |
public void addWizardListener(WizardListener listener) { |
624 |
listenerSupport.addWizardListener(listener); |
625 |
} |
626 |
|
627 |
/**
|
628 |
* DOCUMENT ME!
|
629 |
*
|
630 |
* @param listener
|
631 |
*/
|
632 |
public void removeWizardListener(WizardListener listener) { |
633 |
listenerSupport.removeWizardListener(listener); |
634 |
} |
635 |
|
636 |
/**
|
637 |
* DOCUMENT ME!
|
638 |
*
|
639 |
* @return
|
640 |
*/
|
641 |
// public WMSWizardDataSource getDataSource() {
|
642 |
// return dataSource;
|
643 |
// }
|
644 |
|
645 |
/**
|
646 |
* DOCUMENT ME!
|
647 |
*
|
648 |
* @param source
|
649 |
*/
|
650 |
// public void setDataSource(WMSWizardDataSource source) {
|
651 |
// dataSource = source;
|
652 |
// }
|
653 |
|
654 |
|
655 |
/**
|
656 |
* DOCUMENT ME!
|
657 |
*
|
658 |
* @return DOCUMENT ME!
|
659 |
*/
|
660 |
public String getSRS() { |
661 |
return wmsParamsPanel.getSRS();
|
662 |
} |
663 |
|
664 |
/**
|
665 |
* DOCUMENT ME!
|
666 |
*
|
667 |
* @return DOCUMENT ME!
|
668 |
*/
|
669 |
public String getFormat() { |
670 |
return wmsParamsPanel.getFormat();
|
671 |
} |
672 |
|
673 |
/**
|
674 |
* DOCUMENT ME!
|
675 |
*
|
676 |
* @return DOCUMENT ME!
|
677 |
*/
|
678 |
public TreePath[] getSelectedLayers() { |
679 |
return wmsParamsPanel.getSelectedLayers();
|
680 |
} |
681 |
|
682 |
/**
|
683 |
* DOCUMENT ME!
|
684 |
*
|
685 |
* @return DOCUMENT ME!
|
686 |
*/
|
687 |
public Rectangle2D getLayersRectangle() throws CannotReprojectException{ |
688 |
return wmsParamsPanel.getLayersRectangle();
|
689 |
} |
690 |
|
691 |
|
692 |
|
693 |
/**
|
694 |
* Devuelve el host que est? escrito en el cuadro de texto del host o null
|
695 |
* en caso de que no haya nada escrito o est? mal escrito
|
696 |
*
|
697 |
* @return URL del host
|
698 |
*/
|
699 |
public URL getHost() { |
700 |
try {
|
701 |
if ((cmbHost == null)|| (cmbHost.getModel().getSelectedItem() == null)) |
702 |
return new URL(dataSource.getHost()); |
703 |
else
|
704 |
return new URL(cmbHost.getModel().getSelectedItem().toString()); |
705 |
} catch (MalformedURLException e) { |
706 |
return null; |
707 |
} |
708 |
} |
709 |
|
710 |
/**
|
711 |
* DOCUMENT ME!
|
712 |
*
|
713 |
* @return Nombre de la capa que aparece en el TOC.
|
714 |
*/
|
715 |
public String getLayerName() { |
716 |
return wmsParamsPanel.getLayerName();
|
717 |
} |
718 |
|
719 |
|
720 |
public void initWizard() { |
721 |
dataSource = new WMSWizardData();
|
722 |
} |
723 |
|
724 |
public void execute() { |
725 |
|
726 |
} |
727 |
|
728 |
/**
|
729 |
* DOCUMENT ME!
|
730 |
*
|
731 |
* @return DOCUMENT ME!
|
732 |
*/
|
733 |
protected String getLayersQuery() { |
734 |
return wmsParamsPanel.getLayersQuery();
|
735 |
} |
736 |
|
737 |
public FLayer getLayer(){
|
738 |
|
739 |
if(wmsParamsPanel.getDisagregatedLayers()){
|
740 |
return getLayerTree();
|
741 |
}else{
|
742 |
return getLayerPlain();
|
743 |
} |
744 |
} |
745 |
|
746 |
// private Object[] getFullPath(String name){
|
747 |
// Vector path = new Vector();
|
748 |
// WMSLayerNode layerNode;
|
749 |
// WMSLayerNode parent;
|
750 |
// for (int i = 0; i <wmsParamsPanel.getLstSelectedLayers().getModel().getSize(); i++) {
|
751 |
// layerNode = (WMSLayerNode)wmsParamsPanel.getLstSelectedLayers().getModel().getElementAt(i);
|
752 |
// if(layerNode.getName().compareTo( name ) == 0 ){
|
753 |
// path.add(layerNode);
|
754 |
// parent = (WMSLayerNode)layerNode.getParent().clone();
|
755 |
// while ( parent != null){
|
756 |
// path.add(parent);
|
757 |
// parent = (WMSLayerNode)parent.getParent().clone();
|
758 |
// }
|
759 |
// }
|
760 |
// }
|
761 |
// return path.toArray();
|
762 |
// }
|
763 |
|
764 |
/**
|
765 |
* If user does not select the chekbox Disagregate layers, will get the layer tree in WMS
|
766 |
* @return
|
767 |
*/
|
768 |
protected FLayer getLayerTree() {
|
769 |
String[] layerNames = getLayersQuery().split(","); |
770 |
LayerTree layerTree = wmsParamsPanel.getLayerStructure(); |
771 |
// try{
|
772 |
// for (int i = 0; i < layerNames.length; i++) {
|
773 |
// TreePath path = new TreePath(getFullPath(layerNames[i]));
|
774 |
// layerTree.addSelectionPath(path);
|
775 |
// }
|
776 |
// }catch(Exception e){
|
777 |
// e.printStackTrace();
|
778 |
// }
|
779 |
TreePath[] selection = (TreePath[])wmsParamsPanel.getSelectedPaths().toArray(new TreePath[0]);//layerTree.getSelectionPaths(); |
780 |
if (selection!=null){ |
781 |
return getSubTree((WMSLayerNode)layerTree.getModel().getRoot(), selection);
|
782 |
} |
783 |
return null; |
784 |
} |
785 |
|
786 |
protected boolean nodeSelected(TreePath[] selection, WMSLayerNode node){ |
787 |
for (int i = 0; i < selection.length; i++) { |
788 |
Object[] components = selection[i].getPath(); |
789 |
for (int j=0; j < components.length ; j++) |
790 |
{ |
791 |
if (components[j] instanceof WMSLayerNode){ |
792 |
if (((WMSLayerNode)components[j]).getTitle().compareTo(node.getTitle()) == 0){ |
793 |
return true; |
794 |
} |
795 |
} |
796 |
} |
797 |
} |
798 |
return false; |
799 |
} |
800 |
|
801 |
protected FLayer getSubTree(WMSLayerNode node, TreePath[] selection) |
802 |
{ |
803 |
if (node.getChildren().size() > 0) |
804 |
{ |
805 |
//com.iver.cit.gvsig.gui.View v = (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
|
806 |
FLayers l = new FLayers(this.getMapCtrl().getMapContext(), null); |
807 |
l.setName(node.getTitle()); |
808 |
for(int i = 0; i < node.getChildren().size(); i++ ){ |
809 |
if (nodeSelected(selection, (WMSLayerNode)(node.getChildren().get(i))))
|
810 |
{ |
811 |
FLayer lyr = getSubTree((WMSLayerNode)node.getChildren().get(i), selection); |
812 |
if(lyr != null){ |
813 |
l.addLayer(lyr); |
814 |
} |
815 |
} |
816 |
} |
817 |
return l;
|
818 |
} |
819 |
else{
|
820 |
if (nodeSelected(selection, node))
|
821 |
{ |
822 |
FLyrWMS layer = new FLyrWMS();
|
823 |
layer.setHost(getHost()); |
824 |
try {
|
825 |
layer.setFullExtent(getLayersRectangle()); |
826 |
} catch (CannotReprojectException e) {
|
827 |
e.printStackTrace(); |
828 |
return null; |
829 |
} |
830 |
// layer.setFormat(getFormat());
|
831 |
// layer.setLayerQuery(node.getName());
|
832 |
// layer.setInfoLayerQuery(getQueryableLayerQuery());
|
833 |
// layer.setSRS(getSRS());
|
834 |
// layer.setName(node.getTitle());
|
835 |
// layer.setWmsTransparency(getTransparency());
|
836 |
// layer.setStyles(getStyles());
|
837 |
// layer.setQueryable(isQueryable());
|
838 |
// return layer;
|
839 |
|
840 |
layer.setFormat(getFormat()); |
841 |
layer.setLayerQuery(getLayersQuery()); |
842 |
layer.setInfoLayerQuery(getQueryableLayerQuery()); |
843 |
layer.setSRS(getSRS()); |
844 |
layer.setName(node.getName()); |
845 |
layer.setWmsTransparency(getTransparency()); |
846 |
layer.setStyles(getStyles()); |
847 |
layer.setDimensions(getDimensions()); |
848 |
layer.setDriver(getDriver()); |
849 |
layer.setOnlineResources(getOnlineResources()); |
850 |
layer.setFixedSize(getFixedSize()); |
851 |
layer.setQueryable(isQueryable()); |
852 |
|
853 |
return layer;
|
854 |
|
855 |
}else{
|
856 |
return null; |
857 |
} |
858 |
} |
859 |
} |
860 |
|
861 |
/**
|
862 |
* If user selects the chekbox Disagregate layers, will get the selected layers rendered in one
|
863 |
* the tree structure in WMS will be lost.
|
864 |
* @return
|
865 |
*/
|
866 |
protected FLayer getLayerPlain(){
|
867 |
FLyrWMS layer = new FLyrWMS();
|
868 |
layer.setHost(getHost()); |
869 |
try{
|
870 |
layer.setFullExtent(getLayersRectangle()); |
871 |
}catch(CannotReprojectException ex)
|
872 |
{ |
873 |
ex.printStackTrace(); |
874 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), ex.getMessage()); |
875 |
return null; |
876 |
} |
877 |
layer.setFormat(getFormat()); |
878 |
layer.setLayerQuery(getLayersQuery()); |
879 |
layer.setInfoLayerQuery(getQueryableLayerQuery()); |
880 |
layer.setSRS(getSRS()); |
881 |
layer.setName(getLayerName()); |
882 |
layer.setWmsTransparency(getTransparency()); |
883 |
layer.setStyles(getStyles()); |
884 |
layer.setDimensions(getDimensions()); |
885 |
layer.setDriver(getDriver()); |
886 |
layer.setOnlineResources(getOnlineResources()); |
887 |
layer.setFixedSize(getFixedSize()); |
888 |
layer.setQueryable(isQueryable()); |
889 |
return layer;
|
890 |
} |
891 |
|
892 |
protected boolean isQueryable() { |
893 |
return dataSource.isQueryable();
|
894 |
} |
895 |
|
896 |
protected Dimension getFixedSize() { |
897 |
return wmsParamsPanel.getFixedSize();
|
898 |
} |
899 |
|
900 |
private Hashtable getOnlineResources() { |
901 |
return wmsParamsPanel.getOnlineResources();
|
902 |
} |
903 |
|
904 |
protected FMapWMSDriver getDriver() {
|
905 |
return wmsParamsPanel.getDriver();
|
906 |
} |
907 |
|
908 |
/**
|
909 |
* @return
|
910 |
*/
|
911 |
protected Vector getStyles() { |
912 |
return wmsParamsPanel.getStyles();
|
913 |
} |
914 |
|
915 |
protected Vector getDimensions() { |
916 |
return wmsParamsPanel.getDimensions();
|
917 |
} |
918 |
|
919 |
/**
|
920 |
* @return
|
921 |
*/
|
922 |
protected boolean getTransparency() { |
923 |
return wmsParamsPanel.getTransparency();
|
924 |
} |
925 |
|
926 |
/**
|
927 |
* DOCUMENT ME!
|
928 |
*
|
929 |
* @return DOCUMENT ME!
|
930 |
*/
|
931 |
public String getQueryableLayerQuery() { |
932 |
return wmsParamsPanel.getQueryableLayerQuery();
|
933 |
} |
934 |
|
935 |
/**
|
936 |
* This method initializes chkCaching
|
937 |
*
|
938 |
* @return javax.swing.JCheckBox
|
939 |
*/
|
940 |
private JCheckBox getChkCaching() { |
941 |
if (chkCaching == null) { |
942 |
chkCaching = new JCheckBox(); |
943 |
chkCaching.setBounds(7, 51, 349, 20); |
944 |
chkCaching.setText(PluginServices.getText(this, "refresh_capabilities")); |
945 |
chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip")); |
946 |
chkCaching.setSelected(refreshing); |
947 |
chkCaching.addItemListener(new java.awt.event.ItemListener() {
|
948 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
949 |
refreshing = chkCaching.isSelected(); |
950 |
} |
951 |
}); |
952 |
chkCaching.addActionListener(new java.awt.event.ActionListener() {
|
953 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
954 |
fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
|
955 |
} |
956 |
}); |
957 |
|
958 |
} |
959 |
return chkCaching;
|
960 |
} |
961 |
} // @jve:decl-index=0:visual-constraint="10,10"
|