Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / LayersUngroupTocMenuEntry.java @ 9532

History | View | Annotate | Download (3.61 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 com.iver.cit.gvsig.project.documents.view.toc.actions;
42

    
43
import com.iver.andami.PluginServices;
44
import com.iver.cit.gvsig.ProjectExtension;
45
import com.iver.cit.gvsig.fmap.layers.FLayer;
46
import com.iver.cit.gvsig.fmap.layers.FLayers;
47
import com.iver.cit.gvsig.project.Project;
48
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
49
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
50

    
51

    
52
/* CVS MESSAGES:
53
 *
54
 * $Id: LayersUngroupTocMenuEntry.java 9532 2007-01-04 07:24:32Z caballero $
55
 * $Log$
56
 * Revision 1.6  2007-01-04 07:24:31  caballero
57
 * isModified
58
 *
59
 * Revision 1.5  2006/10/02 13:52:34  jaume
60
 * organize impots
61
 *
62
 * Revision 1.4  2006/09/25 15:24:26  jmvivo
63
 * * Modificada la implementacion.
64
 *
65
 * Revision 1.3  2006/09/20 12:01:24  jaume
66
 * *** empty log message ***
67
 *
68
 * Revision 1.2  2006/09/20 11:41:20  jaume
69
 * *** empty log message ***
70
 *
71
 * Revision 1.1  2006/09/15 10:41:30  caballero
72
 * extensibilidad de documentos
73
 *
74
 * Revision 1.1  2006/09/12 15:58:14  jorpiell
75
 * "Sacadas" las opcines del men? de FPopupMenu
76
 *
77
 *
78
 */
79
/**
80
 * Realiza una desagrupaci?n de capas, a partir de las capas que se encuentren activas.
81
 *
82
 * @author Vicente Caballero Navarro
83
 */
84
public class LayersUngroupTocMenuEntry extends AbstractTocContextMenuAction {
85
        public String getGroup() {
86
                return "group4"; //FIXME
87
        }
88

    
89
        public int getGroupOrder() {
90
                return 40;
91
        }
92

    
93
        public int getOrder() {
94
                return 1;
95
        }
96

    
97
        public String getText() {
98
                return PluginServices.getText(this, "desagrupar_capas");
99
        }
100

    
101
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
102
                return true;
103
        }
104

    
105
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
106
                FLayer lyr = getNodeLayer(item);
107
                if (!(lyr instanceof FLayers) || (lyr instanceof FLayers && lyr.getParentLayer() == null)){
108
                        return false;
109
                }
110
                return true;
111

    
112
        }
113

    
114

    
115
        public void execute(ITocItem item, FLayer[] selectedItems) {
116
                if (isTocItemBranch(item)){
117
                        FLayers agrupa = (FLayers)getNodeLayer(item);
118
                        FLayers parent=agrupa.getParentLayer();
119

    
120
                        if (parent!=null){
121
                                getMapContext().beginAtomicEvent();
122
                                while (agrupa.getLayersCount() > 0){
123
                                        FLayer layer = agrupa.getLayer(0);
124
                                        parent.addLayer(layer);
125
                                        agrupa.removeLayer(layer);
126
                                }
127
                                parent.removeLayer(agrupa);
128
                                getMapContext().endAtomicEvent();
129

    
130
                                // TRUCO PARA REFRESCAR.
131
                                getMapContext().invalidate();
132
                                Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
133
                                project.setModified(true);
134

    
135
                        }
136
                }
137
        }
138
}