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