root / branches / piloto3d / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / EliminarCapaTocMenuEntry.java @ 9529
History | View | Annotate | Download (4.75 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.toc.actions; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.util.ArrayList; |
5 |
|
6 |
import javax.swing.JOptionPane; |
7 |
|
8 |
import com.iver.andami.PluginServices; |
9 |
import com.iver.cit.gvsig.ProjectExtension; |
10 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
11 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
12 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
13 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
14 |
import com.iver.cit.gvsig.project.Project; |
15 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
16 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
17 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
18 |
|
19 |
|
20 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
21 |
*
|
22 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
23 |
*
|
24 |
* This program is free software; you can redistribute it and/or
|
25 |
* modify it under the terms of the GNU General Public License
|
26 |
* as published by the Free Software Foundation; either version 2
|
27 |
* of the License, or (at your option) any later version.
|
28 |
*
|
29 |
* This program is distributed in the hope that it will be useful,
|
30 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
31 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
32 |
* GNU General Public License for more details.
|
33 |
*
|
34 |
* You should have received a copy of the GNU General Public License
|
35 |
* along with this program; if not, write to the Free Software
|
36 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
37 |
*
|
38 |
* For more information, contact:
|
39 |
*
|
40 |
* Generalitat Valenciana
|
41 |
* Conselleria d'Infraestructures i Transport
|
42 |
* Av. Blasco Ib??ez, 50
|
43 |
* 46010 VALENCIA
|
44 |
* SPAIN
|
45 |
*
|
46 |
* +34 963862235
|
47 |
* gvsig@gva.es
|
48 |
* www.gvsig.gva.es
|
49 |
*
|
50 |
* or
|
51 |
*
|
52 |
* IVER T.I. S.A
|
53 |
* Salamanca 50
|
54 |
* 46005 Valencia
|
55 |
* Spain
|
56 |
*
|
57 |
* +34 963163400
|
58 |
* dac@iver.es
|
59 |
*/
|
60 |
/* CVS MESSAGES:
|
61 |
*
|
62 |
* $Id: EliminarCapaTocMenuEntry.java 9529 2007-01-03 17:07:31Z sbayarri $
|
63 |
* $Log$
|
64 |
* Revision 1.2.2.1 2007-01-03 17:07:30 sbayarri
|
65 |
* Fix wrong files
|
66 |
*
|
67 |
* Revision 1.1.2.1 2006/11/15 04:10:44 jjdelcerro
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.1 2006/09/15 10:41:30 caballero
|
71 |
* extensibilidad de documentos
|
72 |
*
|
73 |
* Revision 1.1 2006/09/12 15:58:14 jorpiell
|
74 |
* "Sacadas" las opcines del men? de FPopupMenu
|
75 |
*
|
76 |
*
|
77 |
*/
|
78 |
public class EliminarCapaTocMenuEntry extends AbstractTocContextMenuAction { |
79 |
public String getGroup() { |
80 |
return "group3"; //FIXME |
81 |
} |
82 |
|
83 |
public int getGroupOrder() { |
84 |
return 30; |
85 |
} |
86 |
|
87 |
public int getOrder() { |
88 |
return 0; |
89 |
} |
90 |
|
91 |
public String getText() { |
92 |
return PluginServices.getText(this, "eliminar_capa"); |
93 |
} |
94 |
|
95 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
96 |
return true; |
97 |
} |
98 |
|
99 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
100 |
if (isTocItemBranch(item)) {
|
101 |
return true; |
102 |
} |
103 |
return false; |
104 |
|
105 |
} |
106 |
|
107 |
|
108 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
109 |
// 050209, jmorell: Para poder borrar todas las capas seleccionadas desde el FPopUpMenu.
|
110 |
// Es necesario pulsar May?sculas a la vez que el bot?n derecho.
|
111 |
|
112 |
FLayer[] actives = selectedItems;
|
113 |
int option=-1; |
114 |
if (actives.length>0) { |
115 |
option=JOptionPane.showConfirmDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"desea_borrar_la_capa")); |
116 |
} |
117 |
if (option!=JOptionPane.OK_OPTION) |
118 |
return;
|
119 |
for (int i = actives.length-1; i>=0; i--){ |
120 |
try {
|
121 |
actives[i].getParentLayer().removeLayer(actives[i]); |
122 |
FLayers lyrs=getMapContext().getLayers(); |
123 |
lyrs.addLayer(actives[i]); |
124 |
actives[i].getParentLayer().removeLayer(actives[i]); |
125 |
|
126 |
if (actives[i] instanceof AlphanumericData){ |
127 |
Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
128 |
ProjectTable pt = project.getTable((AlphanumericData) actives[i]); |
129 |
|
130 |
ArrayList tables = project.getTables();
|
131 |
for (int j = 0; j < tables.size(); j++) { |
132 |
if (tables.get(j) == pt){
|
133 |
project.delTable(j); |
134 |
break;
|
135 |
} |
136 |
} |
137 |
|
138 |
PluginServices.getMDIManager().closeSingletonWindow(pt); |
139 |
} |
140 |
|
141 |
//if (getMapContext().getLayers().getLayersCount()==0)
|
142 |
PluginServices.getMainFrame().enableControls(); |
143 |
} catch (CancelationException e1) {
|
144 |
e1.printStackTrace(); |
145 |
} |
146 |
} |
147 |
// 050209, jmorell: As? solo borra una capa (sobre la que pulsas).
|
148 |
/*FLayer lyr = getNodeLayer();
|
149 |
try {
|
150 |
getMapContext().getLayers().removeLayer(lyr);
|
151 |
if (getMapContext().getLayers().getLayersCount()==0)PluginServices.getMainFrame().enableControls();
|
152 |
} catch (CancelationException e1) {
|
153 |
e1.printStackTrace();
|
154 |
}*/
|
155 |
} |
156 |
} |