svn-gvsig-desktop / tags / Root_v061 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FPanelLocConfig.java @ 4812
History | View | Annotate | Download (21.9 KB)
1 |
/*
|
---|---|
2 |
* Created on 18-jun-2004
|
3 |
*
|
4 |
* TODO To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.gui; |
48 |
|
49 |
import java.awt.Color; |
50 |
import java.awt.event.ActionEvent; |
51 |
import java.awt.event.ActionListener; |
52 |
import java.awt.geom.Rectangle2D; |
53 |
import java.io.File; |
54 |
|
55 |
import javax.swing.BorderFactory; |
56 |
import javax.swing.DefaultListModel; |
57 |
import javax.swing.JDialog; |
58 |
import javax.swing.JOptionPane; |
59 |
import javax.swing.JPanel; |
60 |
|
61 |
import org.cresques.cts.ICoordTrans; |
62 |
import org.cresques.cts.IProjection; |
63 |
import org.cresques.cts.ProjectionPool; |
64 |
import org.cresques.cts.gt2.CoordSys; |
65 |
import org.cresques.cts.gt2.CoordTrans; |
66 |
|
67 |
import com.hardcode.driverManager.Driver; |
68 |
import com.hardcode.driverManager.DriverLoadException; |
69 |
import com.hardcode.gdbms.engine.data.driver.DBDriver; |
70 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
71 |
import com.iver.andami.PluginServices; |
72 |
import com.iver.andami.messages.NotificationManager; |
73 |
import com.iver.andami.ui.mdiManager.View; |
74 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
75 |
import com.iver.cit.gvsig.fmap.DriverException; |
76 |
import com.iver.cit.gvsig.fmap.MapControl; |
77 |
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver; |
78 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
79 |
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
80 |
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
81 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
82 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
83 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
84 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
85 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
86 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
87 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
88 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
89 |
import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow; |
90 |
|
91 |
/**
|
92 |
* @author FJP
|
93 |
*
|
94 |
* TODO To change the template for this generated type comment go to
|
95 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
96 |
*/
|
97 |
public class FPanelLocConfig extends JPanel implements ActionListener,View { |
98 |
private javax.swing.JLabel jLabel = null; |
99 |
private javax.swing.JList jList = null; |
100 |
private javax.swing.JButton jBtnUp = null; |
101 |
private javax.swing.JButton jBtnDown = null; |
102 |
private javax.swing.JButton jBtnAddLayer = null; // |
103 |
private javax.swing.JButton jBtnRemoveLayer = null; |
104 |
private javax.swing.JButton jBtnEditLegend = null; |
105 |
private javax.swing.JButton jBtnCancel = null; |
106 |
|
107 |
//private JDialog m_Owner;
|
108 |
private MapControl mapCtrl;
|
109 |
private ViewInfo m_viewinfo = null; |
110 |
/**
|
111 |
* This is the default constructor
|
112 |
*/
|
113 |
public FPanelLocConfig( MapControl mc) {
|
114 |
super();
|
115 |
mapCtrl = mc; |
116 |
initialize(); |
117 |
refreshList(); |
118 |
updateControls(null);
|
119 |
} |
120 |
|
121 |
private void refreshList() |
122 |
{ |
123 |
DefaultListModel lstModel = (DefaultListModel) getJList().getModel(); |
124 |
lstModel.clear(); |
125 |
for (int i=mapCtrl.getMapContext().getLayers().getLayersCount()-1; i >=0; i--) |
126 |
{ |
127 |
FLayer lyr = mapCtrl.getMapContext().getLayers().getLayer(i); |
128 |
lstModel.addElement(lyr.getName()); |
129 |
} |
130 |
} |
131 |
|
132 |
/**
|
133 |
* This method initializes this
|
134 |
*
|
135 |
* @return void
|
136 |
*/
|
137 |
private void initialize() { |
138 |
this.setLayout(null); |
139 |
this.setSize(390, 250); |
140 |
this.setPreferredSize(new java.awt.Dimension(370,200)); |
141 |
this.add(getJLabel(), null); |
142 |
this.add(getJList(), null); |
143 |
this.add(getJBtnUp(), null); |
144 |
this.add(getJBtnDown(), null); |
145 |
this.add(getJBtnAddLayer(), null); |
146 |
this.add(getJBtnRemoveLayer(), null); |
147 |
this.add(getJBtnEditLegend(), null); |
148 |
this.add(getJBtnCancel(), null); |
149 |
} |
150 |
/**
|
151 |
|
152 |
* This method initializes jLabel
|
153 |
|
154 |
*
|
155 |
|
156 |
* @return javax.swing.JLabel
|
157 |
|
158 |
*/
|
159 |
private javax.swing.JLabel getJLabel() {
|
160 |
if (jLabel == null) { |
161 |
jLabel = new javax.swing.JLabel();
|
162 |
jLabel.setText(PluginServices.getText(this,"Capas_del_localizador")+":"); |
163 |
jLabel.setBounds(22, 15, 132, 25); |
164 |
} |
165 |
return jLabel;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
|
170 |
* This method initializes jList
|
171 |
|
172 |
*
|
173 |
|
174 |
* @return javax.swing.JList
|
175 |
|
176 |
*/
|
177 |
private javax.swing.JList getJList() {
|
178 |
if (jList == null) { |
179 |
jList = new javax.swing.JList(new DefaultListModel()); |
180 |
jList.setBounds(22, 49, 179, 139); |
181 |
jList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); |
182 |
jList.setBorder(BorderFactory.createLineBorder(Color.BLACK)); |
183 |
jList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
184 |
|
185 |
public void valueChanged(javax.swing.event.ListSelectionEvent e) { |
186 |
updateControls(e); |
187 |
} |
188 |
}); |
189 |
|
190 |
} |
191 |
return jList;
|
192 |
} |
193 |
|
194 |
private void updateControls(javax.swing.event.ListSelectionEvent e) |
195 |
{ |
196 |
System.out.println("valueChanged()"); // TODO Auto-generated Event stub valueChanged() |
197 |
DefaultListModel lstModel = (DefaultListModel) getJList().getModel(); |
198 |
int selIndex = jList.getSelectedIndex();
|
199 |
jBtnDown.setEnabled(false);
|
200 |
jBtnUp.setEnabled(false);
|
201 |
|
202 |
if (selIndex != -1) |
203 |
{ |
204 |
if (lstModel.getSize() > 1) |
205 |
{ |
206 |
if (selIndex < (lstModel.getSize()-1)) |
207 |
jBtnDown.setEnabled(true);
|
208 |
|
209 |
if (selIndex > 0) |
210 |
jBtnUp.setEnabled(true);
|
211 |
} |
212 |
|
213 |
} |
214 |
|
215 |
|
216 |
} |
217 |
|
218 |
/**
|
219 |
|
220 |
* This method initializes jBtnUp
|
221 |
|
222 |
*
|
223 |
|
224 |
* @return javax.swing.JButton
|
225 |
|
226 |
*/
|
227 |
private javax.swing.JButton getJBtnUp() {
|
228 |
if (jBtnUp == null) { |
229 |
jBtnUp = new javax.swing.plaf.basic.BasicArrowButton(
|
230 |
javax.swing.SwingConstants.NORTH); |
231 |
jBtnUp.setBounds(206, 49, 25, 23); |
232 |
jBtnUp.setToolTipText(PluginServices.getText(this,"Subir_capa")); |
233 |
jBtnUp.addActionListener(this);
|
234 |
jBtnUp.setActionCommand("UP");
|
235 |
|
236 |
} |
237 |
return jBtnUp;
|
238 |
} |
239 |
|
240 |
/**
|
241 |
|
242 |
* This method initializes jBtnDown
|
243 |
|
244 |
*
|
245 |
|
246 |
* @return javax.swing.JButton
|
247 |
|
248 |
*/
|
249 |
private javax.swing.JButton getJBtnDown() {
|
250 |
if (jBtnDown == null) { |
251 |
jBtnDown = new javax.swing.plaf.basic.BasicArrowButton(
|
252 |
javax.swing.SwingConstants.SOUTH); |
253 |
jBtnDown.setBounds(206, 164, 25, 23); |
254 |
jBtnDown.setToolTipText(PluginServices.getText(this,"Bajar_capa")); |
255 |
jBtnDown.setActionCommand("DOWN");
|
256 |
jBtnDown.addActionListener(this);
|
257 |
} |
258 |
return jBtnDown;
|
259 |
} |
260 |
|
261 |
/**
|
262 |
|
263 |
* This method initializes jButton2
|
264 |
|
265 |
*
|
266 |
|
267 |
* @return javax.swing.JButton
|
268 |
|
269 |
*/
|
270 |
private javax.swing.JButton getJBtnAddLayer() {
|
271 |
if (jBtnAddLayer == null) { |
272 |
jBtnAddLayer = new javax.swing.JButton();
|
273 |
jBtnAddLayer.setBounds(251, 49, 109, 23); |
274 |
jBtnAddLayer.setText(PluginServices.getText(this,"Anadir_capa")+"..."); |
275 |
jBtnAddLayer.addActionListener(this);
|
276 |
jBtnAddLayer.setActionCommand("ADD_LAYER");
|
277 |
} |
278 |
return jBtnAddLayer;
|
279 |
} |
280 |
|
281 |
/**
|
282 |
|
283 |
* This method initializes jBtnRemoveLayer
|
284 |
|
285 |
*
|
286 |
|
287 |
* @return javax.swing.JButton
|
288 |
|
289 |
*/
|
290 |
private javax.swing.JButton getJBtnRemoveLayer() {
|
291 |
if (jBtnRemoveLayer == null) { |
292 |
jBtnRemoveLayer = new javax.swing.JButton();
|
293 |
jBtnRemoveLayer.setBounds(251, 78, 109, 23); |
294 |
jBtnRemoveLayer.setText(PluginServices.getText(this,"Quitar_capa")+"..."); |
295 |
jBtnRemoveLayer.addActionListener(this);
|
296 |
jBtnRemoveLayer.setActionCommand("REMOVE_LAYER");
|
297 |
|
298 |
} |
299 |
return jBtnRemoveLayer;
|
300 |
} |
301 |
|
302 |
/**
|
303 |
|
304 |
* This method initializes jBtnEditLegend
|
305 |
|
306 |
*
|
307 |
|
308 |
* @return javax.swing.JButton
|
309 |
|
310 |
*/
|
311 |
private javax.swing.JButton getJBtnEditLegend() {
|
312 |
if (jBtnEditLegend == null) { |
313 |
jBtnEditLegend = new javax.swing.JButton();
|
314 |
jBtnEditLegend.setBounds(251, 113, 109, 23); |
315 |
jBtnEditLegend.setText(PluginServices.getText(this,"Editar_leyenda")+"..."); |
316 |
jBtnEditLegend.addActionListener(this);
|
317 |
jBtnEditLegend.setActionCommand("EDIT_LEGEND");
|
318 |
} |
319 |
return jBtnEditLegend;
|
320 |
} |
321 |
|
322 |
/**
|
323 |
|
324 |
* This method initializes jBtnCancel
|
325 |
|
326 |
*
|
327 |
|
328 |
* @return javax.swing.JButton
|
329 |
|
330 |
*/
|
331 |
private javax.swing.JButton getJBtnCancel() {
|
332 |
if (jBtnCancel == null) { |
333 |
jBtnCancel = new javax.swing.JButton();
|
334 |
jBtnCancel.setBounds(251, 162, 109, 23); |
335 |
jBtnCancel.setText(PluginServices.getText(this,"Cerrar")); |
336 |
jBtnCancel.setActionCommand("CANCEL");
|
337 |
jBtnCancel.addActionListener(this);
|
338 |
|
339 |
} |
340 |
return jBtnCancel;
|
341 |
} |
342 |
/* (non-Javadoc)
|
343 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
344 |
*/
|
345 |
public void actionPerformed(ActionEvent e) |
346 |
{ |
347 |
DefaultListModel lstModel = (DefaultListModel) getJList().getModel(); |
348 |
FLayers theLayers = mapCtrl.getMapContext().getLayers(); |
349 |
IProjection proj = null;
|
350 |
|
351 |
int numLayers = theLayers.getLayersCount()-1; |
352 |
|
353 |
if (e.getActionCommand() == "CANCEL") |
354 |
{ |
355 |
if (PluginServices.getMainFrame() != null) |
356 |
{ |
357 |
PluginServices.getMDIManager().closeView(FPanelLocConfig.this); |
358 |
} |
359 |
else
|
360 |
{ |
361 |
((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
362 |
} |
363 |
} |
364 |
if (e.getActionCommand() == "ADD_LAYER") |
365 |
{ |
366 |
FOpenDialog fopen = new FOpenDialog();
|
367 |
if (PluginServices.getMainFrame() != null) |
368 |
{ |
369 |
FileOpenDialog fileDlg = new FileOpenDialog(new Class[]{VectorialFileDriver.class, GeorreferencedRasterDriver.class}); |
370 |
// DataBaseOpenDialog dbop = new DataBaseOpenDialog();
|
371 |
// dbop.setClasses(new Class[] { DBDriver.class });
|
372 |
fopen.addTab("Fichero", fileDlg);
|
373 |
// fopen.addTab("Base de datos", dbop);
|
374 |
PluginServices.getMDIManager().addView(fopen); |
375 |
|
376 |
if (fopen.isAccepted()) {
|
377 |
// TODO: Hacer lo de la capa WMS tambi?n.
|
378 |
if (fileDlg.getFiles() == null) { |
379 |
return;
|
380 |
} |
381 |
proj =FOpenDialog.getLastProjection(); |
382 |
FLayer lyr = null;
|
383 |
File[] files = fileDlg.getFiles(); |
384 |
String[] driverNames = fileDlg.getDriverNames(); |
385 |
Driver[] drivers = new Driver[driverNames.length]; |
386 |
for (int i = 0; i < drivers.length; i++) { |
387 |
try {
|
388 |
drivers[i] = LayerFactory.getDM().getDriver(driverNames[i]); |
389 |
} catch (DriverLoadException e1) {
|
390 |
e1.printStackTrace(); |
391 |
} |
392 |
} |
393 |
Rectangle2D[] rects=new Rectangle2D[files.length]; |
394 |
boolean first=false; |
395 |
mapCtrl.getMapContext() |
396 |
.beginAtomicEvent(); |
397 |
|
398 |
for (int iFile = 0; iFile < files.length; iFile++) { |
399 |
File fich = files[iFile];
|
400 |
String layerName = fich.getName();
|
401 |
String layerPath = fich.getAbsolutePath();
|
402 |
|
403 |
try {
|
404 |
if (drivers[iFile] instanceof VectorialFileDriver){ |
405 |
lyr = LayerFactory.createLayer(layerName, (VectorialFileDriver) drivers[iFile], |
406 |
fich, proj); |
407 |
}else if (drivers[iFile] instanceof RasterDriver){ |
408 |
lyr = LayerFactory.createLayer(layerName, |
409 |
(RasterDriver) drivers[iFile], fich, proj); |
410 |
} |
411 |
|
412 |
if (lyr != null) { |
413 |
try {
|
414 |
|
415 |
lyr.setVisible(true);
|
416 |
mapCtrl.getMapContext().getLayers() |
417 |
.addLayer(lyr); |
418 |
try
|
419 |
{ |
420 |
// Le asignamos tambi?n una leyenda por defecto acorde con
|
421 |
// el tipo de shape que tenga. Tampoco s? si es aqu? el
|
422 |
// sitio adecuado, pero en fin....
|
423 |
if (lyr instanceof FLyrVect) |
424 |
{ |
425 |
FLyrVect lyrVect = (FLyrVect) lyr; |
426 |
// Comprobar que la projecci?n es la misma que la vista
|
427 |
if (proj != mapCtrl.getProjection()) {
|
428 |
int option = JOptionPane.showConfirmDialog(null, |
429 |
PluginServices.getText(this, "reproyectar_aviso"), |
430 |
PluginServices.getText(this, "reproyectar_pregunta"), |
431 |
JOptionPane.YES_NO_OPTION);
|
432 |
|
433 |
if (option == JOptionPane.NO_OPTION) { |
434 |
return;
|
435 |
} else {
|
436 |
ICoordTrans ct = new CoordTrans((CoordSys) proj,
|
437 |
(CoordSys) mapCtrl.getProjection()); |
438 |
lyrVect.setCoordTrans(ct); |
439 |
System.err.println("coordTrans = " + |
440 |
proj.getAbrev() + " " +
|
441 |
mapCtrl.getProjection().getAbrev()); |
442 |
} |
443 |
} |
444 |
|
445 |
if (drivers[iFile] instanceof WithDefaultLegend) { |
446 |
WithDefaultLegend aux = (WithDefaultLegend) drivers[iFile]; |
447 |
lyrVect.setLegend((VectorialLegend) aux.getDefaultLegend()); |
448 |
} else {
|
449 |
lyrVect.setLegend(LegendFactory.createSingleSymbolLegend( |
450 |
lyrVect.getShapeType())); |
451 |
} |
452 |
} |
453 |
} |
454 |
catch (FieldNotFoundException fe)
|
455 |
{ |
456 |
fe.printStackTrace(); |
457 |
} |
458 |
|
459 |
} catch (CancelationException ex) {
|
460 |
// TODO Auto-generated catch block
|
461 |
ex.printStackTrace(); |
462 |
} |
463 |
|
464 |
} |
465 |
} catch (DriverException ex) {
|
466 |
NotificationManager.addError("A?adiendo capa",ex);
|
467 |
} |
468 |
} // for
|
469 |
//Esto permite que cuando se cargan varias capas de golpe y la vista est? vacia,se ponga como extent la suma de todos sus extents.
|
470 |
if (rects.length > 1) { |
471 |
Rectangle2D rect = new Rectangle2D.Double(); |
472 |
rect.setRect(rects[0]);
|
473 |
|
474 |
if (first) {
|
475 |
for (int i = 0; i < rects.length; i++) { |
476 |
rect.add(rects[i]); |
477 |
} |
478 |
|
479 |
mapCtrl.getMapContext().getViewPort() |
480 |
.setExtent(rect); |
481 |
} |
482 |
} |
483 |
mapCtrl.getMapContext().endAtomicEvent(); |
484 |
if (mapCtrl instanceof MapOverview){ |
485 |
((MapOverview)mapCtrl).refreshExtent(); |
486 |
} |
487 |
|
488 |
} |
489 |
|
490 |
} |
491 |
else
|
492 |
{ |
493 |
JDialog dlg = new JDialog(); |
494 |
dlg.setModal(true);
|
495 |
FileOpenDialog fileDlg = new FileOpenDialog(new Class[]{VectorialFileDriver.class}); |
496 |
DataBaseOpenDialog dbop = new DataBaseOpenDialog();
|
497 |
dbop.setClasses(new Class[]{DBDriver.class}); |
498 |
|
499 |
fopen = new FOpenDialog();
|
500 |
fopen.addTab("Fichero", fileDlg);
|
501 |
fopen.addTab("Base de datos", dbop);
|
502 |
// fileDlg.setPreferredSize(fopen.getSize());
|
503 |
dlg.setSize(fopen.getSize()); |
504 |
dlg.getContentPane().add(fopen); |
505 |
dlg.pack(); |
506 |
dlg.show(); |
507 |
|
508 |
|
509 |
// TODO: Hacer lo de la capa WMS tambi?n.
|
510 |
if (fileDlg.getFiles() == null) return; |
511 |
FLayer lyr = null;
|
512 |
File[] files = fileDlg.getFiles(); |
513 |
String[] driverNames = fileDlg.getDriverNames(); |
514 |
Driver[] drivers = new Driver[driverNames.length]; |
515 |
for (int i = 0; i < drivers.length; i++) { |
516 |
try {
|
517 |
drivers[i] = LayerFactory.getDM().getDriver(driverNames[i]); |
518 |
} catch (DriverLoadException e1) {
|
519 |
e1.printStackTrace(); |
520 |
} |
521 |
} |
522 |
for (int iFile=0; iFile < files.length; iFile++) |
523 |
{ |
524 |
File fich = files[iFile];
|
525 |
String layerName = fich.getName();
|
526 |
String layerPath = fich.getAbsolutePath();
|
527 |
|
528 |
try {
|
529 |
if (drivers[iFile] instanceof VectorialFileDriver) { |
530 |
lyr = LayerFactory.createLayer(layerName, (VectorialFileDriver) drivers[iFile], fich, proj); |
531 |
}else if (drivers[iFile] instanceof RasterDriver) { |
532 |
lyr = LayerFactory.createLayer(layerName, driverNames[iFile], fich, proj); |
533 |
} |
534 |
|
535 |
lyr.setVisible(true);
|
536 |
lyr.setName(layerName); |
537 |
if (lyr != null ) |
538 |
{ |
539 |
try {
|
540 |
mapCtrl.getMapContext().getLayers().addLayer(lyr); |
541 |
} catch (CancelationException ex) {
|
542 |
// TODO Auto-generated catch block
|
543 |
ex.printStackTrace(); |
544 |
} |
545 |
} |
546 |
|
547 |
} catch (DriverException ex) {
|
548 |
NotificationManager.addError("A?adiendo capa",ex);
|
549 |
} |
550 |
} // for
|
551 |
// lstModel.addElement(lyr.getName());
|
552 |
} |
553 |
refreshList(); |
554 |
updateControls(null);
|
555 |
|
556 |
} |
557 |
if (e.getActionCommand() == "REMOVE_LAYER") |
558 |
{ |
559 |
if (jList.getSelectedIndex() != -1) |
560 |
{ |
561 |
theLayers.removeLayer((String) lstModel.get(jList.getSelectedIndex()));
|
562 |
lstModel.remove(jList.getSelectedIndex()); |
563 |
///mapCtrl.drawMap();
|
564 |
updateControls(null);
|
565 |
if (mapCtrl instanceof MapOverview){ |
566 |
((MapOverview)mapCtrl).refreshExtent(); |
567 |
} |
568 |
} |
569 |
} |
570 |
if (e.getActionCommand() == "EDIT_LEGEND") |
571 |
{ |
572 |
int idSelec = jList.getSelectedIndex();
|
573 |
if (idSelec != -1) |
574 |
{ |
575 |
FLayer lyr = theLayers.getLayer((String) lstModel.get(idSelec));
|
576 |
if (lyr instanceof Classifiable) |
577 |
{ |
578 |
FThemeManagerWindow m_LegendEditor = new FThemeManagerWindow();
|
579 |
try {
|
580 |
theLayers.setActive(false);
|
581 |
lyr.setActive(true);
|
582 |
m_LegendEditor.setMapContext(mapCtrl.getMapContext()); |
583 |
} catch (DriverException e1) {
|
584 |
// TODO Auto-generated catch block
|
585 |
e1.printStackTrace(); |
586 |
} |
587 |
if (PluginServices.getMainFrame() == null) { |
588 |
JDialog dlg = new JDialog(); |
589 |
|
590 |
m_LegendEditor.setPreferredSize(m_LegendEditor.getSize()); |
591 |
dlg.getContentPane().add(m_LegendEditor); |
592 |
dlg.setModal(true);
|
593 |
dlg.pack(); |
594 |
dlg.show(); |
595 |
|
596 |
} else {
|
597 |
PluginServices.getMDIManager().addView(m_LegendEditor); |
598 |
} |
599 |
} |
600 |
else
|
601 |
{ |
602 |
JOptionPane.showMessageDialog(null, PluginServices.getText(this,"Solo_para_capas_vectoriales")+"."); |
603 |
} |
604 |
|
605 |
} |
606 |
|
607 |
} |
608 |
if (e.getActionCommand() == "UP") |
609 |
{ |
610 |
int idSelec = jList.getSelectedIndex();
|
611 |
int fromIndex = idSelec;
|
612 |
int toIndex = idSelec-1; |
613 |
FLayer aux = theLayers.getLayer((String) lstModel.get(fromIndex));
|
614 |
try {
|
615 |
theLayers.moveTo(numLayers-fromIndex, numLayers-toIndex); |
616 |
} catch (CancelationException e1) {
|
617 |
e1.printStackTrace(); |
618 |
} |
619 |
|
620 |
lstModel.remove(fromIndex); |
621 |
lstModel.add(toIndex,aux.getName()); |
622 |
|
623 |
jList.setSelectedIndex(toIndex); |
624 |
|
625 |
///mapCtrl.drawMap();
|
626 |
} |
627 |
if (e.getActionCommand() == "DOWN") |
628 |
{ |
629 |
int idSelec = jList.getSelectedIndex();
|
630 |
int fromIndex = idSelec;
|
631 |
int toIndex = idSelec+1; |
632 |
FLayer aux = theLayers.getLayer((String) lstModel.get(fromIndex));
|
633 |
try {
|
634 |
theLayers.moveTo(numLayers-fromIndex, numLayers-toIndex); |
635 |
} catch (CancelationException e1) {
|
636 |
e1.printStackTrace(); |
637 |
} |
638 |
|
639 |
lstModel.remove(fromIndex); |
640 |
lstModel.add(toIndex,aux.getName()); |
641 |
|
642 |
jList.setSelectedIndex(toIndex); |
643 |
|
644 |
///mapCtrl.drawMap();
|
645 |
} |
646 |
|
647 |
|
648 |
} |
649 |
/* (non-Javadoc)
|
650 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
651 |
*/
|
652 |
public ViewInfo getViewInfo() {
|
653 |
if (m_viewinfo==null){ |
654 |
m_viewinfo=new ViewInfo(ViewInfo.PALETTE);
|
655 |
m_viewinfo.setTitle(PluginServices.getText(this,"Configurar_localizador")); |
656 |
} |
657 |
return m_viewinfo;
|
658 |
} |
659 |
/**
|
660 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
661 |
*/
|
662 |
public void viewActivated() { |
663 |
} |
664 |
|
665 |
} // @jve:visual-info decl-index=0 visual-constraint="10,10"
|