svn-gvsig-desktop / trunk / extensions / extWCS / src / com / iver / cit / gvsig / gui / wcs / WCSWizard.java @ 28573
History | View | Annotate | Download (17.3 KB)
1 | 1877 | luisw | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | 2012 | jaume | * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 | 1877 | luisw | *
|
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.wcs; |
||
42 | |||
43 | 6122 | jaume | import java.awt.FlowLayout; |
44 | 1877 | luisw | import java.awt.geom.Rectangle2D; |
45 | import java.net.MalformedURLException; |
||
46 | import java.net.URL; |
||
47 | 9002 | jaume | import java.util.prefs.Preferences; |
48 | 1877 | luisw | |
49 | import javax.swing.DefaultComboBoxModel; |
||
50 | 9002 | jaume | import javax.swing.JCheckBox; |
51 | 6122 | jaume | import javax.swing.JLabel; |
52 | import javax.swing.JPanel; |
||
53 | import javax.swing.JScrollPane; |
||
54 | import javax.swing.JTextArea; |
||
55 | 1877 | luisw | |
56 | 6122 | jaume | import org.gvsig.gui.beans.swing.JButton; |
57 | |||
58 | 1877 | luisw | import com.iver.andami.PluginServices; |
59 | 28573 | vcaballero | import com.iver.andami.persistence.serverData.ServerDataPersistence; |
60 | 1877 | luisw | import com.iver.cit.gvsig.fmap.layers.FLayer; |
61 | import com.iver.cit.gvsig.fmap.layers.FLyrWCS; |
||
62 | import com.iver.cit.gvsig.gui.WizardPanel; |
||
63 | 3166 | jaume | import com.iver.cit.gvsig.gui.panels.WCSParamsPanel; |
64 | 2280 | fjp | import com.iver.cit.gvsig.gui.wizards.WizardListener; |
65 | import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
||
66 | 1877 | luisw | import com.iver.utiles.NotExistInXMLEntity; |
67 | import com.iver.utiles.XMLEntity; |
||
68 | import com.iver.utiles.swing.JComboBox; |
||
69 | 28573 | vcaballero | import com.iver.utiles.swing.jcomboServer.JComboServer; |
70 | import com.iver.utiles.swing.jcomboServer.ServerData; |
||
71 | 6122 | jaume | |
72 | 1877 | luisw | /**
|
73 | 2541 | jaume | * Class implementing the WCSWizard.
|
74 | 6122 | jaume | *
|
75 | 1961 | jaume | * Clase que implementa el Wizard para coberturas WCS
|
76 | 1877 | luisw | * @author Jaume Dom?nguez Faus
|
77 | */
|
||
78 | public class WCSWizard extends WizardPanel { |
||
79 | private int page = 0; |
||
80 | 4356 | jaume | private boolean connected = false; |
81 | 28573 | vcaballero | private JComboServer cmbHost = null; |
82 | 6122 | jaume | private JButton btnConnect = null; |
83 | private JPanel jPanel = null; |
||
84 | private JLabel jLabel1 = null; |
||
85 | private JLabel lblTitle = null; |
||
86 | private JScrollPane jScrollPane = null; |
||
87 | private JTextArea txtAbstract = null; |
||
88 | private JPanel panelPage1 = null; |
||
89 | private JButton btnSiguiente = null; |
||
90 | private JButton btnAnterior = null; |
||
91 | private JPanel jPanel1 = null; |
||
92 | 1877 | luisw | private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
93 | 4414 | jaume | private WCSParamsPanel wcsParamsPanel = null; |
94 | 4356 | jaume | private WCSWizardData dataSource = null; |
95 | 6122 | jaume | private JPanel pnlName; |
96 | 9002 | jaume | private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" ); |
97 | private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false); |
||
98 | private JCheckBox chkCaching; |
||
99 | 6122 | jaume | |
100 | 9002 | jaume | |
101 | 1877 | luisw | /**
|
102 | * This is the default constructor
|
||
103 | */
|
||
104 | public WCSWizard() {
|
||
105 | super();
|
||
106 | initialize(); |
||
107 | } |
||
108 | |||
109 | /**
|
||
110 | * This method initializes this
|
||
111 | */
|
||
112 | private void initialize() { |
||
113 | setTabName("WCS");
|
||
114 | this.setLayout(null); |
||
115 | this.setPreferredSize(new java.awt.Dimension(750, 320)); |
||
116 | this.setVisible(true); |
||
117 | 4398 | jaume | this.setSize(510, 468); |
118 | 1877 | luisw | this.add(getPanelPage1(), null); |
119 | this.add(getPanelPage2(), null); |
||
120 | this.add(getBtnAnterior(), null); |
||
121 | this.add(getBtnSiguiente(), null); |
||
122 | activarVisualizarBotones(); |
||
123 | } |
||
124 | |||
125 | /**
|
||
126 | 2097 | jaume | * Adds the host addres to a persistent data storage.
|
127 | 6122 | jaume | *
|
128 | 1961 | jaume | * con addHost guardamos la informaci?n del combo de servidores en un
|
129 | * almac?n persistente
|
||
130 | 6122 | jaume | *
|
131 | 1886 | luisw | * @param host
|
132 | 1877 | luisw | */
|
133 | private void addHost(String host) { |
||
134 | host = host.trim(); |
||
135 | |||
136 | DefaultComboBoxModel model = (DefaultComboBoxModel) getTxtHost() |
||
137 | 1961 | jaume | .getModel(); |
138 | 1877 | luisw | |
139 | if (model.getIndexOf(host) < 0) { |
||
140 | model.addElement(host); |
||
141 | |||
142 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
143 | XMLEntity xml = ps.getPersistentXML(); |
||
144 | |||
145 | try {
|
||
146 | String[] servers = xml.getStringArrayProperty("wcs-servers"); |
||
147 | String[] newServers = new String[servers.length + 1]; |
||
148 | System.arraycopy(servers, 0, newServers, 0, servers.length); |
||
149 | newServers[servers.length] = host; |
||
150 | xml.putProperty("wcs-servers", newServers);
|
||
151 | } catch (NotExistInXMLEntity e) {
|
||
152 | xml.putProperty("wcs-servers", new String[] { host }); |
||
153 | } |
||
154 | |||
155 | ps.setPersistentXML(xml); |
||
156 | } |
||
157 | } |
||
158 | |||
159 | /**
|
||
160 | 2097 | jaume | * Fills up the initial WCSWizard controls.
|
161 | 6122 | jaume | *
|
162 | 1886 | luisw | * Rellena los primeros controles del WCS Wizard
|
163 | 6122 | jaume | *
|
164 | 1886 | luisw | * jaume
|
165 | 1877 | luisw | */
|
166 | 6442 | jaume | private void fillupComponents() { |
167 | 1877 | luisw | try {
|
168 | String host = cmbHost.getModel().getSelectedItem().toString();
|
||
169 | 6122 | jaume | |
170 | 9002 | jaume | dataSource.setHost(new URL(host), refreshing); |
171 | 6122 | jaume | |
172 | 1961 | jaume | addHost(host); |
173 | 4356 | jaume | getLblTitle().setText(dataSource.getTitle()); |
174 | getTxtAbstract().setText(dataSource.getDescription()); |
||
175 | 6442 | jaume | // wcsParamsPanel.getLstCoverages().setListData(
|
176 | // dataSource.getCoverageList());
|
||
177 | 4414 | jaume | wcsParamsPanel.setWizardData(dataSource); |
178 | 6122 | jaume | |
179 | 4356 | jaume | connected = true;
|
180 | 1877 | luisw | activarVisualizarBotones(); |
181 | } catch (Exception e) { |
||
182 | listenerSupport.callError(e); |
||
183 | 4356 | jaume | e.printStackTrace(); |
184 | 1877 | luisw | } |
185 | } |
||
186 | |||
187 | /**
|
||
188 | 2097 | jaume | * Enables or disables the Next and Previous buttons according with the current
|
189 | * page and the enabled pages.
|
||
190 | 1877 | luisw | */
|
191 | private void activarVisualizarBotones() { |
||
192 | if (page == 0) { |
||
193 | getBtnAnterior().setEnabled(false);
|
||
194 | getBtnSiguiente().setVisible(true);
|
||
195 | 4356 | jaume | if (connected) {
|
196 | 1877 | luisw | getBtnSiguiente().setEnabled(true);
|
197 | } else {
|
||
198 | getBtnSiguiente().setEnabled(false);
|
||
199 | } |
||
200 | 4414 | jaume | } else if (page < wcsParamsPanel.getNumTabs()) { |
201 | 1877 | luisw | getBtnSiguiente().setEnabled(true);
|
202 | getBtnSiguiente().setVisible(true);
|
||
203 | getBtnAnterior().setEnabled(true);
|
||
204 | getBtnAnterior().setVisible(true);
|
||
205 | 4414 | jaume | if (wcsParamsPanel.nextPageEnabled()==-1){ |
206 | 2097 | jaume | getBtnSiguiente().setEnabled(false);
|
207 | } |
||
208 | 4414 | jaume | listenerSupport.callStateChanged(wcsParamsPanel.isCorretlyConfigured()); |
209 | } else if (page == wcsParamsPanel.getNumTabs()) { |
||
210 | 1877 | luisw | getBtnSiguiente().setVisible(false);
|
211 | getBtnSiguiente().setEnabled(false);
|
||
212 | 6122 | jaume | listenerSupport.callStateChanged(wcsParamsPanel |
213 | 3166 | jaume | .isCorretlyConfigured()); |
214 | 1877 | luisw | } |
215 | 1961 | jaume | |
216 | } |
||
217 | 1877 | luisw | |
218 | 1961 | jaume | |
219 | 6122 | jaume | |
220 | 1877 | luisw | /**
|
221 | 1886 | luisw | * This method initializes txtHost from the persistent data storage
|
222 | 6122 | jaume | *
|
223 | 1877 | luisw | * @return javax.swing.JTextField
|
224 | */
|
||
225 | private javax.swing.JComboBox getTxtHost() {
|
||
226 | 28573 | vcaballero | if (cmbHost == null) { |
227 | cmbHost = new JComboServer();
|
||
228 | cmbHost.setModel(new DefaultComboBoxModel()); |
||
229 | cmbHost.setPreferredSize(new java.awt.Dimension(350, 20)); |
||
230 | cmbHost.setBounds(11, 26, 454, 20); |
||
231 | cmbHost.setEditable(true);
|
||
232 | 1877 | luisw | |
233 | 28573 | vcaballero | ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_WCS); |
234 | ServerData[] servers = persistence.getArrayOfServerData();
|
||
235 | 1961 | jaume | |
236 | 28573 | vcaballero | if (servers.length == 0){ |
237 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
238 | XMLEntity xml = ps.getPersistentXML(); |
||
239 | try {
|
||
240 | String[] oldServers = xml.getStringArrayProperty("wcs-servers"); |
||
241 | servers = new ServerData[oldServers.length];
|
||
242 | for (int i=0; i<oldServers.length; i++) { |
||
243 | servers[i] = new ServerData(oldServers[i],ServerData.SERVER_TYPE_WCS);
|
||
244 | } |
||
245 | xml.remove("wcs-servers");
|
||
246 | ps.setPersistentXML(xml); |
||
247 | } catch (NotExistInXMLEntity e) {
|
||
248 | // Old servers doesn't exist
|
||
249 | servers = new ServerData[2]; |
||
250 | servers[0] = new ServerData("http://maps.gdal.org/cgi-bin/mapserv_dem",ServerData.SERVER_TYPE_WCS); |
||
251 | servers[1] = new ServerData("http://inspire.cop.gva.es/mapserver/wcs",ServerData.SERVER_TYPE_WCS); |
||
252 | } |
||
253 | 1877 | luisw | |
254 | 28573 | vcaballero | for (int i=0 ; i<servers.length ; i++){ |
255 | persistence.addServerData(servers[i]); |
||
256 | } |
||
257 | persistence.setPersistent(); |
||
258 | } |
||
259 | 1877 | luisw | |
260 | 28573 | vcaballero | cmbHost.setServerList(servers); |
261 | 1961 | jaume | } |
262 | 28573 | vcaballero | return cmbHost;
|
263 | 1877 | luisw | } |
264 | |||
265 | 6122 | jaume | |
266 | 1877 | luisw | /**
|
267 | * This method initializes btnDetalles
|
||
268 | 6122 | jaume | *
|
269 | * @return JButton
|
||
270 | 1877 | luisw | */
|
271 | 6122 | jaume | private JButton getBtnConnect() { |
272 | 4398 | jaume | if (btnConnect == null) { |
273 | 6122 | jaume | btnConnect = new JButton(); |
274 | 4398 | jaume | btnConnect.setPreferredSize(new java.awt.Dimension(100, 20)); |
275 | btnConnect.setBounds(366, 50, 100, 20); |
||
276 | btnConnect.setText(PluginServices.getText(this, "connect")); |
||
277 | btnConnect.addActionListener(new java.awt.event.ActionListener() {
|
||
278 | 1961 | jaume | public void actionPerformed(java.awt.event.ActionEvent e) { |
279 | 4414 | jaume | wcsParamsPanel.cleanupWizard(); |
280 | 4356 | jaume | connected = false;
|
281 | 6442 | jaume | fillupComponents(); |
282 | 1961 | jaume | } |
283 | }); |
||
284 | 1877 | luisw | } |
285 | |||
286 | 4398 | jaume | return btnConnect;
|
287 | 1877 | luisw | } |
288 | |||
289 | /**
|
||
290 | * This method initializes jPanel
|
||
291 | 6122 | jaume | *
|
292 | * @return JPanel
|
||
293 | 1877 | luisw | */
|
294 | 6122 | jaume | private JPanel getJPanel() { |
295 | 1877 | luisw | if (jPanel == null) { |
296 | jPanel = new javax.swing.JPanel();
|
||
297 | jPanel.setLayout(null);
|
||
298 | jPanel.setPreferredSize(new java.awt.Dimension(470, 130)); |
||
299 | 1961 | jaume | jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
|
300 | PluginServices.getText(this, "descripcion"), |
||
301 | 1877 | luisw | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
302 | 1961 | jaume | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
303 | null));
|
||
304 | 4398 | jaume | jPanel.setBounds(2, 96, 477, 324); |
305 | 6122 | jaume | jPanel.add(getPnlName(), null);
|
306 | 1877 | luisw | jPanel.add(getJScrollPane(), null);
|
307 | } |
||
308 | |||
309 | return jPanel;
|
||
310 | } |
||
311 | |||
312 | /**
|
||
313 | * This method initializes jLabel1
|
||
314 | 6122 | jaume | *
|
315 | * @return JLabel
|
||
316 | 1877 | luisw | */
|
317 | 6122 | jaume | private JLabel getJLabel1() { |
318 | 1877 | luisw | if (jLabel1 == null) { |
319 | jLabel1 = new javax.swing.JLabel();
|
||
320 | jLabel1.setText(PluginServices.getText(this, "nombre") + ":"); |
||
321 | jLabel1.setBounds(37, 26, 40, 15); |
||
322 | } |
||
323 | |||
324 | return jLabel1;
|
||
325 | } |
||
326 | |||
327 | /**
|
||
328 | * This method initializes lblTitle
|
||
329 | 6122 | jaume | *
|
330 | * @return JLabel
|
||
331 | 1877 | luisw | */
|
332 | 6122 | jaume | private JLabel getLblTitle() { |
333 | 1877 | luisw | if (lblTitle == null) { |
334 | lblTitle = new javax.swing.JLabel();
|
||
335 | lblTitle.setText("-");
|
||
336 | lblTitle.setPreferredSize(new java.awt.Dimension(350, 16)); |
||
337 | lblTitle.setBounds(82, 26, 350, 16); |
||
338 | } |
||
339 | |||
340 | return lblTitle;
|
||
341 | } |
||
342 | |||
343 | /**
|
||
344 | * This method initializes jScrollPane
|
||
345 | 6122 | jaume | *
|
346 | * @return JScrollPane
|
||
347 | 1877 | luisw | */
|
348 | 6122 | jaume | private JScrollPane getJScrollPane() { |
349 | 1877 | luisw | if (jScrollPane == null) { |
350 | jScrollPane = new javax.swing.JScrollPane();
|
||
351 | jScrollPane.setViewportView(getTxtAbstract()); |
||
352 | jScrollPane.setPreferredSize(new java.awt.Dimension(450, 60)); |
||
353 | 9888 | ppiqueras | jScrollPane.setBounds(10, 47, 457, 267); |
354 | 1877 | luisw | } |
355 | |||
356 | return jScrollPane;
|
||
357 | } |
||
358 | |||
359 | /**
|
||
360 | * This method initializes txtAbstract
|
||
361 | 6122 | jaume | *
|
362 | * @return JTextArea
|
||
363 | 1877 | luisw | */
|
364 | 6122 | jaume | private JTextArea getTxtAbstract() { |
365 | 1877 | luisw | if (txtAbstract == null) { |
366 | txtAbstract = new javax.swing.JTextArea();
|
||
367 | txtAbstract.setWrapStyleWord(true);
|
||
368 | txtAbstract.setColumns(30);
|
||
369 | txtAbstract.setLineWrap(true);
|
||
370 | } |
||
371 | |||
372 | return txtAbstract;
|
||
373 | } |
||
374 | 9002 | jaume | /**
|
375 | * This method initializes chkCaching
|
||
376 | *
|
||
377 | * @return javax.swing.JCheckBox
|
||
378 | */
|
||
379 | private JCheckBox getChkCaching() { |
||
380 | if (chkCaching == null) { |
||
381 | chkCaching = new JCheckBox(); |
||
382 | chkCaching.setBounds(7, 51, 349, 20); |
||
383 | chkCaching.setText(PluginServices.getText(this, "refresh_capabilities")); |
||
384 | chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip")); |
||
385 | chkCaching.setSelected(refreshing); |
||
386 | chkCaching.addItemListener(new java.awt.event.ItemListener() {
|
||
387 | public void itemStateChanged(java.awt.event.ItemEvent e) { |
||
388 | refreshing = chkCaching.isSelected(); |
||
389 | } |
||
390 | }); |
||
391 | chkCaching.addActionListener(new java.awt.event.ActionListener() {
|
||
392 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
393 | fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
|
||
394 | } |
||
395 | }); |
||
396 | 1877 | luisw | |
397 | 9002 | jaume | } |
398 | return chkCaching;
|
||
399 | } |
||
400 | |||
401 | 1877 | luisw | /**
|
402 | * This method initializes panelPage1
|
||
403 | 6122 | jaume | *
|
404 | * @return JPanel
|
||
405 | 1877 | luisw | */
|
406 | 6122 | jaume | private JPanel getPanelPage1() { |
407 | 1877 | luisw | if (panelPage1 == null) { |
408 | panelPage1 = new javax.swing.JPanel();
|
||
409 | panelPage1.setLayout(null);
|
||
410 | panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
||
411 | panelPage1.setVisible(true);
|
||
412 | 4398 | jaume | panelPage1.setBounds(15, 5, 480, 427); |
413 | 1877 | luisw | panelPage1.add(getJPanel1(), null);
|
414 | panelPage1.add(getJPanel(), null);
|
||
415 | } |
||
416 | |||
417 | return panelPage1;
|
||
418 | } |
||
419 | |||
420 | /**
|
||
421 | * This method initializes panelPage2
|
||
422 | 6122 | jaume | *
|
423 | * @return JPanel
|
||
424 | 1877 | luisw | */
|
425 | 6122 | jaume | private JPanel getPanelPage2() { |
426 | 4414 | jaume | if (wcsParamsPanel == null) { |
427 | wcsParamsPanel = new WCSParamsPanel();
|
||
428 | wcsParamsPanel.setListenerSupport(this.listenerSupport);
|
||
429 | 6501 | jaume | wcsParamsPanel.setBounds(0, 5, 510, 428); |
430 | 1877 | luisw | } |
431 | |||
432 | 4414 | jaume | return wcsParamsPanel;
|
433 | 1877 | luisw | } |
434 | |||
435 | 6122 | jaume | /**
|
436 | * This method initializes pnlName
|
||
437 | *
|
||
438 | * @return JPanel
|
||
439 | */
|
||
440 | private JPanel getPnlName() { |
||
441 | if (pnlName == null) { |
||
442 | pnlName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0)); |
||
443 | pnlName.setBounds(new java.awt.Rectangle(9,19,452,24)); |
||
444 | pnlName.add(getJLabel1(), null);
|
||
445 | pnlName.add(getLblTitle(), null);
|
||
446 | } |
||
447 | return pnlName;
|
||
448 | } |
||
449 | 1961 | jaume | |
450 | |||
451 | 6122 | jaume | |
452 | 1886 | luisw | /**
|
453 | 1877 | luisw | * This method initializes btnSiguiente
|
454 | 6122 | jaume | *
|
455 | * @return JButton
|
||
456 | 1877 | luisw | */
|
457 | 6122 | jaume | private JButton getBtnSiguiente() { |
458 | 1877 | luisw | if (btnSiguiente == null) { |
459 | 6122 | jaume | btnSiguiente = new JButton(); |
460 | 1877 | luisw | btnSiguiente.setPreferredSize(new java.awt.Dimension(100, 30)); |
461 | 6122 | jaume | btnSiguiente.setBounds(395, 444, 100, 20); |
462 | 1877 | luisw | btnSiguiente.setText(PluginServices.getText(this, "siguiente")); |
463 | btnSiguiente.addActionListener(new java.awt.event.ActionListener() {
|
||
464 | 1961 | jaume | public void actionPerformed(java.awt.event.ActionEvent e) { |
465 | if (page > 0) { |
||
466 | // si page es mayor que cero, vamos enfocando las
|
||
467 | // sucesivas SOLAPAS del WCSParamsPanel
|
||
468 | 4414 | jaume | wcsParamsPanel.avanzaTab(); |
469 | page = wcsParamsPanel.getIndiceSolapaActual(); |
||
470 | 1877 | luisw | } |
471 | 1961 | jaume | page++; |
472 | |||
473 | getPanelPage1().setVisible(false);
|
||
474 | getPanelPage2().setVisible(true);
|
||
475 | activarVisualizarBotones(); |
||
476 | } |
||
477 | }); |
||
478 | 1877 | luisw | } |
479 | return btnSiguiente;
|
||
480 | } |
||
481 | |||
482 | /**
|
||
483 | * This method initializes btnAnterior
|
||
484 | 6122 | jaume | *
|
485 | * @return JButton
|
||
486 | 1877 | luisw | */
|
487 | 6122 | jaume | private JButton getBtnAnterior() { |
488 | 1877 | luisw | if (btnAnterior == null) { |
489 | 6122 | jaume | btnAnterior = new JButton(); |
490 | btnAnterior.setBounds(292, 444, 100, 20); |
||
491 | 1877 | luisw | btnAnterior.setText(PluginServices.getText(this, "anterior")); |
492 | btnAnterior.addActionListener(new java.awt.event.ActionListener() {
|
||
493 | 1961 | jaume | public void actionPerformed(java.awt.event.ActionEvent e) { |
494 | page --; |
||
495 | if (page > 0) { |
||
496 | // Tenemos que retroceder en el wcsParamsPanel
|
||
497 | 4414 | jaume | wcsParamsPanel.retrocedeTab(); |
498 | page = wcsParamsPanel.getIndiceSolapaActual() + 1;
|
||
499 | 1877 | luisw | activarVisualizarBotones(); |
500 | 1961 | jaume | } else if (page==0){ |
501 | activarVisualizarBotones(); |
||
502 | page = 1;
|
||
503 | 4414 | jaume | wcsParamsPanel.cleanupWizard(); |
504 | 1961 | jaume | getLblTitle().setText("-");
|
505 | getTxtAbstract().setText("");
|
||
506 | 4414 | jaume | wcsParamsPanel.retrocedeTab(); |
507 | 1961 | jaume | getPanelPage1().setVisible(true);
|
508 | getPanelPage2().setVisible(false);
|
||
509 | getBtnSiguiente().setEnabled(false);
|
||
510 | 6122 | jaume | connected = false;
|
511 | 1877 | luisw | } |
512 | 4414 | jaume | listenerSupport.callStateChanged(wcsParamsPanel.isCorretlyConfigured()); |
513 | 1961 | jaume | } |
514 | }); |
||
515 | 1877 | luisw | } |
516 | return btnAnterior;
|
||
517 | } |
||
518 | |||
519 | /**
|
||
520 | * This method initializes jPanel1
|
||
521 | 6122 | jaume | *
|
522 | 1877 | luisw | * @return javax.swing.JPanel
|
523 | */
|
||
524 | 6122 | jaume | private JPanel getJPanel1() { |
525 | 1877 | luisw | if (jPanel1 == null) { |
526 | jPanel1 = new javax.swing.JPanel();
|
||
527 | 4398 | jaume | jPanel1.setLayout(null);
|
528 | 1877 | luisw | jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
529 | 4398 | jaume | null, PluginServices.getText(this, "server"), |
530 | 1877 | luisw | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
531 | 4398 | jaume | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
532 | jPanel1.setBounds(2, 5, 477, 85); |
||
533 | jPanel1.add(getTxtHost(), null);
|
||
534 | jPanel1.add(getBtnConnect(), null);
|
||
535 | 9002 | jaume | jPanel1.add(getChkCaching(), null);
|
536 | 1877 | luisw | } |
537 | |||
538 | return jPanel1;
|
||
539 | } |
||
540 | |||
541 | /**
|
||
542 | 6122 | jaume | * Adds the gvSIG's wizard listener
|
543 | *
|
||
544 | 1877 | luisw | * @param listener
|
545 | */
|
||
546 | 6122 | jaume | public void addWizardListener(WizardListener listener) { |
547 | 1877 | luisw | listenerSupport.addWizardListener(listener); |
548 | } |
||
549 | |||
550 | /**
|
||
551 | 2097 | jaume | * Removes the gvSIG's wizard listener
|
552 | 6122 | jaume | *
|
553 | 1877 | luisw | * @param listener
|
554 | */
|
||
555 | public void removeWizardListener(WizardListener listener) { |
||
556 | listenerSupport.removeWizardListener(listener); |
||
557 | } |
||
558 | |||
559 | /**
|
||
560 | 2097 | jaume | * Returns the Wizard's data source
|
561 | 6122 | jaume | *
|
562 | 1877 | luisw | * @return
|
563 | */
|
||
564 | 4356 | jaume | public WCSWizardData getDataSource() {
|
565 | 1877 | luisw | return dataSource;
|
566 | } |
||
567 | |||
568 | /**
|
||
569 | 2097 | jaume | * sets the wizard's data source
|
570 | 6122 | jaume | *
|
571 | 1877 | luisw | * @param source
|
572 | */
|
||
573 | 4356 | jaume | public void setDataSource(WCSWizardData source) { |
574 | 1877 | luisw | dataSource = source; |
575 | } |
||
576 | |||
577 | /**
|
||
578 | 2097 | jaume | * Returns the rectangle that contains all the others
|
579 | 6122 | jaume | *
|
580 | 1877 | luisw | * Obtiene el rect?ngulo que contiene a todos los otros
|
581 | 6122 | jaume | *
|
582 | 2097 | jaume | * @param rects[] rectangulos
|
583 | 6122 | jaume | *
|
584 | 2097 | jaume | * @return Rectangle2D
|
585 | 1877 | luisw | */
|
586 | public static Rectangle2D getRectangle(Rectangle2D[] rects) { |
||
587 | Rectangle2D ret = rects[0]; |
||
588 | |||
589 | for (int i = 1; i < rects.length; i++) { |
||
590 | ret.add(rects[i]); |
||
591 | } |
||
592 | |||
593 | return ret;
|
||
594 | } |
||
595 | |||
596 | /**
|
||
597 | 2097 | jaume | * Returns the host typed in the host text field or null if nothing is typed
|
598 | * or it is not a valid URL.
|
||
599 | 6122 | jaume | *
|
600 | 1877 | luisw | * Devuelve el host que est? escrito en el cuadro de texto del host o null
|
601 | * en caso de que no haya nada escrito o est? mal escrito
|
||
602 | 6122 | jaume | *
|
603 | 1877 | luisw | * @return URL del host
|
604 | */
|
||
605 | public URL getHost() { |
||
606 | try {
|
||
607 | return new URL(cmbHost.getModel().getSelectedItem().toString()); |
||
608 | } catch (MalformedURLException e) { |
||
609 | return null; |
||
610 | } |
||
611 | } |
||
612 | |||
613 | /**
|
||
614 | 2097 | jaume | * Returns the name of the coverage that appears in the TOC
|
615 | 6122 | jaume | *
|
616 | 2097 | jaume | * @return String
|
617 | 1877 | luisw | */
|
618 | public String getLayerName() { |
||
619 | 4414 | jaume | return wcsParamsPanel.getLayerName();
|
620 | 1877 | luisw | } |
621 | 6122 | jaume | |
622 | 1877 | luisw | public void initWizard() { |
623 | 4356 | jaume | setDataSource(new WCSWizardData());
|
624 | 1877 | luisw | } |
625 | |||
626 | public void execute() { |
||
627 | } |
||
628 | 6122 | jaume | |
629 | 2097 | jaume | /**
|
630 | * Creates a new layer to be passed to gvSIG. This method is automatically called
|
||
631 | * by gvSIG and it must ensure that a layer is fully and correctly created or then
|
||
632 | 2331 | jaume | * return null.
|
633 | 1877 | luisw | */
|
634 | public FLayer getLayer() {
|
||
635 | 6122 | jaume | FLyrWCS layer = new FLyrWCS();
|
636 | 2003 | jaume | layer.setHost(this.getHost().toString());
|
637 | 4573 | jaume | layer.setCoverageName(wcsParamsPanel.getCurrentCoverageName()); |
638 | layer.setSRS(wcsParamsPanel.getSRS()); |
||
639 | layer.setFormat(wcsParamsPanel.getFormat()); |
||
640 | layer.setFullExtent(wcsParamsPanel.getExtent()); |
||
641 | layer.setDriver(wcsParamsPanel.getDriver()); |
||
642 | layer.setTime(wcsParamsPanel.getTime()); |
||
643 | layer.setParameter(wcsParamsPanel.getParameterString()); |
||
644 | layer.setName(wcsParamsPanel.getCoverageName()); |
||
645 | layer.setMaxResolution(wcsParamsPanel.getMaxRes()); |
||
646 | 14485 | jmvivo | |
647 | 6122 | jaume | return layer;
|
648 | 1961 | jaume | } |
649 | 4356 | jaume | |
650 | 1961 | jaume | } |