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