root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / toc / actions / LayersUngroupTocMenuEntry.java @ 34895
History | View | Annotate | Download (4.13 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 org.gvsig.app.project.documents.view.toc.actions; |
42 |
|
43 |
import org.gvsig.andami.PluginServices; |
44 |
import org.gvsig.andami.messages.NotificationManager; |
45 |
import org.gvsig.app.extension.ProjectExtension; |
46 |
import org.gvsig.app.project.Project; |
47 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
48 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
49 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
50 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
51 |
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection; |
52 |
import org.gvsig.fmap.mapcontext.layers.operations.LayerNotFoundInCollectionException; |
53 |
import org.slf4j.Logger; |
54 |
import org.slf4j.LoggerFactory; |
55 |
|
56 |
|
57 |
|
58 |
/* CVS MESSAGES:
|
59 |
*
|
60 |
* $Id: LayersUngroupTocMenuEntry.java 34895 2011-04-06 07:58:58Z fdiaz $
|
61 |
* $Log$
|
62 |
* Revision 1.6 2007-01-04 07:24:31 caballero
|
63 |
* isModified
|
64 |
*
|
65 |
* Revision 1.5 2006/10/02 13:52:34 jaume
|
66 |
* organize impots
|
67 |
*
|
68 |
* Revision 1.4 2006/09/25 15:24:26 jmvivo
|
69 |
* * Modificada la implementacion.
|
70 |
*
|
71 |
* Revision 1.3 2006/09/20 12:01:24 jaume
|
72 |
* *** empty log message ***
|
73 |
*
|
74 |
* Revision 1.2 2006/09/20 11:41:20 jaume
|
75 |
* *** empty log message ***
|
76 |
*
|
77 |
* Revision 1.1 2006/09/15 10:41:30 caballero
|
78 |
* extensibilidad de documentos
|
79 |
*
|
80 |
* Revision 1.1 2006/09/12 15:58:14 jorpiell
|
81 |
* "Sacadas" las opcines del men? de FPopupMenu
|
82 |
*
|
83 |
*
|
84 |
*/
|
85 |
/**
|
86 |
* Realiza una desagrupaci?n de capas, a partir de las capas que se encuentren activas.
|
87 |
*
|
88 |
* @author Vicente Caballero Navarro
|
89 |
*/
|
90 |
public class LayersUngroupTocMenuEntry extends AbstractTocContextMenuAction { |
91 |
/**
|
92 |
* Useful for debug the problems during the implementation.
|
93 |
*/
|
94 |
private static Logger logger = LoggerFactory.getLogger(LayersUngroupTocMenuEntry.class); |
95 |
|
96 |
public String getGroup() { |
97 |
return "group4"; //FIXME |
98 |
} |
99 |
|
100 |
public int getGroupOrder() { |
101 |
return 40; |
102 |
} |
103 |
|
104 |
public int getOrder() { |
105 |
return 1; |
106 |
} |
107 |
|
108 |
public String getText() { |
109 |
return PluginServices.getText(this, "desagrupar_capas"); |
110 |
} |
111 |
|
112 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
113 |
return true; |
114 |
} |
115 |
|
116 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
117 |
FLayer lyr = getNodeLayer(item); |
118 |
if (!(lyr instanceof FLayers) || (lyr instanceof FLayers && lyr.getParentLayer() == null)){ |
119 |
return false; |
120 |
} |
121 |
return true; |
122 |
|
123 |
} |
124 |
|
125 |
|
126 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
127 |
if (isTocItemBranch(item)){
|
128 |
FLayers agrupa = (FLayers)getNodeLayer(item); |
129 |
FLayers parent=agrupa.getParentLayer(); |
130 |
|
131 |
if (parent!=null){ |
132 |
getMapContext().beginAtomicEvent(); |
133 |
try{
|
134 |
while (agrupa.getLayersCount() > 0){ |
135 |
FLayer layer = agrupa.getLayer(0);
|
136 |
agrupa.move(layer, parent, LayerCollection.BEFORE, agrupa); |
137 |
} |
138 |
parent.removeLayer(agrupa); |
139 |
} catch (LayerNotFoundInCollectionException e) {
|
140 |
NotificationManager.addError(e); |
141 |
} |
142 |
getMapContext().endAtomicEvent(); |
143 |
|
144 |
// TRUCO PARA REFRESCAR.
|
145 |
getMapContext().invalidate(); |
146 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
147 |
project.setModified(true);
|
148 |
|
149 |
} |
150 |
} |
151 |
} |
152 |
} |