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