svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FPanelLocConfig.java @ 4281
History | View | Annotate | Download (21.9 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
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 | 1103 | fjp | /* 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 | 312 | fernando | 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 | 2659 | fjp | import java.awt.geom.Rectangle2D; |
53 | 572 | fjp | import java.io.File; |
54 | 312 | fernando | |
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 | 2659 | fjp | import org.cresques.cts.ICoordTrans; |
62 | 312 | fernando | import org.cresques.cts.IProjection; |
63 | import org.cresques.cts.ProjectionPool; |
||
64 | 2659 | fjp | import org.cresques.cts.gt2.CoordSys; |
65 | import org.cresques.cts.gt2.CoordTrans; |
||
66 | 312 | fernando | |
67 | 1830 | fernando | import com.hardcode.driverManager.Driver; |
68 | import com.hardcode.driverManager.DriverLoadException; |
||
69 | import com.hardcode.gdbms.engine.data.driver.DBDriver; |
||
70 | 2659 | fjp | import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
71 | 620 | fjp | import com.iver.andami.PluginServices; |
72 | 1038 | vcaballero | import com.iver.andami.messages.NotificationManager; |
73 | 620 | fjp | import com.iver.andami.ui.mdiManager.View; |
74 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
75 | 654 | fernando | import com.iver.cit.gvsig.fmap.DriverException; |
76 | 1223 | fernando | import com.iver.cit.gvsig.fmap.MapControl; |
77 | 643 | fjp | import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver; |
78 | 1830 | fernando | import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
79 | 572 | fjp | import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver; |
80 | 2659 | fjp | import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend; |
81 | 572 | fjp | import com.iver.cit.gvsig.fmap.layers.CancelationException; |
82 | 377 | fjp | import com.iver.cit.gvsig.fmap.layers.FLayer; |
83 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
84 | 2659 | fjp | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
85 | 572 | fjp | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
86 | import com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable; |
||
87 | 2659 | fjp | import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
88 | import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
||
89 | 2209 | vcaballero | import com.iver.cit.gvsig.gui.thememanager.FThemeManagerWindow; |
90 | 312 | fernando | |
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 | 1223 | fernando | private MapControl mapCtrl;
|
109 | 312 | fernando | private ViewInfo m_viewinfo = null; |
110 | /**
|
||
111 | * This is the default constructor
|
||
112 | */
|
||
113 | 1223 | fernando | public FPanelLocConfig( MapControl mc) {
|
114 | 312 | fernando | super();
|
115 | 377 | fjp | mapCtrl = mc; |
116 | 312 | fernando | initialize(); |
117 | refreshList(); |
||
118 | updateControls(null);
|
||
119 | } |
||
120 | |||
121 | private void refreshList() |
||
122 | { |
||
123 | DefaultListModel lstModel = (DefaultListModel) getJList().getModel(); |
||
124 | lstModel.clear(); |
||
125 | 655 | fjp | for (int i=mapCtrl.getMapContext().getLayers().getLayersCount()-1; i >=0; i--) |
126 | 312 | fernando | { |
127 | 403 | fjp | FLayer lyr = mapCtrl.getMapContext().getLayers().getLayer(i); |
128 | 312 | fernando | 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(370, 200); |
||
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 | 620 | fjp | jLabel.setText(PluginServices.getText(this,"Capas_del_localizador")+":"); |
163 | 312 | fernando | 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 | 620 | fjp | jBtnUp.setToolTipText(PluginServices.getText(this,"Subir_capa")); |
233 | 312 | fernando | 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 | 620 | fjp | jBtnDown.setToolTipText(PluginServices.getText(this,"Bajar_capa")); |
255 | 312 | fernando | 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 | 620 | fjp | jBtnAddLayer.setText(PluginServices.getText(this,"Anadir_capa")+"..."); |
275 | 312 | fernando | 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 | 620 | fjp | jBtnRemoveLayer.setText(PluginServices.getText(this,"Quitar_capa")+"..."); |
295 | 312 | fernando | 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 | 620 | fjp | jBtnEditLegend.setText(PluginServices.getText(this,"Editar_leyenda")+"..."); |
316 | 312 | fernando | 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 | 620 | fjp | jBtnCancel.setText(PluginServices.getText(this,"Cerrar")); |
336 | 312 | fernando | 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 | 404 | fjp | FLayers theLayers = mapCtrl.getMapContext().getLayers(); |
349 | 2659 | fjp | IProjection proj = null;
|
350 | 655 | fjp | |
351 | int numLayers = theLayers.getLayersCount()-1; |
||
352 | 312 | fernando | |
353 | if (e.getActionCommand() == "CANCEL") |
||
354 | { |
||
355 | 620 | fjp | if (PluginServices.getMainFrame() != null) |
356 | 312 | fernando | { |
357 | 620 | fjp | PluginServices.getMDIManager().closeView(FPanelLocConfig.this); |
358 | 312 | fernando | } |
359 | else
|
||
360 | { |
||
361 | ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
||
362 | } |
||
363 | } |
||
364 | if (e.getActionCommand() == "ADD_LAYER") |
||
365 | { |
||
366 | 643 | fjp | FOpenDialog fopen = new FOpenDialog();
|
367 | 620 | fjp | if (PluginServices.getMainFrame() != null) |
368 | 572 | fjp | { |
369 | 643 | fjp | FileOpenDialog fileDlg = new FileOpenDialog(new Class[]{VectorialFileDriver.class, GeorreferencedRasterDriver.class}); |
370 | DataBaseOpenDialog dbop = new DataBaseOpenDialog();
|
||
371 | 646 | fjp | dbop.setClasses(new Class[] { DBDriver.class }); |
372 | 643 | fjp | 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 | 2659 | fjp | proj =FOpenDialog.getLastProjection(); |
382 | 643 | fjp | FLayer lyr = null;
|
383 | File[] files = fileDlg.getFiles(); |
||
384 | 1171 | fjp | String[] driverNames = fileDlg.getDriverNames(); |
385 | 1830 | fernando | 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 | 2659 | fjp | Rectangle2D[] rects=new Rectangle2D[files.length]; |
394 | boolean first=false; |
||
395 | mapCtrl.getMapContext() |
||
396 | .beginAtomicEvent(); |
||
397 | |||
398 | 643 | fjp | 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 | 1830 | fernando | if (drivers[iFile] instanceof VectorialFileDriver){ |
405 | lyr = LayerFactory.createLayer(layerName, (VectorialFileDriver) drivers[iFile], |
||
406 | fich, proj); |
||
407 | }else if (drivers[iFile] instanceof RasterDriver){ |
||
408 | 2659 | fjp | lyr = LayerFactory.createLayer(layerName, |
409 | (RasterDriver) drivers[iFile], fich, proj); |
||
410 | } |
||
411 | 643 | fjp | |
412 | if (lyr != null) { |
||
413 | try {
|
||
414 | |||
415 | lyr.setVisible(true);
|
||
416 | mapCtrl.getMapContext().getLayers() |
||
417 | .addLayer(lyr); |
||
418 | 2659 | fjp | 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 | 1307 | vcaballero | } |
454 | 2659 | fjp | catch (FieldNotFoundException fe)
|
455 | { |
||
456 | fe.printStackTrace(); |
||
457 | } |
||
458 | |||
459 | 643 | fjp | } catch (CancelationException ex) {
|
460 | // TODO Auto-generated catch block
|
||
461 | ex.printStackTrace(); |
||
462 | } |
||
463 | |||
464 | } |
||
465 | 1060 | fjp | } catch (DriverException ex) {
|
466 | 1038 | vcaballero | NotificationManager.addError("A?adiendo capa",ex);
|
467 | 1049 | fjp | } |
468 | 643 | fjp | } // for
|
469 | 2659 | fjp | //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 | 643 | fjp | } |
489 | |||
490 | 572 | fjp | } |
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 | 646 | fjp | dbop.setClasses(new Class[]{DBDriver.class}); |
498 | 572 | fjp | |
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 | 1171 | fjp | String[] driverNames = fileDlg.getDriverNames(); |
514 | 1830 | fernando | 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 | 572 | fjp | 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 | 1830 | fernando | if (drivers[iFile] instanceof VectorialFileDriver) { |
530 | lyr = LayerFactory.createLayer(layerName, (VectorialFileDriver) drivers[iFile], fich, proj); |
||
531 | }else if (drivers[iFile] instanceof RasterDriver) { |
||
532 | 2659 | fjp | lyr = LayerFactory.createLayer(layerName, driverNames[iFile], fich, proj); |
533 | 1830 | fernando | } |
534 | 572 | fjp | |
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 | 1060 | fjp | } catch (DriverException ex) {
|
548 | 1038 | vcaballero | NotificationManager.addError("A?adiendo capa",ex);
|
549 | 572 | fjp | } |
550 | } // for
|
||
551 | // lstModel.addElement(lyr.getName());
|
||
552 | 655 | fjp | } |
553 | 572 | fjp | refreshList(); |
554 | updateControls(null);
|
||
555 | 312 | fernando | |
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 | 842 | vcaballero | ///mapCtrl.drawMap();
|
564 | 312 | fernando | updateControls(null);
|
565 | 1307 | vcaballero | if (mapCtrl instanceof MapOverview){ |
566 | ((MapOverview)mapCtrl).refreshExtent(); |
||
567 | } |
||
568 | 312 | fernando | } |
569 | } |
||
570 | if (e.getActionCommand() == "EDIT_LEGEND") |
||
571 | { |
||
572 | int idSelec = jList.getSelectedIndex();
|
||
573 | if (idSelec != -1) |
||
574 | { |
||
575 | 377 | fjp | FLayer lyr = theLayers.getLayer((String) lstModel.get(idSelec));
|
576 | 572 | fjp | if (lyr instanceof Classifiable) |
577 | 312 | fernando | { |
578 | 2209 | vcaballero | FThemeManagerWindow m_LegendEditor = new FThemeManagerWindow();
|
579 | 572 | fjp | try {
|
580 | 655 | fjp | theLayers.setActive(false);
|
581 | lyr.setActive(true);
|
||
582 | 572 | fjp | m_LegendEditor.setMapContext(mapCtrl.getMapContext()); |
583 | } catch (DriverException e1) {
|
||
584 | // TODO Auto-generated catch block
|
||
585 | e1.printStackTrace(); |
||
586 | } |
||
587 | 655 | fjp | 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 | 1469 | fernando | } else {
|
597 | PluginServices.getMDIManager().addView(m_LegendEditor); |
||
598 | } |
||
599 | 312 | fernando | } |
600 | else
|
||
601 | { |
||
602 | 1500 | fjp | JOptionPane.showMessageDialog(null, PluginServices.getText(this,"Solo_para_capas_vectoriales")+"."); |
603 | 312 | fernando | } |
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 | 655 | fjp | FLayer aux = theLayers.getLayer((String) lstModel.get(fromIndex));
|
614 | 572 | fjp | try {
|
615 | 655 | fjp | theLayers.moveTo(numLayers-fromIndex, numLayers-toIndex); |
616 | 572 | fjp | } catch (CancelationException e1) {
|
617 | e1.printStackTrace(); |
||
618 | } |
||
619 | 312 | fernando | |
620 | lstModel.remove(fromIndex); |
||
621 | lstModel.add(toIndex,aux.getName()); |
||
622 | |||
623 | jList.setSelectedIndex(toIndex); |
||
624 | |||
625 | 842 | vcaballero | ///mapCtrl.drawMap();
|
626 | 312 | fernando | } |
627 | if (e.getActionCommand() == "DOWN") |
||
628 | { |
||
629 | int idSelec = jList.getSelectedIndex();
|
||
630 | int fromIndex = idSelec;
|
||
631 | int toIndex = idSelec+1; |
||
632 | 655 | fjp | FLayer aux = theLayers.getLayer((String) lstModel.get(fromIndex));
|
633 | 572 | fjp | try {
|
634 | 655 | fjp | theLayers.moveTo(numLayers-fromIndex, numLayers-toIndex); |
635 | 572 | fjp | } catch (CancelationException e1) {
|
636 | e1.printStackTrace(); |
||
637 | } |
||
638 | 312 | fernando | |
639 | lstModel.remove(fromIndex); |
||
640 | lstModel.add(toIndex,aux.getName()); |
||
641 | |||
642 | jList.setSelectedIndex(toIndex); |
||
643 | |||
644 | 842 | vcaballero | ///mapCtrl.drawMap();
|
645 | 312 | fernando | } |
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 | 655 | fjp | m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
655 | 620 | fjp | m_viewinfo.setTitle(PluginServices.getText(this,"Configurar_localizador")); |
656 | 312 | fernando | } |
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" |