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