gvsig-raster / org.gvsig.raster.wms / branches / org.gvsig.raster.wms_dataaccess_refactoring / org.gvsig.raster.wms.app.wmsclient / src / main / java / org / gvsig / raster / wms / app / wmsclient / gui / panel / WMSParamsPanel.java @ 2243
History | View | Annotate | Download (51.4 KB)
1 | 1944 | nbrodin | /* 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.wms.app.wmsclient.gui.panel; |
||
24 | |||
25 | import java.awt.Component; |
||
26 | import java.awt.Dimension; |
||
27 | import java.awt.event.FocusAdapter; |
||
28 | import java.awt.event.FocusEvent; |
||
29 | import java.awt.event.FocusListener; |
||
30 | import java.awt.event.MouseAdapter; |
||
31 | import java.awt.event.MouseEvent; |
||
32 | import java.awt.geom.Rectangle2D; |
||
33 | import java.lang.reflect.InvocationTargetException; |
||
34 | import java.util.AbstractCollection; |
||
35 | import java.util.ArrayList; |
||
36 | import java.util.Hashtable; |
||
37 | import java.util.TreeSet; |
||
38 | import java.util.Vector; |
||
39 | import java.util.prefs.Preferences; |
||
40 | |||
41 | import javax.swing.JButton; |
||
42 | import javax.swing.JCheckBox; |
||
43 | import javax.swing.JList; |
||
44 | import javax.swing.JOptionPane; |
||
45 | import javax.swing.JPanel; |
||
46 | import javax.swing.JScrollPane; |
||
47 | import javax.swing.JTabbedPane; |
||
48 | import javax.swing.JTextField; |
||
49 | import javax.swing.tree.TreePath; |
||
50 | |||
51 | import org.cresques.cts.ICoordTrans; |
||
52 | import org.cresques.cts.IProjection; |
||
53 | import org.gvsig.andami.IconThemeHelper; |
||
54 | import org.gvsig.andami.PluginServices; |
||
55 | import org.gvsig.andami.messages.NotificationManager; |
||
56 | import org.gvsig.app.gui.WizardPanel; |
||
57 | import org.gvsig.app.gui.wizards.FormatListModel; |
||
58 | import org.gvsig.app.gui.wizards.WizardListenerSupport; |
||
59 | import org.gvsig.fmap.crs.CRSFactory; |
||
60 | import org.gvsig.fmap.dal.DALLocator; |
||
61 | import org.gvsig.fmap.dal.DataManager; |
||
62 | import org.gvsig.fmap.dal.DataParameters; |
||
63 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
64 | import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
||
65 | import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
||
66 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
67 | import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
||
68 | import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
||
69 | import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException; |
||
70 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
71 | import org.gvsig.fmap.mapcontext.layers.FLayers; |
||
72 | import org.gvsig.gui.beans.Messages; |
||
73 | import org.gvsig.gui.beans.controls.dnd.JDnDListModel; |
||
74 | import org.gvsig.gui.beans.listeners.BeanListener; |
||
75 | import org.gvsig.raster.wms.app.wmsclient.gui.wizard.LayerTreeModel; |
||
76 | import org.gvsig.raster.wms.app.wmsclient.gui.wizard.SRSListModel; |
||
77 | import org.gvsig.raster.wms.app.wmsclient.layer.FLyrWMS; |
||
78 | import org.gvsig.raster.wms.io.RemoteWMSStyle; |
||
79 | import org.gvsig.raster.wms.io.WMSDataParameters; |
||
80 | import org.gvsig.raster.wms.io.WMSLayerNode; |
||
81 | import org.gvsig.raster.wms.io.WMSServerExplorer; |
||
82 | import org.gvsig.raster.wms.io.time.RemoteTimeDimension; |
||
83 | import org.slf4j.Logger; |
||
84 | import org.slf4j.LoggerFactory; |
||
85 | |||
86 | |||
87 | /**
|
||
88 | * This class implements the map option panel.
|
||
89 | *
|
||
90 | * It includes a set of Listeners that implement some control rules which
|
||
91 | * refresh the component values that depends on those selected in the other
|
||
92 | * components to avoid to choose an invalid set of options. It also includes a
|
||
93 | * method (isCorrectlyConfigured()) that checks if the current set of values is
|
||
94 | * enough to correctly launch a GetMap request.
|
||
95 | *
|
||
96 | * The information is obtained from a WMSWizardDataSource object.
|
||
97 | *
|
||
98 | *
|
||
99 | * Esta clase implementa el panel de opciones disponibles sobre el mapa
|
||
100 | *
|
||
101 | * Incluye una serie de Listeners que implementan unas reglas de control que
|
||
102 | * refrescan los valores de componentes cuyos valores dependen de aqu?llos
|
||
103 | * seleccionados en otros componentes para evitar que se escoja una combinaci?n
|
||
104 | * de opciones err?nea as? como una funci?n (isCorrectlyConfigured()) que
|
||
105 | * comprueba si la combinaci?n escogida actualmente es suficiente para lanzar
|
||
106 | * una operaci?n GetMap correctamente.
|
||
107 | *
|
||
108 | * La informaci?n obtiene a partir de un objeto WMSWizardDataSource.
|
||
109 | *
|
||
110 | * @author jaume - jaume dominguez faus
|
||
111 | *
|
||
112 | */
|
||
113 | @SuppressWarnings("unchecked") |
||
114 | public class WMSParamsPanel extends WizardPanel { |
||
115 | private static final long serialVersionUID = 1L; |
||
116 | private JScrollPane jScrollPane1 = null; |
||
117 | private JScrollPane jScrollPane2 = null; |
||
118 | private JScrollPane jScrollPane3 = null; |
||
119 | private JScrollPane jScrollPane5 = null; |
||
120 | private JButton btnAdd = null; |
||
121 | private JButton btnDel = null; |
||
122 | private JScrollPane jScrollPane6 = null; |
||
123 | private JPanel jPanel2 = null; |
||
124 | private JPanel tabFormats = null; |
||
125 | private JPanel jPanel4 = null; |
||
126 | private JTextField jTxtNomCapa = null; |
||
127 | private LayerList lstSelectedLayers = null; |
||
128 | private ArrayList<TreePath> selectedPaths = new ArrayList<TreePath>(); |
||
129 | private JList lstSRSs = null; |
||
130 | private JList lstInfoFormats = null; |
||
131 | private LayerTree treeLayers = null; |
||
132 | private JList lstFormats = null; |
||
133 | private WizardListenerSupport listenerSupport;
|
||
134 | private JTabbedPane jTabbedPane = null; |
||
135 | private JPanel tabLayers = null; |
||
136 | 2243 | nbrodin | private JPanel jPanelFormats = null; |
137 | private JPanel jPanelSrsSelection = null; |
||
138 | private JPanel jPanelInfoByPointFormat = null; |
||
139 | 1944 | nbrodin | private StylesPanel tabStyle = null; |
140 | private JCheckBox chkTransparency = null; |
||
141 | private InfoPanel tabInfo = null; |
||
142 | private DimensionPanel tabDimensions = null; |
||
143 | private int dimensionTabIndex; |
||
144 | private int stylesTabIndex; |
||
145 | private String oldSRS = null; |
||
146 | private AbstractCollection oldDimensions = null; |
||
147 | private Dimension sizeFixed; |
||
148 | private JCheckBox chkExtendedNames = null; |
||
149 | private JButton btnUp = null; |
||
150 | private JButton btnDown = null; |
||
151 | protected WMSServerExplorer explorer = null; |
||
152 | private boolean updating = fPrefs.getBoolean("refresh_capabilities", false); |
||
153 | public static Preferences fPrefs = Preferences.userRoot().node("gvsig.wms-wizard"); |
||
154 | private Logger log = LoggerFactory.getLogger(WMSParamsPanel.class); |
||
155 | private JCheckBox chkDisagregate = null; |
||
156 | private boolean lastCached; |
||
157 | private String groupName = "WMS Group"; |
||
158 | |||
159 | public WMSParamsPanel() {
|
||
160 | super();
|
||
161 | initialize(); |
||
162 | } |
||
163 | |||
164 | // TODO: crear nuevo constructor para a?adir los panels que quieras...
|
||
165 | public WMSParamsPanel(WMSServerExplorer data) {
|
||
166 | super();
|
||
167 | setWizardData(data); |
||
168 | this.setLayout(null); |
||
169 | this.setVisible(false); |
||
170 | this.setBounds(0, 0, 510, 427); |
||
171 | if (jTabbedPane == null) { |
||
172 | jTabbedPane = new JTabbedPane(); |
||
173 | jTabbedPane.setBounds(4, 4, 502, 415); |
||
174 | StylesPanel sp = getTabStyle(); |
||
175 | DimensionPanel dp = getTabDimensions(); |
||
176 | |||
177 | jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, |
||
178 | getTabLayers(), null);
|
||
179 | jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, |
||
180 | sp, null);
|
||
181 | stylesTabIndex = jTabbedPane.getTabCount() - 1;
|
||
182 | jTabbedPane.addTab(PluginServices.getText(this, "dimensiones"), |
||
183 | null, dp, null); |
||
184 | dimensionTabIndex = jTabbedPane.getTabCount() - 1;
|
||
185 | jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, |
||
186 | getTabFormats(), null);
|
||
187 | jTabbedPane.setEnabledAt(dimensionTabIndex, false);
|
||
188 | jTabbedPane.setEnabledAt(stylesTabIndex, false);
|
||
189 | } |
||
190 | this.add(jTabbedPane, null); |
||
191 | |||
192 | setListenerSupport(new WizardListenerSupport());
|
||
193 | } |
||
194 | |||
195 | /**
|
||
196 | * This method initializes panelPage2
|
||
197 | *
|
||
198 | * @return Panel
|
||
199 | */
|
||
200 | private void initialize() { |
||
201 | this.setLayout(null); |
||
202 | this.setVisible(false); |
||
203 | this.setBounds(0, 0, 510, 427); |
||
204 | this.add(getJTabbedPane(), null); |
||
205 | } |
||
206 | |||
207 | public boolean isUpdatingCache() { |
||
208 | return updating;
|
||
209 | } |
||
210 | |||
211 | public void setUpdatingCache(boolean updating) { |
||
212 | this.updating = updating;
|
||
213 | } |
||
214 | |||
215 | /**
|
||
216 | * This method initializes jPanel2
|
||
217 | *
|
||
218 | * @return Panel
|
||
219 | */
|
||
220 | private JPanel getJPanel2() { |
||
221 | if (jPanel2 == null) { |
||
222 | jPanel2 = new JPanel(); |
||
223 | jPanel2.setLayout(null);
|
||
224 | jPanel2.setBounds(5, 59, 485, 328); |
||
225 | jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
226 | null, PluginServices.getText(this, "select_layers"), |
||
227 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
228 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
229 | null));
|
||
230 | jPanel2.add(getChkExtendedNames(), null);
|
||
231 | |||
232 | jPanel2.add(getJScrollPane1(), null);
|
||
233 | jPanel2.add(getBtnDel(), null);
|
||
234 | jPanel2.add(getBtnAdd(), null);
|
||
235 | jPanel2.add(getJScrollPane5(), null);
|
||
236 | jPanel2.add(getBtnUp(), null);
|
||
237 | jPanel2.add(getBtnDown(), null);
|
||
238 | jPanel2.add(getChkDisagregate(), null);
|
||
239 | } |
||
240 | |||
241 | return jPanel2;
|
||
242 | } |
||
243 | |||
244 | /**
|
||
245 | * This method initializes jPanel4
|
||
246 | *
|
||
247 | * @return Panel
|
||
248 | */
|
||
249 | private JPanel getJPanel4() { |
||
250 | if (jPanel4 == null) { |
||
251 | jPanel4 = new JPanel(); |
||
252 | jPanel4.setLayout(null);
|
||
253 | jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
254 | null, PluginServices.getText(this, "layer_name"), |
||
255 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
256 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
257 | null));
|
||
258 | jPanel4.setBounds(5, 8, 485, 49); |
||
259 | jPanel4.add(getJTxtNomCapa(), null);
|
||
260 | } |
||
261 | |||
262 | return jPanel4;
|
||
263 | } |
||
264 | |||
265 | /**
|
||
266 | * This method initializes jPanel3
|
||
267 | *
|
||
268 | * @return Panel
|
||
269 | */
|
||
270 | private JPanel getTabFormats() { |
||
271 | if (tabFormats == null) { |
||
272 | tabFormats = new JPanel(); |
||
273 | tabFormats.setLayout(null);
|
||
274 | 2243 | nbrodin | tabFormats.add(getJPanelFormats(), null);
|
275 | tabFormats.add(getJPanelSrsSelection(), null);
|
||
276 | tabFormats.add(getJPanelInfoByPointFormat(), null);
|
||
277 | 1944 | nbrodin | } |
278 | |||
279 | return tabFormats;
|
||
280 | } |
||
281 | |||
282 | /**
|
||
283 | * This method initializes jScrollPane1
|
||
284 | *
|
||
285 | * @return ScrollPane
|
||
286 | */
|
||
287 | private JScrollPane getJScrollPane1() { |
||
288 | if (jScrollPane1 == null) { |
||
289 | jScrollPane1 = new JScrollPane(); |
||
290 | jScrollPane1.setBounds(11, 22, 460, 123); |
||
291 | jScrollPane1.setViewportView(getTreeLayers()); |
||
292 | jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75)); |
||
293 | } |
||
294 | |||
295 | return jScrollPane1;
|
||
296 | } |
||
297 | |||
298 | /**
|
||
299 | * This method initializes btnDel
|
||
300 | *
|
||
301 | * @return Button
|
||
302 | */
|
||
303 | private JButton getBtnDel() { |
||
304 | if (btnDel == null) { |
||
305 | btnDel = new JButton(); |
||
306 | // btnDel.setPreferredSize(new java.awt.Dimension(23, 23));
|
||
307 | btnDel.setText(PluginServices.getText(this, "remove")); |
||
308 | btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
||
309 | btnDel.setBounds(339, 300, 101, 20); |
||
310 | btnDel.setEnabled(false);
|
||
311 | btnDel.addActionListener(new java.awt.event.ActionListener() {
|
||
312 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
313 | delLayer(); |
||
314 | } |
||
315 | }); |
||
316 | } |
||
317 | return btnDel;
|
||
318 | } |
||
319 | |||
320 | /**
|
||
321 | * This method initializes btnAdd
|
||
322 | *
|
||
323 | * @return Button
|
||
324 | */
|
||
325 | private JButton getBtnAdd() { |
||
326 | if (btnAdd == null) { |
||
327 | btnAdd = new JButton(); |
||
328 | // btnAdd.setPreferredSize(new java.awt.Dimension(23, 23));
|
||
329 | btnAdd.setText(PluginServices.getText(this, "add")); |
||
330 | btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0)); |
||
331 | btnAdd.setBounds(236, 300, 101, 20); |
||
332 | btnAdd.setEnabled(false);
|
||
333 | btnAdd.addActionListener(new java.awt.event.ActionListener() {
|
||
334 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
335 | addLayer(); |
||
336 | } |
||
337 | }); |
||
338 | } |
||
339 | return btnAdd;
|
||
340 | } |
||
341 | |||
342 | /**
|
||
343 | * This method initializes jScrollPane5
|
||
344 | *
|
||
345 | * @return ScrollPane
|
||
346 | */
|
||
347 | private JScrollPane getJScrollPane5() { |
||
348 | if (jScrollPane5 == null) { |
||
349 | jScrollPane5 = new JScrollPane(); |
||
350 | jScrollPane5.setBounds(11, 155, 422, 120); |
||
351 | jScrollPane5.setViewportView(getLstSelectedLayers()); |
||
352 | jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75)); |
||
353 | } |
||
354 | |||
355 | return jScrollPane5;
|
||
356 | } |
||
357 | |||
358 | /**
|
||
359 | * This method initializes jTextField
|
||
360 | *
|
||
361 | * @return TextField
|
||
362 | */
|
||
363 | private JTextField getJTxtNomCapa() { |
||
364 | if (jTxtNomCapa == null) { |
||
365 | jTxtNomCapa = new JTextField(); |
||
366 | jTxtNomCapa.setBounds(10, 19, 460, 20); |
||
367 | jTxtNomCapa.setText(PluginServices.getText(this, "WMSLayer")); |
||
368 | jTxtNomCapa.addKeyListener(new java.awt.event.KeyAdapter() {
|
||
369 | public void keyTyped(java.awt.event.KeyEvent e) { |
||
370 | fireWizardComplete(isCorrectlyConfigured()); |
||
371 | } |
||
372 | }); |
||
373 | } |
||
374 | |||
375 | return jTxtNomCapa;
|
||
376 | } |
||
377 | |||
378 | /**
|
||
379 | * This method initializes jPanel1
|
||
380 | *
|
||
381 | * @return Panel
|
||
382 | */
|
||
383 | 2243 | nbrodin | private JPanel getJPanelFormats() { |
384 | if (jPanelFormats == null) { |
||
385 | jPanelFormats = new JPanel(); |
||
386 | jPanelFormats.setLayout(null);
|
||
387 | jPanelFormats.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
388 | 1944 | nbrodin | null, PluginServices.getText(this, "select_formats"), |
389 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
390 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
391 | null));
|
||
392 | 2243 | nbrodin | jPanelFormats.setBounds(5, 10, 485, 140); |
393 | jPanelFormats.add(getJScrollPane6(), null);
|
||
394 | jPanelFormats.add(getChkTransparency(), null);
|
||
395 | 1944 | nbrodin | } |
396 | 2243 | nbrodin | return jPanelFormats;
|
397 | 1944 | nbrodin | } |
398 | |||
399 | /**
|
||
400 | * This method initializes jPanel5
|
||
401 | *
|
||
402 | * @return Panel
|
||
403 | */
|
||
404 | 2243 | nbrodin | private JPanel getJPanelSrsSelection() { |
405 | if (jPanelSrsSelection == null) { |
||
406 | jPanelSrsSelection = new JPanel(); |
||
407 | jPanelSrsSelection.setLayout(null);
|
||
408 | jPanelSrsSelection.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
409 | 1944 | nbrodin | null, PluginServices.getText(this, "seleccionar_srs"), |
410 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
411 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
412 | null));
|
||
413 | 2243 | nbrodin | jPanelSrsSelection.setBounds(5, 150, 485, 140); |
414 | jPanelSrsSelection.add(getJScrollPane2(), null);
|
||
415 | 1944 | nbrodin | } |
416 | 2243 | nbrodin | return jPanelSrsSelection;
|
417 | 1944 | nbrodin | } |
418 | |||
419 | /**
|
||
420 | * This method initializes jPanel6
|
||
421 | *
|
||
422 | * @return Panel
|
||
423 | */
|
||
424 | 2243 | nbrodin | private JPanel getJPanelInfoByPointFormat() { |
425 | if (jPanelInfoByPointFormat == null) { |
||
426 | jPanelInfoByPointFormat = new JPanel(); |
||
427 | jPanelInfoByPointFormat.setLayout(null);
|
||
428 | jPanelInfoByPointFormat.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
429 | 1944 | nbrodin | null, PluginServices.getText(this, "seleccionar_infobypoint_format"), |
430 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
431 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
|
||
432 | null));
|
||
433 | 2243 | nbrodin | jPanelInfoByPointFormat.setBounds(5, 295, 485, 78); |
434 | jPanelInfoByPointFormat.add(getJScrollPane3(), null);
|
||
435 | 1944 | nbrodin | } |
436 | 2243 | nbrodin | return jPanelInfoByPointFormat;
|
437 | 1944 | nbrodin | } |
438 | |||
439 | /**
|
||
440 | * This method initializes jScrollPane6
|
||
441 | *
|
||
442 | * @return ScrollPane
|
||
443 | */
|
||
444 | private JScrollPane getJScrollPane6() { |
||
445 | if (jScrollPane6 == null) { |
||
446 | jScrollPane6 = new JScrollPane(); |
||
447 | jScrollPane6.setBounds(5, 23, 470, 110); |
||
448 | jScrollPane6.setViewportView(getLstFormats()); |
||
449 | jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 180)); |
||
450 | } |
||
451 | |||
452 | return jScrollPane6;
|
||
453 | } |
||
454 | |||
455 | /**
|
||
456 | * This method initializes jScrollPane2
|
||
457 | *
|
||
458 | * @return ScrollPane
|
||
459 | */
|
||
460 | private JScrollPane getJScrollPane2() { |
||
461 | if (jScrollPane2 == null) { |
||
462 | jScrollPane2 = new JScrollPane(); |
||
463 | jScrollPane2.setBounds(5, 23, 470, 110); |
||
464 | jScrollPane2.setViewportView(getLstSRSs()); |
||
465 | jScrollPane2.setPreferredSize(new java.awt.Dimension(250, 180)); |
||
466 | } |
||
467 | |||
468 | return jScrollPane2;
|
||
469 | } |
||
470 | |||
471 | /**
|
||
472 | * This method initializes jScrollPane3
|
||
473 | *
|
||
474 | * @return ScrollPane
|
||
475 | */
|
||
476 | private JScrollPane getJScrollPane3() { |
||
477 | if (jScrollPane3 == null) { |
||
478 | jScrollPane3 = new JScrollPane(); |
||
479 | jScrollPane3.setBounds(5, 23, 470, 45); |
||
480 | jScrollPane3.setViewportView(getLstInfoFormats()); |
||
481 | jScrollPane3.setPreferredSize(new java.awt.Dimension(250, 120)); |
||
482 | } |
||
483 | |||
484 | return jScrollPane3;
|
||
485 | } |
||
486 | |||
487 | /**
|
||
488 | * Gets the available layers in WMS maintaining the tree structure
|
||
489 | *
|
||
490 | * @return
|
||
491 | */
|
||
492 | public LayerTree getLayerStructure() {
|
||
493 | return treeLayers;
|
||
494 | } |
||
495 | |||
496 | /**
|
||
497 | * This method initializes treeLayers
|
||
498 | *
|
||
499 | * @return Tree
|
||
500 | */
|
||
501 | private LayerTree getTreeLayers() {
|
||
502 | if (treeLayers == null) { |
||
503 | treeLayers = new LayerTree();
|
||
504 | treeLayers.setRootVisible(true);
|
||
505 | treeLayers.addMouseListener(new java.awt.event.MouseAdapter() {
|
||
506 | public void mouseClicked(java.awt.event.MouseEvent e) { |
||
507 | if (e.getClickCount() == 2) { |
||
508 | addLayer(); |
||
509 | } |
||
510 | } |
||
511 | }); |
||
512 | treeLayers |
||
513 | .addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
|
||
514 | public void valueChanged( |
||
515 | javax.swing.event.TreeSelectionEvent e) { |
||
516 | |||
517 | boolean isGetMapable = false; |
||
518 | TreePath[] selecciones = getTreeLayers() |
||
519 | .getSelectionPaths(); |
||
520 | if (selecciones != null) { |
||
521 | for (int i = 0; i < selecciones.length |
||
522 | && !isGetMapable; i++) { |
||
523 | WMSLayerNode layer = ((WMSLayerNode) selecciones[i] |
||
524 | .getLastPathComponent()); |
||
525 | isGetMapable = layer.getChildren().size() == 0
|
||
526 | || layer.getName() != null;
|
||
527 | } |
||
528 | |||
529 | } |
||
530 | getBtnAdd().setEnabled(isGetMapable); |
||
531 | fireWizardComplete(isCorrectlyConfigured()); |
||
532 | } |
||
533 | }); |
||
534 | } |
||
535 | |||
536 | return treeLayers;
|
||
537 | } |
||
538 | |||
539 | /**
|
||
540 | * This method checks for the options selected within the configuration
|
||
541 | * dialog are correct and enough to perform a GetMap request.
|
||
542 | *
|
||
543 | * @return true if you're done, false if not.
|
||
544 | */
|
||
545 | public boolean isCorrectlyConfigured() { |
||
546 | |||
547 | boolean b;
|
||
548 | this.repaint();
|
||
549 | boolean infoFormatOk = ((getLstInfoFormats().getModel().getSize()!= 0 && |
||
550 | getLstInfoFormats().getSelectedIndex() != -1) ||
|
||
551 | getLstInfoFormats().getModel().getSize() == 0);
|
||
552 | if ((getLstSRSs().getSelectedIndex() != -1) |
||
553 | && (getLstFormats().getSelectedIndex() != -1)
|
||
554 | && infoFormatOk |
||
555 | && (getLstSelectedLayers().getModel().getSize() > 0)) {
|
||
556 | b = true;
|
||
557 | } else {
|
||
558 | b = false;
|
||
559 | } |
||
560 | |||
561 | // Enable or disable del button.
|
||
562 | int[] selectedIndices = getLstSelectedLayers().getSelectedIndices(); |
||
563 | |||
564 | getBtnDel().setEnabled(selectedIndices != null && selectedIndices.length > 0); |
||
565 | |||
566 | return b;
|
||
567 | } |
||
568 | |||
569 | public WMSLayerNode[] selectedLayersToArray() { |
||
570 | JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers.getModel()); |
||
571 | ArrayList elements = modelo.getElements();
|
||
572 | WMSLayerNode[] layers = (WMSLayerNode[]) elements |
||
573 | .toArray(new WMSLayerNode[0]); |
||
574 | return layers;
|
||
575 | } |
||
576 | |||
577 | /**
|
||
578 | * DOCUMENT ME!
|
||
579 | */
|
||
580 | private void delLayer() { |
||
581 | int[] indices = lstSelectedLayers.getSelectedIndices(); |
||
582 | |||
583 | try {
|
||
584 | ArrayList removeList = new ArrayList(); |
||
585 | WMSLayerNode[] infos = selectedLayersToArray();
|
||
586 | JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers |
||
587 | .getModel()); |
||
588 | for (int i = 0; i < indices.length; i++) { |
||
589 | removeList.add(infos[indices[i]]); |
||
590 | } |
||
591 | modelo.delIndices(indices); |
||
592 | lstSelectedLayers.clearSelection(); |
||
593 | fireWizardComplete(isCorrectlyConfigured()); |
||
594 | |||
595 | // delete from selectedPaths as well
|
||
596 | WMSLayerNode elemento = null;
|
||
597 | WMSLayerNode last = null;
|
||
598 | TreePath path = null; |
||
599 | for (int i = removeList.size() - 1; i >= 0; i--) { |
||
600 | elemento = (WMSLayerNode) removeList.get(i); |
||
601 | for (int j = 0; j < selectedPaths.size(); j++) { |
||
602 | path = (TreePath) selectedPaths.get(j);
|
||
603 | last = (WMSLayerNode) path.getLastPathComponent(); |
||
604 | if (last.getTitle().compareTo(elemento.getTitle()) == 0) { |
||
605 | selectedPaths.remove(path); |
||
606 | } |
||
607 | } |
||
608 | } |
||
609 | |||
610 | refreshData(); |
||
611 | refreshInfo(); |
||
612 | } catch (ArrayIndexOutOfBoundsException ex) { |
||
613 | // if you reach this, please, tell me how you did it.
|
||
614 | ex.printStackTrace(); |
||
615 | } |
||
616 | } |
||
617 | |||
618 | /**
|
||
619 | * Fires a notification to this wizard listeners telling them if the
|
||
620 | * configuration is fair enough to send a GetMap request.
|
||
621 | *
|
||
622 | * @param b
|
||
623 | */
|
||
624 | private void fireWizardComplete(boolean b) { |
||
625 | listenerSupport.callStateChanged(b); |
||
626 | callStateChanged(b); |
||
627 | } |
||
628 | |||
629 | /**
|
||
630 | * Refreshes the content shown by this.
|
||
631 | */
|
||
632 | public void refreshData() { |
||
633 | JDnDListModel model = (JDnDListModel) lstSelectedLayers.getModel(); |
||
634 | if(model.getSize() > 1) |
||
635 | setLayerName(groupName); |
||
636 | else if(model.getSize() == 1) |
||
637 | setLayerName(model.getElementAt(0).toString());
|
||
638 | else
|
||
639 | setLayerName(PluginServices.getText(this, "WMSLayer")); |
||
640 | refreshSRS(); |
||
641 | getLstSelectedLayers().repaint(); |
||
642 | refreshStyleTree(); |
||
643 | refreshDimensions(); |
||
644 | |||
645 | } |
||
646 | |||
647 | /**
|
||
648 | * Refreshes the info tab
|
||
649 | *
|
||
650 | */
|
||
651 | public void refreshInfo() { |
||
652 | getTabInfo().refresh(explorer, selectedLayersVector(), |
||
653 | getStyleTitles(), getFormat(), getInfoFormat(), getSRS(), getDimensions()); |
||
654 | } |
||
655 | |||
656 | private void refreshDimensions() { |
||
657 | int size = getLstSelectedLayers().getModel().getSize();
|
||
658 | boolean enable = false; |
||
659 | for (int i = 0; i < size; i++) { |
||
660 | WMSLayerNode node = (WMSLayerNode) getLstSelectedLayers() |
||
661 | .getModel().getElementAt(i); |
||
662 | if (node.getDimensions() == null) { |
||
663 | continue;
|
||
664 | } |
||
665 | |||
666 | for (int j = 0; j < node.getDimensions().size(); j++) { |
||
667 | RemoteTimeDimension dim = (RemoteTimeDimension) node |
||
668 | .getDimensions().get(j); |
||
669 | |||
670 | try {
|
||
671 | getTabDimensions().addDimension(dim); |
||
672 | enable = true;
|
||
673 | } catch (IllegalArgumentException e) { |
||
674 | NotificationManager.addWarning( |
||
675 | "Unrecognized dimension expression: "
|
||
676 | + dim.getExpression() + " (for "
|
||
677 | + dim.getName() + " in layer '"
|
||
678 | + node.getName() + "')", null); |
||
679 | } |
||
680 | } |
||
681 | } |
||
682 | jTabbedPane.setEnabledAt(dimensionTabIndex, enable); |
||
683 | |||
684 | } |
||
685 | |||
686 | /**
|
||
687 | *
|
||
688 | */
|
||
689 | private void refreshStyleTree() { |
||
690 | |||
691 | int size = getLstSelectedLayers().getModel().getSize();
|
||
692 | WMSLayerNode styleRoot = new WMSLayerNode();
|
||
693 | styleRoot.setTitle(PluginServices.getText(this, "selected_layers")); |
||
694 | |||
695 | StyleTreeModel model = new StyleTreeModel(styleRoot);
|
||
696 | jTabbedPane.setEnabledAt(stylesTabIndex, false);
|
||
697 | for (int i = 0; i < size; i++) { |
||
698 | WMSLayerNode node = (WMSLayerNode) getLstSelectedLayers() |
||
699 | .getModel().getElementAt(i); |
||
700 | // If any of the layers defines styles, the tab will be enabled.
|
||
701 | if (model.addLayerBranch(node)) {
|
||
702 | jTabbedPane.setEnabledAt(stylesTabIndex, true);
|
||
703 | } |
||
704 | } |
||
705 | |||
706 | getStyleTree().setModel(model); |
||
707 | getStyleTree().expandAll(); |
||
708 | getStyleTree().repaint(); |
||
709 | } |
||
710 | |||
711 | /**
|
||
712 | * Takes the array of selected layers and a vector containing the style
|
||
713 | * names and set them as selected in the styles panel
|
||
714 | *
|
||
715 | * @param selectedLayers
|
||
716 | * @param styles
|
||
717 | */
|
||
718 | public void setStyleSelections(Vector<RemoteWMSStyle> styles) { |
||
719 | |||
720 | WMSLayerNode[] layers = selectedLayersToArray();
|
||
721 | int length = layers.length;
|
||
722 | for (int i = 0; i < length; i++) { |
||
723 | String styleName = styles.get(i).getName();
|
||
724 | layers[length - i - 1].setSelectedStyleByName(styleName);
|
||
725 | } |
||
726 | } |
||
727 | |||
728 | /**
|
||
729 | * Gets the currently shown style tree.
|
||
730 | *
|
||
731 | * @return
|
||
732 | */
|
||
733 | private StyleTree getStyleTree() {
|
||
734 | return getTabStyle().getStyleTree();
|
||
735 | } |
||
736 | |||
737 | /**
|
||
738 | * Method called when pressing the Add layer button or when double-clicking
|
||
739 | * on a layer from the server's layer tree.
|
||
740 | */
|
||
741 | public void addLayer() { |
||
742 | boolean alguno = false; |
||
743 | |||
744 | TreePath[] selecciones = getTreeLayers().getSelectionPaths(); |
||
745 | if (selecciones == null) { |
||
746 | return;
|
||
747 | } |
||
748 | for (int i = 0; i < selecciones.length; i++) { |
||
749 | selectedPaths.add(selecciones[i]); |
||
750 | WMSLayerNode nodo = (WMSLayerNode) selecciones[i] |
||
751 | .getLastPathComponent(); |
||
752 | if (nodo.getName() == null || nodo.getName().equals("")) { |
||
753 | continue;
|
||
754 | } |
||
755 | if (nodo.isSizeFixed()) {
|
||
756 | if (sizeFixed == null) { |
||
757 | sizeFixed = nodo.getFixedSize(); |
||
758 | } else if ((sizeFixed.getHeight() != nodo.getFixedSize() |
||
759 | .getHeight()) |
||
760 | || (sizeFixed.getWidth() != nodo.getFixedSize() |
||
761 | .getWidth())) { |
||
762 | JOptionPane.showMessageDialog((Component) PluginServices |
||
763 | .getMainFrame(), PluginServices.getText(this,
|
||
764 | "server_cant_render_layers"));
|
||
765 | continue;
|
||
766 | } |
||
767 | } |
||
768 | // s'afegeix a la llista de capes seleccionades
|
||
769 | JDnDListModel modelo = (JDnDListModel) lstSelectedLayers.getModel(); |
||
770 | |||
771 | try {
|
||
772 | 2243 | nbrodin | if (modelo.addElement(modelo.getSize(), nodo.clone())) {
|
773 | 1944 | nbrodin | alguno = true;
|
774 | } |
||
775 | } catch (CloneNotSupportedException e) { |
||
776 | } |
||
777 | } |
||
778 | |||
779 | if (alguno) {
|
||
780 | refreshData(); |
||
781 | } |
||
782 | refreshInfo(); |
||
783 | } |
||
784 | |||
785 | /**
|
||
786 | * This method initializes lstSelectedLayers
|
||
787 | *
|
||
788 | * @return List
|
||
789 | */
|
||
790 | public LayerList getLstSelectedLayers() {
|
||
791 | if (lstSelectedLayers == null) { |
||
792 | lstSelectedLayers = new LayerList();
|
||
793 | lstSelectedLayers.setModel(new JDnDListModel());
|
||
794 | lstSelectedLayers |
||
795 | .setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||
796 | lstSelectedLayers |
||
797 | .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
798 | public void valueChanged( |
||
799 | javax.swing.event.ListSelectionEvent e) { |
||
800 | fireWizardComplete(isCorrectlyConfigured()); |
||
801 | } |
||
802 | }); |
||
803 | lstSelectedLayers.addMouseListener(new MouseAdapter() { |
||
804 | public void mouseReleased(MouseEvent e) { |
||
805 | refreshData(); |
||
806 | } |
||
807 | }); |
||
808 | } |
||
809 | |||
810 | return lstSelectedLayers;
|
||
811 | } |
||
812 | |||
813 | /**
|
||
814 | * This method initializes lstSRSs
|
||
815 | *
|
||
816 | * @return JList
|
||
817 | */
|
||
818 | public JList getLstSRSs() { |
||
819 | if (lstSRSs == null) { |
||
820 | lstSRSs = new JList(); |
||
821 | lstSRSs.setModel(new SRSListModel());
|
||
822 | lstSRSs.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
823 | lstSRSs.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
824 | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
||
825 | int i = lstSRSs.getSelectedIndex();
|
||
826 | if (i != -1) { |
||
827 | oldSRS = (String) lstSRSs.getModel().getElementAt(i);
|
||
828 | } |
||
829 | fireWizardComplete(isCorrectlyConfigured()); |
||
830 | } |
||
831 | }); |
||
832 | } |
||
833 | return lstSRSs;
|
||
834 | } |
||
835 | |||
836 | /**
|
||
837 | * This method initializes lstSRSs
|
||
838 | *
|
||
839 | * @return JList
|
||
840 | */
|
||
841 | public JList getLstInfoFormats() { |
||
842 | if (lstInfoFormats == null) { |
||
843 | lstInfoFormats = new JList(); |
||
844 | lstInfoFormats.setModel(new SRSListModel());
|
||
845 | lstInfoFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
846 | lstInfoFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
847 | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
||
848 | fireWizardComplete(isCorrectlyConfigured()); |
||
849 | } |
||
850 | }); |
||
851 | } |
||
852 | |||
853 | return lstInfoFormats;
|
||
854 | } |
||
855 | |||
856 | /**
|
||
857 | * This method initializes lstFormats
|
||
858 | *
|
||
859 | * @return List
|
||
860 | */
|
||
861 | public JList getLstFormats() { |
||
862 | if (lstFormats == null) { |
||
863 | lstFormats = new JList(); |
||
864 | lstFormats.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
||
865 | lstFormats.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||
866 | public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
||
867 | fireWizardComplete(isCorrectlyConfigured()); |
||
868 | } |
||
869 | }); |
||
870 | } |
||
871 | |||
872 | return lstFormats;
|
||
873 | } |
||
874 | |||
875 | /**
|
||
876 | * Refreshes the SRS list
|
||
877 | */
|
||
878 | private void refreshSRS() { |
||
879 | ArrayList elements = ((JDnDListModel) lstSelectedLayers.getModel())
|
||
880 | .getElements(); |
||
881 | WMSLayerNode[] layers = (WMSLayerNode[]) elements |
||
882 | .toArray(new WMSLayerNode[0]); |
||
883 | |||
884 | SRSListModel model = new SRSListModel();
|
||
885 | |||
886 | if (layers.length == 0) { |
||
887 | lstSRSs.setModel(model);// new DefaultListModel());
|
||
888 | sizeFixed = null;
|
||
889 | } else {
|
||
890 | TreeSet srsSet = new TreeSet(); |
||
891 | srsSet.addAll(layers[0].getAllSrs());
|
||
892 | model.setAll(srsSet); |
||
893 | for (int i = 1; i < layers.length; i++) { |
||
894 | model.setAll(model.intersect(layers[i].getAllSrs())); |
||
895 | } |
||
896 | lstSRSs.setModel(model); |
||
897 | } |
||
898 | int srsIndex = getSRSIndex(oldSRS);
|
||
899 | if (srsIndex != -1) { |
||
900 | getLstSRSs().setSelectedIndex(srsIndex); |
||
901 | } |
||
902 | |||
903 | } |
||
904 | |||
905 | public void setListenerSupport(WizardListenerSupport support) { |
||
906 | listenerSupport = support; |
||
907 | } |
||
908 | |||
909 | public void setWizardData(WMSServerExplorer data) { |
||
910 | this.explorer = data;
|
||
911 | ((JDnDListModel) getLstSelectedLayers().getModel()).clear(); |
||
912 | getLstSelectedLayers().repaint(); |
||
913 | |||
914 | getLstFormats().setModel( |
||
915 | new FormatListModel(this.explorer.getFormats())); |
||
916 | getLstInfoFormats().setModel( |
||
917 | new FormatListModel(this.explorer.getInfoFormats())); |
||
918 | getTreeLayers() |
||
919 | .setModel(new LayerTreeModel(this.explorer.getLayerTree())); |
||
920 | refreshInfo(); |
||
921 | } |
||
922 | |||
923 | private Vector getStyleTitles() { |
||
924 | return getTabStyle().getStyleTree().getStyleSelectionTitles();
|
||
925 | } |
||
926 | |||
927 | /**
|
||
928 | * @return
|
||
929 | */
|
||
930 | private Vector selectedLayersVector() { |
||
931 | JDnDListModel mod = (JDnDListModel) getLstSelectedLayers().getModel(); |
||
932 | Vector lyrs = new Vector(); |
||
933 | for (int i = 0; i < mod.getSize(); i++) { |
||
934 | lyrs.add(mod.getElementAt(i)); |
||
935 | } |
||
936 | return lyrs;
|
||
937 | } |
||
938 | |||
939 | public String getFormat() { |
||
940 | return (String) getLstFormats().getSelectedValue(); |
||
941 | } |
||
942 | |||
943 | public String getInfoFormat() { |
||
944 | return (String) getLstInfoFormats().getSelectedValue(); |
||
945 | } |
||
946 | |||
947 | public String getLayersQuery() { |
||
948 | ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel())
|
||
949 | .getElements(); |
||
950 | WMSLayerNode[] layers = (WMSLayerNode[]) elements |
||
951 | .toArray(new WMSLayerNode[0]); |
||
952 | |||
953 | // Nombre separado por comas de las capas
|
||
954 | String layersQuery = layers[layers.length - 1].getName(); |
||
955 | |||
956 | for (int i = layers.length - 2; i >= 0; i--) { |
||
957 | layersQuery += ("," + layers[i].getName());
|
||
958 | } |
||
959 | |||
960 | return layersQuery;
|
||
961 | |||
962 | } |
||
963 | |||
964 | /**
|
||
965 | * Returns the current selected SRS.
|
||
966 | *
|
||
967 | * @return
|
||
968 | */
|
||
969 | public String getSRS() { |
||
970 | return (String) getLstSRSs().getSelectedValue(); |
||
971 | } |
||
972 | |||
973 | /**
|
||
974 | * Returns the name of the layer that the user has typed-in
|
||
975 | *
|
||
976 | * @return
|
||
977 | */
|
||
978 | public String getLayerName() { |
||
979 | return getJTxtNomCapa().getText();
|
||
980 | } |
||
981 | |||
982 | public void setLayerName(String name) { |
||
983 | getJTxtNomCapa().setText(name); |
||
984 | } |
||
985 | |||
986 | public Rectangle2D getLayersRectangle() throws ProjectionLayerException { |
||
987 | ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel())
|
||
988 | .getElements(); |
||
989 | WMSLayerNode[] layers = (WMSLayerNode[]) elements |
||
990 | .toArray(new WMSLayerNode[0]); |
||
991 | String[] layerNames = new String[layers.length]; |
||
992 | for (int i = 0; i < layerNames.length; i++) { |
||
993 | layerNames[i] = layers[i].getName(); |
||
994 | } |
||
995 | return explorer.getBoundingBox(layerNames, getSRS());
|
||
996 | } |
||
997 | |||
998 | public TreePath[] getSelectedLayers() { |
||
999 | return getTreeLayers().getSelectionPaths();
|
||
1000 | } |
||
1001 | |||
1002 | public Hashtable getOnlineResources() { |
||
1003 | return explorer.getOnlineResources();
|
||
1004 | } |
||
1005 | |||
1006 | /**
|
||
1007 | * The piece of the GetMap request that has the layer names.
|
||
1008 | *
|
||
1009 | * @return
|
||
1010 | */
|
||
1011 | public String getQueryableLayerQuery() { |
||
1012 | ArrayList elements = ((JDnDListModel) getLstSelectedLayers().getModel())
|
||
1013 | .getElements(); |
||
1014 | WMSLayerNode[] layers = (WMSLayerNode[]) elements |
||
1015 | .toArray(new WMSLayerNode[0]); |
||
1016 | // Nombre separado por comas de las capas
|
||
1017 | String layersQuery = ""; |
||
1018 | int i;
|
||
1019 | |||
1020 | for (i = 0; i < layers.length; i++) { |
||
1021 | if (layers[i].isQueryable()) {
|
||
1022 | layersQuery = layers[i].getName(); |
||
1023 | |||
1024 | break;
|
||
1025 | } |
||
1026 | } |
||
1027 | |||
1028 | for (int j = i + 1; j < layers.length; j++) { |
||
1029 | if (layers[j].isQueryable()) {
|
||
1030 | layersQuery += ("," + layers[j].getName());
|
||
1031 | } |
||
1032 | } |
||
1033 | |||
1034 | return layersQuery;
|
||
1035 | } |
||
1036 | |||
1037 | /**
|
||
1038 | * Returns the index of the CRS within the CRS list.
|
||
1039 | *
|
||
1040 | * Devuelve la posicion que ocupa el CRS en la lista de CRS
|
||
1041 | *
|
||
1042 | * @param crs
|
||
1043 | * @return The CRS's index if it exists, -1 if it not exists.
|
||
1044 | */
|
||
1045 | public int getSRSIndex(String crs) { |
||
1046 | for (int i = 0; i < getLstSRSs().getModel().getSize(); i++) { |
||
1047 | if (crs != null |
||
1048 | && crs.equals(getLstSRSs().getModel().getElementAt(i))) { |
||
1049 | return i;
|
||
1050 | } |
||
1051 | } |
||
1052 | return -1; |
||
1053 | } |
||
1054 | |||
1055 | /**
|
||
1056 | * Returns the index of the format within the formats list.
|
||
1057 | *
|
||
1058 | * Devuelve la posicion que ocupa el formato en la lista de formatos
|
||
1059 | *
|
||
1060 | * @param format
|
||
1061 | *
|
||
1062 | * @return The format's index if it exists, -1 if it not exists.
|
||
1063 | */
|
||
1064 | public int getFormatIndex(String format) { |
||
1065 | for (int i = 0; i < getLstFormats().getModel().getSize(); i++) { |
||
1066 | if (format != null |
||
1067 | && format |
||
1068 | .equals(getLstFormats().getModel().getElementAt(i))) { |
||
1069 | return i;
|
||
1070 | } |
||
1071 | } |
||
1072 | return -1; |
||
1073 | } |
||
1074 | |||
1075 | /**
|
||
1076 | * Returns the index of the format within the formats list.
|
||
1077 | *
|
||
1078 | * Devuelve la posicion que ocupa el formato en la lista de formatos
|
||
1079 | *
|
||
1080 | * @param format
|
||
1081 | *
|
||
1082 | * @return The format's index if it exists, -1 if it not exists.
|
||
1083 | */
|
||
1084 | public int getInfoFormatIndex(String infoformat) { |
||
1085 | for (int i = 0; i < getLstInfoFormats().getModel().getSize(); i++) { |
||
1086 | if (infoformat != null |
||
1087 | && infoformat.equals(getLstInfoFormats().getModel().getElementAt(i))) { |
||
1088 | return i;
|
||
1089 | } |
||
1090 | } |
||
1091 | return -1; |
||
1092 | } |
||
1093 | |||
1094 | /**
|
||
1095 | * This method initializes jTabbedPane
|
||
1096 | *
|
||
1097 | * @return TabbedPane
|
||
1098 | */
|
||
1099 | public JTabbedPane getJTabbedPane() { |
||
1100 | if (jTabbedPane == null) { |
||
1101 | jTabbedPane = new JTabbedPane(); |
||
1102 | jTabbedPane.setBounds(4, 4, 502, 415); |
||
1103 | InfoPanel ip = getTabInfo(); |
||
1104 | ip.addFocusListener(new FocusListener() { |
||
1105 | public void focusGained(FocusEvent e) { |
||
1106 | refreshInfo(); |
||
1107 | } |
||
1108 | |||
1109 | public void focusLost(FocusEvent e) { |
||
1110 | } |
||
1111 | }); |
||
1112 | |||
1113 | StylesPanel sp = getTabStyle(); |
||
1114 | DimensionPanel dp = getTabDimensions(); |
||
1115 | |||
1116 | jTabbedPane.addTab(PluginServices.getText(this, "info"), null, ip, |
||
1117 | null);
|
||
1118 | jTabbedPane.addTab(PluginServices.getText(this, "capas"), null, |
||
1119 | getTabLayers(), null);
|
||
1120 | jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null, |
||
1121 | sp, null);
|
||
1122 | stylesTabIndex = jTabbedPane.getTabCount() - 1;
|
||
1123 | jTabbedPane.addTab(PluginServices.getText(this, "dimensiones"), |
||
1124 | null, dp, null); |
||
1125 | dimensionTabIndex = jTabbedPane.getTabCount() - 1;
|
||
1126 | jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null, |
||
1127 | getTabFormats(), null);
|
||
1128 | jTabbedPane.setEnabledAt(dimensionTabIndex, false);
|
||
1129 | jTabbedPane.setEnabledAt(stylesTabIndex, false);
|
||
1130 | } |
||
1131 | return jTabbedPane;
|
||
1132 | } |
||
1133 | |||
1134 | /**
|
||
1135 | * This method initializes jPanel
|
||
1136 | *
|
||
1137 | * @return Panel
|
||
1138 | */
|
||
1139 | private JPanel getTabLayers() { |
||
1140 | if (tabLayers == null) { |
||
1141 | tabLayers = new JPanel(); |
||
1142 | tabLayers.setLayout(null);
|
||
1143 | tabLayers.add(getJPanel4(), null);
|
||
1144 | tabLayers.add(getJPanel2(), null);
|
||
1145 | } |
||
1146 | return tabLayers;
|
||
1147 | } |
||
1148 | |||
1149 | /**
|
||
1150 | * This method initializes jPanel6
|
||
1151 | *
|
||
1152 | * @return Panel
|
||
1153 | */
|
||
1154 | private StylesPanel getTabStyle() {
|
||
1155 | if (tabStyle == null) { |
||
1156 | tabStyle = new StylesPanel(this); |
||
1157 | tabStyle.setEnabled(false);
|
||
1158 | tabStyle.addListener(new BeanListener() {
|
||
1159 | public void beanValueChanged(Object value) { |
||
1160 | fireWizardComplete(isCorrectlyConfigured()); |
||
1161 | }; |
||
1162 | }); |
||
1163 | tabStyle.addFocusListener(new FocusAdapter() { |
||
1164 | public void focusGained(FocusEvent e) { |
||
1165 | refreshStyleTree(); |
||
1166 | } |
||
1167 | }); |
||
1168 | } |
||
1169 | return tabStyle;
|
||
1170 | } |
||
1171 | |||
1172 | /**
|
||
1173 | * Sets the focus to the tab next to the current one.
|
||
1174 | *
|
||
1175 | * Enfoca a la solapa siguiente a la actualmente enfocada del TabbedPane
|
||
1176 | *
|
||
1177 | */
|
||
1178 | public void avanzaTab() { |
||
1179 | int currentPage = currentPage();
|
||
1180 | int nPages = getNumTabs();
|
||
1181 | if (nPages - 1 > currentPage) { |
||
1182 | getJTabbedPane().setSelectedIndex(nextEnabledPage()); |
||
1183 | } |
||
1184 | } |
||
1185 | |||
1186 | /**
|
||
1187 | * Sets the focus to the tab previous to the current one.
|
||
1188 | *
|
||
1189 | * Enfoca a la solapa anterior a la actualmente enfocada del TabbedPane
|
||
1190 | *
|
||
1191 | */
|
||
1192 | public void retrocedeTab() { |
||
1193 | this.getJTabbedPane().setSelectedIndex(previousEnabledPage());
|
||
1194 | |||
1195 | } |
||
1196 | |||
1197 | /**
|
||
1198 | * Returns the index of the current tab.
|
||
1199 | *
|
||
1200 | * Devuelve el ?ndice de la p?gina actual del wizard.
|
||
1201 | *
|
||
1202 | * @return
|
||
1203 | */
|
||
1204 | public int currentPage() { |
||
1205 | return getJTabbedPane().getSelectedIndex();
|
||
1206 | } |
||
1207 | |||
1208 | /**
|
||
1209 | * Returns the tab amount that the WMSParamsPanel currently have
|
||
1210 | *
|
||
1211 | * Devuelve el n?mero de solapas que tiene actualmente el WMSParamsPanel
|
||
1212 | *
|
||
1213 | * @return int
|
||
1214 | */
|
||
1215 | public int getNumTabs() { |
||
1216 | return getJTabbedPane().getTabCount();
|
||
1217 | } |
||
1218 | |||
1219 | /**
|
||
1220 | * <p>
|
||
1221 | * Returns the index of the previous enabled tab.
|
||
1222 | * </p>
|
||
1223 | * <p>
|
||
1224 | * Devuelve el ?ndice de la anterior p?gina habilitada del wizard o -1
|
||
1225 | * si no hay ninguna.
|
||
1226 | * </p>
|
||
1227 | *
|
||
1228 | * @return The index, or -1 if there is no one.
|
||
1229 | */
|
||
1230 | public int previousEnabledPage() { |
||
1231 | int currentPage = currentPage();
|
||
1232 | int j = 0; |
||
1233 | if (currentPage == 0) { |
||
1234 | j = -1;
|
||
1235 | } |
||
1236 | for (int i = currentPage - 1; i > -1; i--) { |
||
1237 | if (getJTabbedPane().isEnabledAt(i)) {
|
||
1238 | j = i; |
||
1239 | break;
|
||
1240 | } |
||
1241 | } |
||
1242 | return j;
|
||
1243 | } |
||
1244 | |||
1245 | /**
|
||
1246 | * <p>
|
||
1247 | * Returns the previous of the previous enabled tab.
|
||
1248 | * </p>
|
||
1249 | * <p>
|
||
1250 | * Devuelve el ?ndice de la siguiente p?gina habilitada del wizard o -1
|
||
1251 | * si no hay ninguna.
|
||
1252 | * </p>
|
||
1253 | *
|
||
1254 | * @return The index, or -1 if there is no one.
|
||
1255 | */
|
||
1256 | public int nextEnabledPage() { |
||
1257 | int currentPage = currentPage();
|
||
1258 | int nPages = getNumTabs();
|
||
1259 | if (currentPage == nPages) {
|
||
1260 | return -1; |
||
1261 | } |
||
1262 | for (int i = currentPage + 1; i < nPages; i++) { |
||
1263 | if (getJTabbedPane().isEnabledAt(i)) {
|
||
1264 | return i;
|
||
1265 | } |
||
1266 | } |
||
1267 | return -1; |
||
1268 | } |
||
1269 | |||
1270 | /**
|
||
1271 | * Selects/deselects the transparency checkbox.
|
||
1272 | *
|
||
1273 | * @param b
|
||
1274 | */
|
||
1275 | public void setTransparent(boolean b) { |
||
1276 | getChkTransparency().setSelected(b); |
||
1277 | } |
||
1278 | |||
1279 | /**
|
||
1280 | * This method initializes chkTrasparency
|
||
1281 | *
|
||
1282 | * @return CheckBox
|
||
1283 | */
|
||
1284 | private JCheckBox getChkTransparency() { |
||
1285 | if (chkTransparency == null) { |
||
1286 | chkTransparency = new JCheckBox(); |
||
1287 | chkTransparency.setText(PluginServices.getText(this,
|
||
1288 | "wms_transparency"));
|
||
1289 | chkTransparency.setSelected(true);
|
||
1290 | chkTransparency.addItemListener(new java.awt.event.ItemListener() {
|
||
1291 | public void itemStateChanged(java.awt.event.ItemEvent e) { |
||
1292 | fireWizardComplete(isCorrectlyConfigured()); |
||
1293 | } |
||
1294 | }); |
||
1295 | chkTransparency.setBounds(5, 168, 441, 21); |
||
1296 | |||
1297 | } |
||
1298 | return chkTransparency;
|
||
1299 | } |
||
1300 | |||
1301 | /**
|
||
1302 | * Returns a vector of strings containing the styles selected for the
|
||
1303 | * layers. A blank style is correct and means that default style will be
|
||
1304 | * used.
|
||
1305 | *
|
||
1306 | * @return Vector
|
||
1307 | */
|
||
1308 | public Vector<RemoteWMSStyle> getStyles() { |
||
1309 | WMSLayerNode[] layers = selectedLayersToArray();
|
||
1310 | 2243 | nbrodin | Vector<RemoteWMSStyle> v = new Vector<RemoteWMSStyle>(layers.length); |
1311 | int posInsertion = 0; |
||
1312 | |||
1313 | for (int i = layers.length - 1; i >= 0; i--) { |
||
1314 | 1944 | nbrodin | RemoteWMSStyle sty = layers[i].getSelectedStyle(); |
1315 | if(sty != null) |
||
1316 | 2243 | nbrodin | v.add(posInsertion, sty); |
1317 | else {
|
||
1318 | RemoteWMSStyle s = new RemoteWMSStyle();
|
||
1319 | s.name = "default";
|
||
1320 | v.add(posInsertion, s); |
||
1321 | } |
||
1322 | posInsertion ++; |
||
1323 | 1944 | nbrodin | } |
1324 | return v;
|
||
1325 | } |
||
1326 | |||
1327 | public Vector<RemoteWMSStyle> getLayerStyle(String layerName) { |
||
1328 | Vector<RemoteWMSStyle> v = new Vector<RemoteWMSStyle>(); |
||
1329 | WMSLayerNode[] layers = selectedLayersToArray();
|
||
1330 | for (int i = 0; i < layers.length; i++) { |
||
1331 | if (layers[i].getName().equalsIgnoreCase(layerName)) {
|
||
1332 | RemoteWMSStyle sty = layers[i].getSelectedStyle(); |
||
1333 | v.add(sty); |
||
1334 | return v;
|
||
1335 | } |
||
1336 | } |
||
1337 | return v;
|
||
1338 | } |
||
1339 | |||
1340 | /**
|
||
1341 | * This method initializes tabInfo
|
||
1342 | *
|
||
1343 | * @return Panel
|
||
1344 | */
|
||
1345 | private InfoPanel getTabInfo() {
|
||
1346 | if (tabInfo == null) { |
||
1347 | tabInfo = new InfoPanel();
|
||
1348 | |||
1349 | } |
||
1350 | return tabInfo;
|
||
1351 | } |
||
1352 | |||
1353 | public void setDimensions(Vector dimensions) { |
||
1354 | for (int i = 0; i < dimensions.size(); i++) { |
||
1355 | String st = (String) dimensions.get(i); |
||
1356 | if (st.split("=").length == 2) { |
||
1357 | String[] s = st.split("="); |
||
1358 | getTabDimensions().setDimensionValue(s[0], s[1]); |
||
1359 | } |
||
1360 | } |
||
1361 | |||
1362 | } |
||
1363 | |||
1364 | /**
|
||
1365 | * This method initializes tabDimension
|
||
1366 | *
|
||
1367 | * @return Panel
|
||
1368 | */
|
||
1369 | private DimensionPanel getTabDimensions() {
|
||
1370 | if (tabDimensions == null) { |
||
1371 | tabDimensions = new DimensionPanel();
|
||
1372 | tabDimensions.setEnabled(false);
|
||
1373 | tabDimensions.addListener(new BeanListener() {
|
||
1374 | public void beanValueChanged(Object value) { |
||
1375 | Vector myDimensions = (Vector) value; |
||
1376 | if (value != null |
||
1377 | && (oldDimensions == null || !(oldDimensions.size() == myDimensions
|
||
1378 | .size() && oldDimensions |
||
1379 | .containsAll(myDimensions)))) { |
||
1380 | oldDimensions = myDimensions; |
||
1381 | } |
||
1382 | fireWizardComplete(isCorrectlyConfigured()); |
||
1383 | } |
||
1384 | }); |
||
1385 | |||
1386 | } |
||
1387 | return tabDimensions;
|
||
1388 | } |
||
1389 | |||
1390 | /**
|
||
1391 | * @return
|
||
1392 | */
|
||
1393 | public boolean getTransparency() { |
||
1394 | return getChkTransparency().isSelected();
|
||
1395 | } |
||
1396 | |||
1397 | /**
|
||
1398 | * @return
|
||
1399 | */
|
||
1400 | public Vector getDimensions() { |
||
1401 | return getTabDimensions().getDimensions();
|
||
1402 | } |
||
1403 | |||
1404 | public void initWizard() { |
||
1405 | } |
||
1406 | |||
1407 | public void execute() { |
||
1408 | } |
||
1409 | |||
1410 | // Gets all the layers available in the WMS Server
|
||
1411 | protected FLayer getAllSubTree(WMSLayerNode node) throws LoadLayerException { |
||
1412 | if (node.getChildren().size() > 0) { |
||
1413 | FLayers l = null;
|
||
1414 | if (this.getMapCtrl() == null) { |
||
1415 | org.gvsig.app.project.documents.view.gui.AbstractViewPanel v = (org.gvsig.app.project.documents.view.gui.AbstractViewPanel) PluginServices |
||
1416 | .getMDIManager().getActiveWindow(); |
||
1417 | l = new FLayers();
|
||
1418 | l.setMapContext(v.getMapControl().getMapContext()); |
||
1419 | } else {
|
||
1420 | l = new FLayers();
|
||
1421 | l.setMapContext(this.getMapCtrl().getMapContext());
|
||
1422 | } |
||
1423 | |||
1424 | l.setName(node.getTitle()); |
||
1425 | l.setVisible(false);
|
||
1426 | for (int i = 0; i < node.getChildren().size(); i++) { |
||
1427 | FLayer lyr = getAllSubTree((WMSLayerNode) node.getChildren() |
||
1428 | .get(i)); |
||
1429 | if (lyr != null) { |
||
1430 | l.addLayer(lyr); |
||
1431 | } |
||
1432 | } |
||
1433 | return l;
|
||
1434 | } else {
|
||
1435 | DataStoreParameters parameters = explorer.getStoreParameters(); |
||
1436 | WMSDataParameters par = null;
|
||
1437 | if(parameters instanceof WMSDataParameters) { |
||
1438 | par = (WMSDataParameters) parameters; |
||
1439 | } |
||
1440 | if(parameters instanceof TileDataParameters) { |
||
1441 | DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
||
1442 | if(p instanceof WMSDataParameters) |
||
1443 | par = (WMSDataParameters) p; |
||
1444 | } |
||
1445 | par.setFormat(getFormat()); |
||
1446 | par.setInfoFormat(getInfoFormat()); |
||
1447 | par.setLayerQuery(node.getName()); |
||
1448 | par.setInfoLayerQuery(getQueryableLayerQuery()); |
||
1449 | par.setSRS(getSRS()); |
||
1450 | par.setWmsTransparency(getTransparency()); |
||
1451 | par.setStyles(getLayerStyle(node.getName())); |
||
1452 | par.setDimensions(getDimensions()); |
||
1453 | par.setOnlineResources(getOnlineResources()); |
||
1454 | par.setFixedSize(getFixedSize()); |
||
1455 | par.setQueryable(explorer.isQueryable()); |
||
1456 | par.setName(node.getTitle()); |
||
1457 | par.setURI(explorer.getHost()); |
||
1458 | par.deleteCache(updating); |
||
1459 | |||
1460 | FLyrWMS layer = new FLyrWMS();
|
||
1461 | try {
|
||
1462 | layer.setParameters(parameters); |
||
1463 | layer.setExplorer(explorer); |
||
1464 | layer.setFullExtent(getLayersRectangle()); |
||
1465 | } catch (InitializeException e) {
|
||
1466 | throw new LoadLayerException("Error initializating layer", e); |
||
1467 | } |
||
1468 | layer.setVisible(false);
|
||
1469 | return layer;
|
||
1470 | } |
||
1471 | } |
||
1472 | |||
1473 | // Gets all the layers available in the WMS Server
|
||
1474 | public FLayer getAllLayers() throws LoadLayerException { |
||
1475 | LayerTree layerTree = getLayerStructure(); |
||
1476 | return getAllSubTree((WMSLayerNode) layerTree.getModel().getRoot());
|
||
1477 | } |
||
1478 | |||
1479 | // changed by Laura:
|
||
1480 | // To delegate getLayer to ParamsPanel from WMSWizard and WMSProps
|
||
1481 | // public FLayer getLayer() { return null; }
|
||
1482 | public FLayer getLayer(boolean cached) throws InitializeException { |
||
1483 | lastCached = cached; |
||
1484 | if (getDisagregatedLayers()) {
|
||
1485 | return getLayerTree();
|
||
1486 | } else {
|
||
1487 | return getLayerPlain(cached);
|
||
1488 | } |
||
1489 | } |
||
1490 | |||
1491 | public FLayer getLayer() throws InitializeException { |
||
1492 | return getLayer(lastCached);
|
||
1493 | } |
||
1494 | |||
1495 | /**
|
||
1496 | * If user does not select the chekbox Disagregate layers, will get the
|
||
1497 | * layer tree in WMS
|
||
1498 | *
|
||
1499 | * @return
|
||
1500 | * @throws LoadLayerException
|
||
1501 | */
|
||
1502 | protected FLayer getLayerTree() throws InitializeException { |
||
1503 | LayerTree layerTree = getLayerStructure(); |
||
1504 | TreePath[] selection = (TreePath[]) getSelectedPaths().toArray(new TreePath[0]); |
||
1505 | if (selection != null) { |
||
1506 | return getSubTree((WMSLayerNode) layerTree.getModel().getRoot(), selection);
|
||
1507 | } |
||
1508 | return null; |
||
1509 | } |
||
1510 | |||
1511 | protected boolean nodeSelected(TreePath[] selection, WMSLayerNode node) { |
||
1512 | for (int i = 0; i < selection.length; i++) { |
||
1513 | Object[] components = selection[i].getPath(); |
||
1514 | for (int j = 0; j < components.length; j++) { |
||
1515 | if (components[j] instanceof WMSLayerNode) { |
||
1516 | if (((WMSLayerNode) components[j]).getTitle().compareTo(
|
||
1517 | node.getTitle()) == 0) {
|
||
1518 | return true; |
||
1519 | } |
||
1520 | } |
||
1521 | } |
||
1522 | } |
||
1523 | return false; |
||
1524 | } |
||
1525 | |||
1526 | protected FLayer getSubTree(WMSLayerNode node, TreePath[] selection) throws InitializeException { |
||
1527 | if (node.getChildren().size() > 0) { |
||
1528 | FLayers l = null;
|
||
1529 | if (this.getMapCtrl() == null) { |
||
1530 | org.gvsig.app.project.documents.view.gui.AbstractViewPanel v = (org.gvsig.app.project.documents.view.gui.AbstractViewPanel) PluginServices |
||
1531 | .getMDIManager().getActiveWindow(); |
||
1532 | l = new FLayers();
|
||
1533 | l.setMapContext(v.getMapControl().getMapContext()); |
||
1534 | } else {
|
||
1535 | l = new FLayers();
|
||
1536 | l.setMapContext(this.getMapCtrl().getMapContext());
|
||
1537 | } |
||
1538 | |||
1539 | l.setName(node.getTitle()); |
||
1540 | for (int i = 0; i < node.getChildren().size(); i++) { |
||
1541 | if (nodeSelected(selection, (WMSLayerNode) (node.getChildren()
|
||
1542 | .get(i)))) { |
||
1543 | FLayer lyr = getSubTree((WMSLayerNode) node.getChildren() |
||
1544 | .get(i), selection); |
||
1545 | if (lyr != null) { |
||
1546 | l.addLayer(lyr); |
||
1547 | } |
||
1548 | } |
||
1549 | } |
||
1550 | return l;
|
||
1551 | } else {
|
||
1552 | if (nodeSelected(selection, node)) {
|
||
1553 | |||
1554 | DataStoreParameters parameters = explorer.getStoreParameters(); |
||
1555 | WMSDataParameters par = null;
|
||
1556 | if(parameters instanceof WMSDataParameters) { |
||
1557 | par = (WMSDataParameters) parameters; |
||
1558 | } |
||
1559 | if(parameters instanceof TileDataParameters) { |
||
1560 | DataParameters p = ((TileDataParameters) parameters).getDataParameters(); |
||
1561 | if(p instanceof WMSDataParameters) |
||
1562 | par = (WMSDataParameters) p; |
||
1563 | } |
||
1564 | par.setFormat(getFormat()); |
||
1565 | par.setInfoFormat(getInfoFormat()); |
||
1566 | par.setLayerQuery(node.getName()); |
||
1567 | par.setInfoLayerQuery(getQueryableLayerQuery()); |
||
1568 | par.setSRS(getSRS()); |
||
1569 | par.setWmsTransparency(getTransparency()); |
||
1570 | par.setStyles(getLayerStyle(node.getName())); |
||
1571 | par.setDimensions(getDimensions()); |
||
1572 | par.setOnlineResources(explorer.getOnlineResources()); |
||
1573 | par.setFixedSize(getFixedSize()); |
||
1574 | par.setQueryable(node.isQueryable()); |
||
1575 | par.setName(node.getTitle()); |
||
1576 | par.setURI(explorer.getHost()); |
||
1577 | par.deleteCache(updating); |
||
1578 | |||
1579 | FLyrWMS layer = new FLyrWMS();
|
||
1580 | try {
|
||
1581 | layer.setParameters(parameters); |
||
1582 | layer.setExplorer(explorer); |
||
1583 | layer.setFullExtent(getLayersRectangle()); |
||
1584 | } catch (InitializeException e) {
|
||
1585 | if (e.getCause() instanceof InvocationTargetException) { |
||
1586 | Throwable t = ((InvocationTargetException)e.getCause()).getTargetException().getCause(); |
||
1587 | if(t != null) { |
||
1588 | String msg = t.getMessage();
|
||
1589 | JOptionPane.showMessageDialog(this, msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
||
1590 | } |
||
1591 | log.info(e.getMessage(), e); |
||
1592 | } else {
|
||
1593 | throw e;
|
||
1594 | } |
||
1595 | return null; |
||
1596 | } catch (ProjectionLayerException e) {
|
||
1597 | throw new InitializeException(e); |
||
1598 | } |
||
1599 | return layer;
|
||
1600 | |||
1601 | } else {
|
||
1602 | return null; |
||
1603 | } |
||
1604 | } |
||
1605 | } |
||
1606 | |||
1607 | /**
|
||
1608 | * If user selects the chekbox Disagregate layers, will get the selected
|
||
1609 | * layers rendered in one the tree structure in WMS will be lost.
|
||
1610 | *
|
||
1611 | * @return
|
||
1612 | */
|
||
1613 | protected FLayer getLayerPlain(boolean cached) throws InitializeException { |
||
1614 | WMSDataParameters par = (WMSDataParameters)explorer.getStoreParameters(); |
||
1615 | DataStoreParameters parameters = par; |
||
1616 | |||
1617 | if(cached) {
|
||
1618 | DataManager manager = DALLocator.getDataManager(); |
||
1619 | TileDataParameters tileParams = null;
|
||
1620 | try {
|
||
1621 | tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
|
||
1622 | } catch (ProviderNotRegisteredException e) {
|
||
1623 | throw new InitializeException(e.getMessage(), e); |
||
1624 | } |
||
1625 | tileParams.setDataParameters(par); |
||
1626 | parameters = tileParams; |
||
1627 | } |
||
1628 | |||
1629 | par.setFormat(getFormat()); |
||
1630 | par.setInfoFormat(getInfoFormat()); |
||
1631 | par.setLayerQuery(getLayersQuery()); |
||
1632 | par.setInfoLayerQuery(getQueryableLayerQuery()); |
||
1633 | par.setSRS(getSRS()); |
||
1634 | par.setWmsTransparency(getTransparency()); |
||
1635 | par.setStyles(getStyles()); |
||
1636 | par.setDimensions(getDimensions()); |
||
1637 | par.setOnlineResources(explorer.getOnlineResources()); |
||
1638 | par.setFixedSize(getFixedSize()); |
||
1639 | par.setQueryable(explorer.isQueryable()); |
||
1640 | par.setName(getLayerName()); |
||
1641 | par.setURI(explorer.getHost()); |
||
1642 | par.deleteCache(updating); |
||
1643 | |||
1644 | FLyrWMS layer = new FLyrWMS();
|
||
1645 | try {
|
||
1646 | layer.setParameters(parameters); |
||
1647 | layer.setExplorer(explorer); |
||
1648 | layer.setFullExtent(getLayersRectangle()); |
||
1649 | layer.setName(getLayerName()); |
||
1650 | } catch (InitializeException e) {
|
||
1651 | String msg = getDriverExceptionMessage(e);
|
||
1652 | if(msg != null) { |
||
1653 | JOptionPane.showMessageDialog(this, msg, Messages.getText("Error"), JOptionPane.ERROR_MESSAGE); |
||
1654 | return null; |
||
1655 | } else
|
||
1656 | throw e;
|
||
1657 | } catch (ProjectionLayerException e) {
|
||
1658 | throw new InitializeException(e); |
||
1659 | } |
||
1660 | return layer;
|
||
1661 | } |
||
1662 | |||
1663 | /**
|
||
1664 | * Gets the <code>RasterDriverException</code> message. The message
|
||
1665 | * of this exception is returned by the server
|
||
1666 | * @param e
|
||
1667 | * @return
|
||
1668 | */
|
||
1669 | private String getDriverExceptionMessage(InitializeException e) { |
||
1670 | Throwable ex = e;
|
||
1671 | final int MAX_DEEP = 10; |
||
1672 | int deep = 0; |
||
1673 | while(deep < MAX_DEEP) {
|
||
1674 | Throwable t = null; |
||
1675 | if(ex instanceof RasterDriverException) { |
||
1676 | return ex.getMessage();
|
||
1677 | } else if(ex instanceof InitializeException) { |
||
1678 | t = ex.getCause(); |
||
1679 | } else if(ex instanceof InvocationTargetException) { |
||
1680 | t = ((InvocationTargetException)ex).getTargetException();
|
||
1681 | } |
||
1682 | if(t == null) |
||
1683 | return null; |
||
1684 | else
|
||
1685 | ex = t; |
||
1686 | deep++; |
||
1687 | } |
||
1688 | return null; |
||
1689 | } |
||
1690 | |||
1691 | public Dimension getFixedSize() { |
||
1692 | return sizeFixed;
|
||
1693 | } |
||
1694 | |||
1695 | /**
|
||
1696 | * This method initializes chkExtendedNames
|
||
1697 | *
|
||
1698 | * @return CheckBox
|
||
1699 | */
|
||
1700 | private JCheckBox getChkExtendedNames() { |
||
1701 | if (chkExtendedNames == null) { |
||
1702 | chkExtendedNames = new JCheckBox(); |
||
1703 | chkExtendedNames.setText(PluginServices.getText(this,
|
||
1704 | "show_layer_names"));
|
||
1705 | chkExtendedNames.addItemListener(new java.awt.event.ItemListener() {
|
||
1706 | public void itemStateChanged(java.awt.event.ItemEvent e) { |
||
1707 | boolean b = chkExtendedNames.isSelected();
|
||
1708 | getTreeLayers().showLayerNames = b; |
||
1709 | getTreeLayers().repaint(); |
||
1710 | getLstSelectedLayers().showLayerNames = b; |
||
1711 | getLstSelectedLayers().repaint(); |
||
1712 | getStyleTree().showLayerNames = b; |
||
1713 | } |
||
1714 | }); |
||
1715 | chkExtendedNames |
||
1716 | .addActionListener(new java.awt.event.ActionListener() {
|
||
1717 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
1718 | fPrefs.putBoolean("show_layer_names",
|
||
1719 | chkExtendedNames.isSelected()); |
||
1720 | } |
||
1721 | }); |
||
1722 | chkExtendedNames.setBounds(19, 300, 212, 20); |
||
1723 | chkExtendedNames.setSelected(fPrefs.getBoolean("show_layer_names",
|
||
1724 | false));
|
||
1725 | |||
1726 | } |
||
1727 | return chkExtendedNames;
|
||
1728 | } |
||
1729 | |||
1730 | /**
|
||
1731 | * This method initializes btnUp
|
||
1732 | *
|
||
1733 | * @return Button
|
||
1734 | */
|
||
1735 | private JButton getBtnUp() { |
||
1736 | if (btnUp == null) { |
||
1737 | btnUp = new JButton(); |
||
1738 | btnUp.setBounds(438, 184, 30, 30); |
||
1739 | btnUp.setToolTipText(PluginServices.getText(this, "move_layer_up")); |
||
1740 | btnUp.addActionListener(new java.awt.event.ActionListener() {
|
||
1741 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
1742 | LayerList list = getLstSelectedLayers(); |
||
1743 | int[] selectedIndices = list.getSelectedIndices(); |
||
1744 | int index = list.getSelectedIndex();
|
||
1745 | if (selectedIndices != null && selectedIndices.length == 1 |
||
1746 | && index > 0) {
|
||
1747 | JDnDListModel m = (JDnDListModel) list.getModel(); |
||
1748 | m.itemsMoved(index - 1, new int[] { index }); |
||
1749 | list.setSelectedIndex(index - 1);
|
||
1750 | } |
||
1751 | } |
||
1752 | }); |
||
1753 | btnUp.setIcon(IconThemeHelper.getImageIcon("aplication-preferences-uparrow"));
|
||
1754 | } |
||
1755 | return btnUp;
|
||
1756 | } |
||
1757 | |||
1758 | /**
|
||
1759 | * This method initializes btnDown
|
||
1760 | *
|
||
1761 | * @return Button
|
||
1762 | */
|
||
1763 | private JButton getBtnDown() { |
||
1764 | if (btnDown == null) { |
||
1765 | btnDown = new JButton(); |
||
1766 | btnDown.setBounds(438, 215, 30, 30); |
||
1767 | btnDown.setToolTipText(PluginServices.getText(this,
|
||
1768 | "move_layer_down"));
|
||
1769 | btnDown.addActionListener(new java.awt.event.ActionListener() {
|
||
1770 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
1771 | LayerList list = getLstSelectedLayers(); |
||
1772 | int[] selectedIndices = list.getSelectedIndices(); |
||
1773 | int index = list.getSelectedIndex();
|
||
1774 | if (selectedIndices != null |
||
1775 | && selectedIndices.length == 1
|
||
1776 | && index < getLstSelectedLayers().getModel() |
||
1777 | .getSize() - 1) {
|
||
1778 | JDnDListModel m = (JDnDListModel) list.getModel(); |
||
1779 | m.itemsMoved(index + 1, new int[] { index }); |
||
1780 | list.setSelectedIndex(index + 1);
|
||
1781 | } |
||
1782 | } |
||
1783 | }); |
||
1784 | btnDown.setIcon(IconThemeHelper.getImageIcon("aplication-preferences-downarrow"));
|
||
1785 | } |
||
1786 | return btnDown;
|
||
1787 | } |
||
1788 | |||
1789 | public void setFixedSize(Dimension sz) { |
||
1790 | sizeFixed = sz; |
||
1791 | } |
||
1792 | |||
1793 | public ArrayList getSelectedPaths() { |
||
1794 | return selectedPaths;
|
||
1795 | } |
||
1796 | |||
1797 | public LayerTree getJustTreeLayer() {
|
||
1798 | return treeLayers;
|
||
1799 | } |
||
1800 | |||
1801 | /**
|
||
1802 | * This method initializes chkDisagregate
|
||
1803 | *
|
||
1804 | * @return CheckBox
|
||
1805 | */
|
||
1806 | private JCheckBox getChkDisagregate() { |
||
1807 | if (chkDisagregate == null) { |
||
1808 | |||
1809 | chkDisagregate = new JCheckBox(); |
||
1810 | chkDisagregate.setBounds(new java.awt.Rectangle(19,276,269,20)); |
||
1811 | chkDisagregate.setText(PluginServices.getText(this,
|
||
1812 | "disagregate_layers"));
|
||
1813 | chkDisagregate.setSelected(false);
|
||
1814 | |||
1815 | } |
||
1816 | return chkDisagregate;
|
||
1817 | } |
||
1818 | |||
1819 | public boolean getDisagregatedLayers() { |
||
1820 | return chkDisagregate.isSelected();
|
||
1821 | } |
||
1822 | |||
1823 | public void disableDisagregatedLayers() { |
||
1824 | chkDisagregate.setEnabled(false);
|
||
1825 | } |
||
1826 | |||
1827 | @Override
|
||
1828 | public DataStoreParameters[] getParameters() { |
||
1829 | // TODO Auto-generated method stub
|
||
1830 | return null; |
||
1831 | } |
||
1832 | |||
1833 | @Override
|
||
1834 | public void close() { |
||
1835 | // Nothing to do
|
||
1836 | } |
||
1837 | |||
1838 | public WMSServerExplorer getExplorer() {
|
||
1839 | return explorer;
|
||
1840 | } |
||
1841 | } // @jve:decl-index=0:visual-constraint="10,10" |