gvsig-raster / org.gvsig.raster.wcs / trunk / org.gvsig.raster.wcs / org.gvsig.raster.wcs.app.wcsclient / src / main / java / org / gvsig / raster / wcs / app / wcsclient / gui / wizard / WCSWizard.java @ 1979
History | View | Annotate | Download (25.8 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
package org.gvsig.raster.wcs.app.wcsclient.gui.wizard; |
24 |
|
25 |
import java.awt.Component; |
26 |
import java.awt.FlowLayout; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
import java.awt.geom.Rectangle2D; |
30 |
import java.io.IOException; |
31 |
import java.net.MalformedURLException; |
32 |
import java.net.URL; |
33 |
import java.util.prefs.Preferences; |
34 |
|
35 |
import javax.swing.DefaultComboBoxModel; |
36 |
import javax.swing.JButton; |
37 |
import javax.swing.JCheckBox; |
38 |
import javax.swing.JLabel; |
39 |
import javax.swing.JOptionPane; |
40 |
import javax.swing.JPanel; |
41 |
import javax.swing.JScrollPane; |
42 |
import javax.swing.JTextArea; |
43 |
|
44 |
import org.cresques.cts.IProjection; |
45 |
import org.gvsig.andami.PluginServices; |
46 |
import org.gvsig.andami.persistence.serverData.ServerDataPersistence; |
47 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
48 |
import org.gvsig.app.gui.WizardPanel; |
49 |
import org.gvsig.app.gui.wizards.WizardListener; |
50 |
import org.gvsig.app.gui.wizards.WizardListenerSupport; |
51 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
52 |
import org.gvsig.compat.net.ICancellable; |
53 |
import org.gvsig.fmap.dal.DALLocator; |
54 |
import org.gvsig.fmap.dal.DataManager; |
55 |
import org.gvsig.fmap.dal.DataStoreParameters; |
56 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
57 |
import org.gvsig.fmap.dal.exception.InitializeException; |
58 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
59 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
60 |
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException; |
61 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
62 |
import org.gvsig.gui.beans.Messages; |
63 |
import org.gvsig.raster.cache.tile.TileCacheLibrary; |
64 |
import org.gvsig.raster.util.CancelTaskImpl; |
65 |
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.WCSParamsPanel; |
66 |
import org.gvsig.raster.wcs.io.WCSServerExplorer; |
67 |
import org.gvsig.raster.wcs.io.WCSServerExplorerParameters; |
68 |
import org.gvsig.utils.NotExistInXMLEntity; |
69 |
import org.gvsig.utils.XMLEntity; |
70 |
import org.gvsig.utils.swing.jcomboServer.JComboServer; |
71 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
72 |
import org.slf4j.Logger; |
73 |
import org.slf4j.LoggerFactory; |
74 |
|
75 |
|
76 |
|
77 |
/**
|
78 |
* The WCS properties container panel.
|
79 |
*
|
80 |
* @author Jaume Dominguez Faus
|
81 |
*/
|
82 |
public class WCSWizard extends WizardPanel implements ActionListener { |
83 |
final static private Logger logger = LoggerFactory.getLogger(WCSWizard.class); |
84 |
private static final long serialVersionUID = 1L; |
85 |
protected int page = 0; |
86 |
protected boolean connected = false; |
87 |
private JComboServer cmbHost = null; |
88 |
private JButton btnConnect = null; |
89 |
private JButton btnCancel = null; |
90 |
private JPanel jPanel = null; |
91 |
private JLabel jLabel1 = null; |
92 |
private JLabel lblTitle = null; |
93 |
private JScrollPane jScrollPane = null; |
94 |
private JTextArea txtAbstract = null; |
95 |
private JPanel panelPage1 = null; |
96 |
private JButton btnSiguiente = null; |
97 |
private JButton btnAnterior = null; |
98 |
private JPanel jPanel1 = null; |
99 |
protected WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
100 |
protected WCSParamsPanel wcsParamsPanel = null; |
101 |
protected JLabel lblServerType = null; |
102 |
protected JLabel lblServerTypeValue = null; |
103 |
private JCheckBox chkCaching = null; |
104 |
private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
105 |
private boolean usingTileCache = fPrefs.getBoolean("tile_cache", false); |
106 |
private JCheckBox chkTileCache = null; |
107 |
private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false); |
108 |
protected int firstPage = 0; |
109 |
private JPanel pnlName = null; |
110 |
private IProjection proj = null; |
111 |
private ICancellable cancel = null; |
112 |
private WCSServerExplorer explorer = null; |
113 |
|
114 |
|
115 |
public WCSWizard (WCSParamsPanel params) {
|
116 |
super();
|
117 |
firstPage = 1;
|
118 |
page = firstPage; |
119 |
this.wcsParamsPanel = params;
|
120 |
this.explorer = wcsParamsPanel.getExplorer();
|
121 |
|
122 |
setTabName("WCS");
|
123 |
lblServerType = new JLabel(); |
124 |
lblServerType.setBounds(20, 444, 100, 20); |
125 |
lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
126 |
lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
127 |
lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); |
128 |
lblServerType.setText(PluginServices.getText(this, "server_type")+":"); |
129 |
lblServerTypeValue = new JLabel(); |
130 |
lblServerTypeValue.setBounds(128, 444, 148, 20); |
131 |
lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11)); |
132 |
lblServerTypeValue.setText("-");
|
133 |
this.setSize(510, 468); |
134 |
this.setLayout(null); |
135 |
this.setPreferredSize(new java.awt.Dimension(750, 420)); |
136 |
this.setVisible(true); |
137 |
|
138 |
wcsParamsPanel.setListenerSupport(this.listenerSupport);
|
139 |
wcsParamsPanel.setBounds(0, 5, 510, 428); |
140 |
wcsParamsPanel.getJTabbedPane().addMouseListener( |
141 |
new java.awt.event.MouseAdapter() {
|
142 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
143 |
page = wcsParamsPanel.currentPage() + 1;
|
144 |
activarVisualizarBotones(); |
145 |
} |
146 |
}); |
147 |
this.add(wcsParamsPanel, null); |
148 |
this.add(lblServerType, null); |
149 |
this.add(lblServerTypeValue, null); |
150 |
getWCSParamsPanel().setVisible(true);
|
151 |
|
152 |
connected = true;
|
153 |
} |
154 |
|
155 |
/**
|
156 |
* This is the default constructor
|
157 |
*/
|
158 |
public WCSWizard() {
|
159 |
super();
|
160 |
firstPage = 0;
|
161 |
page = firstPage; |
162 |
initialize(); |
163 |
|
164 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows();
|
165 |
for (int i = 0; i < windows.length; i++) { |
166 |
if(windows[i] instanceof AbstractViewPanel) |
167 |
proj = ((AbstractViewPanel)windows[i]).getProjection(); |
168 |
} |
169 |
cancel = new CancelTaskImpl();
|
170 |
} |
171 |
/**
|
172 |
* This method initializes this
|
173 |
*/
|
174 |
private void initialize() { |
175 |
setTabName("WCS");
|
176 |
|
177 |
lblServerType = new JLabel(); |
178 |
lblServerType.setBounds(20, 444, 100, 20); |
179 |
lblServerType.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
180 |
lblServerType.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
181 |
lblServerType.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); |
182 |
lblServerType.setText(PluginServices.getText(this, "server_type")+":"); |
183 |
lblServerTypeValue = new JLabel(); |
184 |
lblServerTypeValue.setBounds(128, 444, 148, 20); |
185 |
lblServerTypeValue.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 11)); |
186 |
lblServerTypeValue.setText("-");
|
187 |
this.setSize(510, 468); |
188 |
this.setLayout(null); |
189 |
this.setPreferredSize(new java.awt.Dimension(750, 420)); |
190 |
this.setVisible(true); |
191 |
this.add(getPanelPage1(), null); |
192 |
this.add(getWCSParamsPanel(), null); |
193 |
this.add(getBtnAnterior(), null); |
194 |
this.add(getBtnSiguiente(), null); |
195 |
this.add(lblServerType, null); |
196 |
this.add(lblServerTypeValue, null); |
197 |
activarVisualizarBotones(); |
198 |
} |
199 |
|
200 |
|
201 |
protected JPanel getWCSParamsPanel(){ |
202 |
if (wcsParamsPanel == null){ |
203 |
wcsParamsPanel = new WCSParamsPanel();
|
204 |
wcsParamsPanel.setListenerSupport(this.listenerSupport);
|
205 |
wcsParamsPanel.setBounds(0, 5, 510, 428); |
206 |
wcsParamsPanel.getJTabbedPane().addMouseListener( |
207 |
new java.awt.event.MouseAdapter() {
|
208 |
public void mouseClicked(java.awt.event.MouseEvent e) { |
209 |
page = wcsParamsPanel.currentPage() + 1;
|
210 |
activarVisualizarBotones(); |
211 |
} |
212 |
}); |
213 |
} |
214 |
return wcsParamsPanel;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* This method checks for the options selected within the configuration
|
219 |
* dialog are correct.
|
220 |
*
|
221 |
* @return true if you're done, false if not.
|
222 |
*/
|
223 |
public boolean areSettingsValid() { |
224 |
return wcsParamsPanel.isCorrectlyConfigured();
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* DOCUMENT ME!
|
229 |
*
|
230 |
* @param host DOCUMENT ME!
|
231 |
*/
|
232 |
private void addHost(String host) { |
233 |
host = host.trim(); |
234 |
|
235 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WCS); |
236 |
persistence.addServerData(new ServerData(host, ServerData.SERVER_TYPE_WCS));
|
237 |
persistence.setPersistent(); |
238 |
} |
239 |
|
240 |
/**
|
241 |
* Thread to connect to a WCS server
|
242 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
243 |
*/
|
244 |
public class ConnectThread extends Thread { |
245 |
private ICancellable cancel = null; |
246 |
private WCSServerExplorer explorer = null; |
247 |
private WCSWizard wizard = null; |
248 |
|
249 |
public ConnectThread(ICancellable cancel, WCSServerExplorer explorer, WCSWizard wizard) {
|
250 |
this.cancel = cancel;
|
251 |
this.explorer = explorer;
|
252 |
this.wizard = wizard;
|
253 |
} |
254 |
|
255 |
public void run() { |
256 |
if(!checkHostAndNetwork())
|
257 |
return;
|
258 |
|
259 |
try {
|
260 |
explorer.connect(cancel); |
261 |
} catch (RemoteServiceException e) {
|
262 |
String msg = e.getMessage() + " : " + getIOExceptionMessage(e); |
263 |
logger.info(msg, e); |
264 |
JOptionPane.showMessageDialog(getWCSParamsPanel(), msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
265 |
return;
|
266 |
} finally {
|
267 |
((CancelTaskImpl)cancel).setCanceled(false);
|
268 |
} |
269 |
|
270 |
//storeParams = (WCSDataParameters)explorer.getStoreParameters();
|
271 |
|
272 |
wizard.rellenarControles(); |
273 |
} |
274 |
|
275 |
/**
|
276 |
* Gets the <code>IOException</code> message. The message
|
277 |
* of this exception is returned by the server
|
278 |
* @param e
|
279 |
* @return
|
280 |
*/
|
281 |
private String getIOExceptionMessage(Exception e) { |
282 |
Throwable ex = e;
|
283 |
final int MAX_DEEP = 10; |
284 |
int deep = 0; |
285 |
while(deep < MAX_DEEP) {
|
286 |
Throwable t = null; |
287 |
if(ex instanceof IOException) { |
288 |
return ex.getMessage();
|
289 |
} else if(ex instanceof RemoteServiceException) { |
290 |
t = ex.getCause(); |
291 |
} |
292 |
if(t == null) |
293 |
return null; |
294 |
else
|
295 |
ex = t; |
296 |
deep++; |
297 |
} |
298 |
return null; |
299 |
} |
300 |
} |
301 |
|
302 |
/**
|
303 |
* Checks if the network and host are reachable
|
304 |
* @return true if both are reachable and false if they are not
|
305 |
*/
|
306 |
private boolean checkHostAndNetwork() { |
307 |
if(!explorer.isHostReachable()) {
|
308 |
JOptionPane.showMessageDialog(null, Messages.getText("host_unreachable"), Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
309 |
logger.info(Messages.getText("host_unreachable"));
|
310 |
return false; |
311 |
} |
312 |
return true; |
313 |
} |
314 |
|
315 |
/**
|
316 |
* DOCUMENT ME!
|
317 |
*/
|
318 |
private void rellenarControles() { |
319 |
try {
|
320 |
String host = cmbHost.getModel().getSelectedItem().toString();
|
321 |
|
322 |
lblTitle.setText(explorer.getTitle()); |
323 |
lblServerTypeValue.setText(explorer.getServerType()); |
324 |
txtAbstract.setText(explorer.getAbstract()); |
325 |
|
326 |
addHost(host); |
327 |
wcsParamsPanel.setWizardData(explorer); |
328 |
connected = true;
|
329 |
activarVisualizarBotones(); |
330 |
} catch (Exception e) { |
331 |
if (e.getMessage()==null) { |
332 |
txtAbstract.setText(PluginServices.getText(this,"error")); |
333 |
} else {
|
334 |
txtAbstract.setText(e.getMessage()); |
335 |
} |
336 |
listenerSupport.callError(e); |
337 |
getBtnSiguiente().setEnabled(false);
|
338 |
getBtnAnterior().setEnabled(true);
|
339 |
} finally {
|
340 |
getBtnCancel().setEnabled(false);
|
341 |
} |
342 |
} |
343 |
|
344 |
@SuppressWarnings("deprecation") |
345 |
public void actionPerformed(ActionEvent e) { |
346 |
if(e.getSource() == getBtnConnect()) {
|
347 |
getBtnCancel().setEnabled(true);
|
348 |
getTxtAbstract().setText("Trying to connect...");
|
349 |
String host = cmbHost.getModel().getSelectedItem().toString();
|
350 |
try {
|
351 |
DataManager datamanager = DALLocator.getDataManager(); |
352 |
WCSServerExplorerParameters explorerParams = (WCSServerExplorerParameters) datamanager.createServerExplorerParameters(WCSServerExplorer.NAME); |
353 |
explorerParams.setHost(host); |
354 |
|
355 |
explorer = (WCSServerExplorer) datamanager.createServerExplorer(explorerParams); |
356 |
|
357 |
((CancelTaskImpl)cancel).setCanceled(false);
|
358 |
new ConnectThread(cancel, explorer, this).start(); |
359 |
|
360 |
} catch (InitializeException e1) {
|
361 |
getTxtAbstract().setText("Error creating WCS layer");
|
362 |
} catch (ProviderNotRegisteredException e1) {
|
363 |
getTxtAbstract().setText("Provider not registered. I cannot connect.");
|
364 |
} catch (ValidateDataParametersException e1) {
|
365 |
getTxtAbstract().setText("Parameters not valid. I cannot connect.");
|
366 |
} |
367 |
} |
368 |
|
369 |
if(e.getSource() == getBtnCancel()) {
|
370 |
getTxtAbstract().setText("Cancelled...");
|
371 |
((CancelTaskImpl)cancel).setCanceled(true);
|
372 |
getBtnCancel().setEnabled(false);
|
373 |
} |
374 |
} |
375 |
|
376 |
/**
|
377 |
* DOCUMENT ME!
|
378 |
*/
|
379 |
protected void activarVisualizarBotones() { |
380 |
if (page == firstPage) {
|
381 |
getBtnAnterior().setEnabled(false);
|
382 |
getBtnSiguiente().setVisible(true);
|
383 |
|
384 |
if (connected) {
|
385 |
getBtnSiguiente().setEnabled(true);
|
386 |
} else {
|
387 |
getBtnSiguiente().setEnabled(false);
|
388 |
} |
389 |
} else if (page < wcsParamsPanel.getNumTabs()) { |
390 |
getBtnSiguiente().setEnabled(true);
|
391 |
getBtnSiguiente().setVisible(true);
|
392 |
getBtnAnterior().setEnabled(true);
|
393 |
getBtnAnterior().setVisible(true);
|
394 |
if (wcsParamsPanel.nextEnabledPage()==-1){ |
395 |
getBtnSiguiente().setEnabled(false);
|
396 |
} |
397 |
listenerSupport.callStateChanged(wcsParamsPanel.isCorrectlyConfigured()); |
398 |
} else if (page == wcsParamsPanel.getNumTabs()) { |
399 |
getBtnSiguiente().setVisible(false);
|
400 |
getBtnSiguiente().setEnabled(false);
|
401 |
listenerSupport.callStateChanged(wcsParamsPanel.isCorrectlyConfigured()); |
402 |
} |
403 |
} |
404 |
|
405 |
/**
|
406 |
* This method initializes txtHost
|
407 |
*
|
408 |
* @return javax.swing.JTextField
|
409 |
*/
|
410 |
private javax.swing.JComboBox getTxtHost() {
|
411 |
if (cmbHost == null) { |
412 |
cmbHost = new JComboServer();
|
413 |
cmbHost.setModel(new DefaultComboBoxModel()); |
414 |
cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
415 |
cmbHost.setBounds(11, 26, 454, 20); |
416 |
cmbHost.setEditable(true);
|
417 |
|
418 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WCS); |
419 |
ServerData[] servers = persistence.getArrayOfServerData();
|
420 |
|
421 |
if (servers.length == 0){ |
422 |
PluginServices ps = PluginServices.getPluginServices(this);
|
423 |
XMLEntity xml = ps.getPersistentXML(); |
424 |
try {
|
425 |
String[] oldServers = xml.getStringArrayProperty("wcs-servers"); |
426 |
servers = new ServerData[oldServers.length];
|
427 |
for (int i=0; i<oldServers.length; i++) { |
428 |
servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WCS);
|
429 |
} |
430 |
xml.remove("wcs-servers");
|
431 |
ps.setPersistentXML(xml); |
432 |
} catch (NotExistInXMLEntity e) {
|
433 |
// Old servers doesn't exist
|
434 |
servers = new ServerData[2]; |
435 |
servers[0] = new ServerData("http://maps.gdal.org/cgi-bin/mapserv_dem",ServerData.SERVER_TYPE_WCS); |
436 |
servers[1] = new ServerData("http://inspire.cop.gva.es/mapserver/wcs",ServerData.SERVER_TYPE_WCS); |
437 |
} |
438 |
|
439 |
for (int i=0 ; i<servers.length ; i++){ |
440 |
persistence.addServerData(servers[i]); |
441 |
} |
442 |
persistence.setPersistent(); |
443 |
} |
444 |
|
445 |
cmbHost.setServerList(servers); |
446 |
} |
447 |
|
448 |
return cmbHost;
|
449 |
} |
450 |
|
451 |
/**
|
452 |
* This method initializes btnDetalles
|
453 |
*
|
454 |
* @return javax.swing.JButton
|
455 |
*/
|
456 |
private JButton getBtnConnect() { |
457 |
if (btnConnect == null) { |
458 |
btnConnect = new JButton(); |
459 |
btnConnect.setPreferredSize(new java.awt.Dimension(100, 20)); |
460 |
btnConnect.setBounds(262, 50, 100, 20); |
461 |
btnConnect.setText(PluginServices.getText(this, "conectar")); |
462 |
btnConnect.addActionListener(this);
|
463 |
} |
464 |
|
465 |
return btnConnect;
|
466 |
} |
467 |
|
468 |
/**
|
469 |
* This method initializes btnDetalles
|
470 |
*
|
471 |
* @return javax.swing.JButton
|
472 |
*/
|
473 |
private JButton getBtnCancel() { |
474 |
if (btnCancel == null) { |
475 |
btnCancel = new JButton(); |
476 |
btnCancel.setEnabled(false);
|
477 |
btnCancel.setPreferredSize(new java.awt.Dimension(100, 20)); |
478 |
btnCancel.setBounds(366, 50, 100, 20); |
479 |
btnCancel.setText(PluginServices.getText(this, "cancel")); |
480 |
btnCancel.addActionListener(this);
|
481 |
} |
482 |
|
483 |
return btnCancel;
|
484 |
} |
485 |
|
486 |
/**
|
487 |
* This method initializes jPanel
|
488 |
*
|
489 |
* @return javax.swing.JPanel
|
490 |
*/
|
491 |
private javax.swing.JPanel getJPanel() {
|
492 |
if (jPanel == null) { |
493 |
jPanel = new javax.swing.JPanel();
|
494 |
jPanel.setLayout(null);
|
495 |
jPanel.setPreferredSize(new java.awt.Dimension(470, 130)); |
496 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
497 |
null, PluginServices.getText(this, "description"), |
498 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
499 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
500 |
jPanel.setBounds(2, 116, 477, 304); |
501 |
|
502 |
jPanel.add(getJScrollPane(), null);
|
503 |
jPanel.add(getPnlName(), null);
|
504 |
} |
505 |
|
506 |
return jPanel;
|
507 |
} |
508 |
|
509 |
/**
|
510 |
* This method initializes jLabel1
|
511 |
*
|
512 |
* @return javax.swing.JLabel
|
513 |
*/
|
514 |
private javax.swing.JLabel getJLabel1() {
|
515 |
if (jLabel1 == null) { |
516 |
jLabel1 = new javax.swing.JLabel();
|
517 |
jLabel1.setText(PluginServices.getText(this, "name") + ":"); |
518 |
} |
519 |
|
520 |
return jLabel1;
|
521 |
} |
522 |
|
523 |
/**
|
524 |
* This method initializes lblTitle
|
525 |
*
|
526 |
* @return javax.swing.JLabel
|
527 |
*/
|
528 |
private javax.swing.JLabel getLblTitle() {
|
529 |
if (lblTitle == null) { |
530 |
lblTitle = new javax.swing.JLabel();
|
531 |
lblTitle.setText("-");
|
532 |
} |
533 |
|
534 |
return lblTitle;
|
535 |
} |
536 |
|
537 |
/**
|
538 |
* This method initializes jScrollPane
|
539 |
*
|
540 |
* @return javax.swing.JScrollPane
|
541 |
*/
|
542 |
private javax.swing.JScrollPane getJScrollPane() {
|
543 |
if (jScrollPane == null) { |
544 |
jScrollPane = new javax.swing.JScrollPane();
|
545 |
jScrollPane.setViewportView(getTxtAbstract()); |
546 |
jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60)); |
547 |
jScrollPane.setBounds(10, 47, 457, 247); |
548 |
} |
549 |
|
550 |
return jScrollPane;
|
551 |
} |
552 |
|
553 |
/**
|
554 |
* This method initializes txtAbstract
|
555 |
*
|
556 |
* @return javax.swing.JTextArea
|
557 |
*/
|
558 |
private javax.swing.JTextArea getTxtAbstract() {
|
559 |
if (txtAbstract == null) { |
560 |
txtAbstract = new javax.swing.JTextArea();
|
561 |
txtAbstract.setWrapStyleWord(true);
|
562 |
txtAbstract.setColumns(30);
|
563 |
txtAbstract.setLineWrap(true);
|
564 |
} |
565 |
|
566 |
return txtAbstract;
|
567 |
} |
568 |
|
569 |
private javax.swing.JPanel getPanelPage1() {
|
570 |
if (panelPage1 == null) { |
571 |
panelPage1 = new JPanel(); |
572 |
panelPage1.setLayout(null);
|
573 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
574 |
panelPage1.setVisible(true);
|
575 |
panelPage1.setBounds(15, 5, 480, 427); |
576 |
panelPage1.add(getJPanel1(), null);
|
577 |
panelPage1.add(getJPanel(), null);
|
578 |
} |
579 |
|
580 |
return panelPage1;
|
581 |
} |
582 |
|
583 |
|
584 |
/**
|
585 |
* This method initializes btnSiguiente
|
586 |
*
|
587 |
* @return javax.swing.JButton
|
588 |
*/
|
589 |
private javax.swing.JButton getBtnSiguiente() {
|
590 |
if (btnSiguiente == null) { |
591 |
btnSiguiente = new JButton(); |
592 |
btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30)); |
593 |
btnSiguiente.setBounds(395, 444, 100, 20); |
594 |
btnSiguiente.setText(PluginServices.getText(this, "siguiente")); |
595 |
btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
|
596 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
597 |
if(page == firstPage && getChkTileCache().isSelected()) {
|
598 |
messageBoxInfo("remote_service_tiled", TileCacheLibrary.ALTERNATIVE_TILESIZE + "", this); |
599 |
} |
600 |
if (page > firstPage) {
|
601 |
// si page es mayor que cero, vamos enfocando las
|
602 |
// sucesivas SOLAPAS del WCSParamsPanel
|
603 |
wcsParamsPanel.avanzaTab(); |
604 |
page = wcsParamsPanel.currentPage(); |
605 |
} |
606 |
page++; |
607 |
getPanelPage1().setVisible(false);
|
608 |
getWCSParamsPanel().setVisible(true);
|
609 |
activarVisualizarBotones(); |
610 |
} |
611 |
}); |
612 |
} |
613 |
return btnSiguiente;
|
614 |
} |
615 |
|
616 |
/**
|
617 |
* Shows an information dialog with a text and a accept button
|
618 |
* @param msg Message to show in the dialog
|
619 |
* @param parentWindow Parent window
|
620 |
*/
|
621 |
public static void messageBoxInfo(String msg, String fixedText, Object parentWindow){ |
622 |
String string = PluginServices.getText(parentWindow, "accept"); |
623 |
Object[] options = {string}; |
624 |
JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
625 |
"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + " " + fixedText + "</html>", |
626 |
PluginServices.getText(parentWindow, "confirmacion"),
|
627 |
JOptionPane.OK_OPTION,
|
628 |
JOptionPane.INFORMATION_MESSAGE,
|
629 |
null,
|
630 |
options, |
631 |
string); |
632 |
} |
633 |
|
634 |
/**
|
635 |
* This method initializes btnAnterior
|
636 |
*
|
637 |
* @return javax.swing.JButton
|
638 |
*/
|
639 |
private javax.swing.JButton getBtnAnterior() {
|
640 |
if (btnAnterior == null) { |
641 |
btnAnterior = new JButton(); |
642 |
btnAnterior.setBounds(292, 444, 100, 20); |
643 |
btnAnterior.setPreferredSize(new java.awt.Dimension(100, 30)); |
644 |
btnAnterior.setText(PluginServices.getText(this, "anterior")); |
645 |
btnAnterior.addActionListener(new java.awt.event.ActionListener() {
|
646 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
647 |
page --; |
648 |
if (page > firstPage) {
|
649 |
// Tenemos que retroceder en el wcsParamsPanel
|
650 |
wcsParamsPanel.retrocedeTab(); |
651 |
page = wcsParamsPanel.currentPage() + 1;
|
652 |
activarVisualizarBotones(); |
653 |
} else if (page==firstPage){ |
654 |
activarVisualizarBotones(); |
655 |
page = firstPage +1;
|
656 |
getLblTitle().setText("-");
|
657 |
getTxtAbstract().setText("");
|
658 |
wcsParamsPanel.retrocedeTab(); |
659 |
getPanelPage1().setVisible(true);
|
660 |
getWCSParamsPanel().setVisible(false);
|
661 |
getBtnSiguiente().setEnabled(false);
|
662 |
connected = false;
|
663 |
} |
664 |
listenerSupport.callStateChanged(wcsParamsPanel.isCorrectlyConfigured()); |
665 |
} |
666 |
}); |
667 |
} |
668 |
|
669 |
return btnAnterior;
|
670 |
} |
671 |
|
672 |
private javax.swing.JPanel getJPanel1() {
|
673 |
if (jPanel1 == null) { |
674 |
jPanel1 = new javax.swing.JPanel();
|
675 |
jPanel1.setLayout(null);
|
676 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
677 |
null, PluginServices.getText(this, "server"), |
678 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
679 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
680 |
jPanel1.setBounds(2, 5, 477, 105); |
681 |
jPanel1.add(getTxtHost(), null);
|
682 |
jPanel1.add(getBtnConnect(), null);
|
683 |
jPanel1.add(getBtnCancel(), null);
|
684 |
jPanel1.add(getChkCaching(), null);
|
685 |
jPanel1.add(getChkTileCache(), null);
|
686 |
} |
687 |
|
688 |
return jPanel1;
|
689 |
} |
690 |
|
691 |
/**
|
692 |
* DOCUMENT ME!
|
693 |
*
|
694 |
* @param listener
|
695 |
*/
|
696 |
public void addWizardListener(WizardListener listener) { |
697 |
listenerSupport.addWizardListener(listener); |
698 |
} |
699 |
|
700 |
/**
|
701 |
* DOCUMENT ME!
|
702 |
*
|
703 |
* @param listener
|
704 |
*/
|
705 |
public void removeWizardListener(WizardListener listener) { |
706 |
listenerSupport.removeWizardListener(listener); |
707 |
} |
708 |
|
709 |
/**
|
710 |
* DOCUMENT ME!
|
711 |
*
|
712 |
* @return DOCUMENT ME!
|
713 |
* @throws ProjectionLayerException
|
714 |
*/
|
715 |
public Rectangle2D getLayersRectangle() throws ProjectionLayerException { |
716 |
//return wcsParamsPanel.getLayersRectangle();
|
717 |
return null; |
718 |
} |
719 |
|
720 |
|
721 |
|
722 |
/**
|
723 |
* Devuelve el host que est� escrito en el cuadro de texto del host o null
|
724 |
* en caso de que no haya nada escrito o est� mal escrito
|
725 |
*
|
726 |
* @return URL del host
|
727 |
*/
|
728 |
public URL getHost() { |
729 |
try {
|
730 |
if ((cmbHost == null)|| (cmbHost.getModel().getSelectedItem() == null)) { |
731 |
return new URL(explorer.getHost()); |
732 |
} else {
|
733 |
return new URL(cmbHost.getModel().getSelectedItem().toString()); |
734 |
} |
735 |
} catch (MalformedURLException e) { |
736 |
return null; |
737 |
} |
738 |
} |
739 |
|
740 |
/**
|
741 |
* DOCUMENT ME!
|
742 |
*
|
743 |
* @return Nombre de la capa que aparece en el TOC.
|
744 |
*/
|
745 |
public String getLayerName() { |
746 |
return wcsParamsPanel.getLayerName();
|
747 |
} |
748 |
|
749 |
|
750 |
public void initWizard() { |
751 |
} |
752 |
|
753 |
public void execute() { |
754 |
try {
|
755 |
FLayer layer = wcsParamsPanel.getLayer(getChkTileCache().isSelected()); |
756 |
if(layer == null) |
757 |
return;
|
758 |
this.getMapCtrl().getMapContext().getLayers().addLayer(layer);
|
759 |
} catch (InitializeException e) {
|
760 |
logger.info("The layer cannot be added", e);
|
761 |
} |
762 |
|
763 |
} |
764 |
|
765 |
/**
|
766 |
* This method initializes chkCaching
|
767 |
*
|
768 |
* @return javax.swing.JCheckBox
|
769 |
*/
|
770 |
private JCheckBox getChkCaching() { |
771 |
if (chkCaching == null) { |
772 |
chkCaching = new JCheckBox(); |
773 |
chkCaching.setBounds(7, 51, 249, 20); |
774 |
chkCaching.setText(PluginServices.getText(this, "refresh_capabilities")); |
775 |
chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip")); |
776 |
chkCaching.setSelected(refreshing); |
777 |
chkCaching.addItemListener(new java.awt.event.ItemListener() {
|
778 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
779 |
refreshing = chkCaching.isSelected(); |
780 |
} |
781 |
}); |
782 |
chkCaching.addActionListener(new java.awt.event.ActionListener() {
|
783 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
784 |
fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
|
785 |
} |
786 |
}); |
787 |
|
788 |
} |
789 |
return chkCaching;
|
790 |
} |
791 |
|
792 |
/**
|
793 |
* This method initializes chkCaching
|
794 |
*
|
795 |
* @return javax.swing.JCheckBox
|
796 |
*/
|
797 |
private JCheckBox getChkTileCache() { |
798 |
if (chkTileCache == null) { |
799 |
chkTileCache = new JCheckBox(); |
800 |
chkTileCache.setBounds(7, 72, 249, 20); |
801 |
chkTileCache.setText(PluginServices.getText(this, "tile_cache")); |
802 |
chkTileCache.setToolTipText(PluginServices.getText(this, "tile_cache_tooltip")); |
803 |
chkTileCache.setSelected(usingTileCache); |
804 |
chkTileCache.addItemListener(new java.awt.event.ItemListener() {
|
805 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
806 |
usingTileCache = chkTileCache.isSelected(); |
807 |
} |
808 |
}); |
809 |
chkTileCache.addActionListener(new java.awt.event.ActionListener() {
|
810 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
811 |
fPrefs.putBoolean("tile_cache", chkTileCache.isSelected());
|
812 |
} |
813 |
}); |
814 |
|
815 |
} |
816 |
return chkTileCache;
|
817 |
} |
818 |
|
819 |
/**
|
820 |
* This method initializes pnlName
|
821 |
*
|
822 |
* @return javax.swing.JPanel
|
823 |
*/
|
824 |
private JPanel getPnlName() { |
825 |
if (pnlName == null) { |
826 |
pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0)); |
827 |
pnlName.setBounds(new java.awt.Rectangle(9,19,452,24)); |
828 |
pnlName.add(getJLabel1(), null);
|
829 |
pnlName.add(getLblTitle(), null);
|
830 |
} |
831 |
return pnlName;
|
832 |
} |
833 |
|
834 |
@Override
|
835 |
public DataStoreParameters[] getParameters() { |
836 |
// TODO Auto-generated method stub
|
837 |
return null; |
838 |
} |
839 |
|
840 |
@Override
|
841 |
public void close() { |
842 |
// Nothing to do
|
843 |
} |
844 |
} // @jve:decl-index=0:visual-constraint="10,10"
|