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