Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / LayersUngroupTocMenuEntry.java @ 7738

History | View | Annotate | Download (3.34 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.fmap.layers.FLayer;
45
import com.iver.cit.gvsig.fmap.layers.FLayers;
46
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
47
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
48

    
49

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

    
84
        public int getGroupOrder() {
85
                return 40;
86
        }
87

    
88
        public int getOrder() {
89
                return 1;
90
        }
91

    
92
        public String getText() {
93
                return PluginServices.getText(this, "desagrupar_capas");
94
        }
95

    
96
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
97
                return true;
98
        }
99

    
100
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
101
                FLayer lyr = getNodeLayer(item);
102
                if (!(lyr instanceof FLayers) || (lyr instanceof FLayers && lyr.getParentLayer() == null)){
103
                        return false;
104
                }
105
                return true;
106

    
107
        }
108

    
109

    
110
        public void execute(ITocItem item, FLayer[] selectedItems) {
111
                if (isTocItemBranch(item)){                        
112
                        FLayers agrupa = (FLayers)getNodeLayer(item);
113
                        FLayers parent=agrupa.getParentLayer();
114
                        
115
                        if (parent!=null){
116
                                getMapContext().beginAtomicEvent();
117
                                while (agrupa.getLayersCount() > 0){
118
                                        FLayer layer = agrupa.getLayer(0);
119
                                        parent.addLayer(layer);
120
                                        agrupa.removeLayer(layer);
121
                                }
122
                                parent.removeLayer(agrupa);
123
                                getMapContext().endAtomicEvent();
124
                                
125
                                // TRUCO PARA REFRESCAR.
126
                                getMapContext().invalidate();
127

    
128
                        }                
129
                }
130
        }
131
}