Statistics
| Revision:

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

History | View | Annotate | Download (3.91 KB)

1
package com.iver.cit.gvsig.project.documents.view.toc.actions;
2

    
3
import com.iver.andami.PluginServices;
4
import com.iver.cit.gvsig.ProjectExtension;
5
import com.iver.cit.gvsig.fmap.layers.FLayer;
6
import com.iver.cit.gvsig.fmap.layers.FLayers;
7
import com.iver.cit.gvsig.project.Project;
8
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
9
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
10
import com.iver.cit.gvsig.project.documents.view.toc.TocItemBranch;
11

    
12
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
13
 *
14
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
15
 *
16
 * This program is free software; you can redistribute it and/or
17
 * modify it under the terms of the GNU General Public License
18
 * as published by the Free Software Foundation; either version 2
19
 * of the License, or (at your option) any later version.
20
 *
21
 * This program is distributed in the hope that it will be useful,
22
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 * GNU General Public License for more details.
25
 *
26
 * You should have received a copy of the GNU General Public License
27
 * along with this program; if not, write to the Free Software
28
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
29
 *
30
 * For more information, contact:
31
 *
32
 *  Generalitat Valenciana
33
 *   Conselleria d'Infraestructures i Transport
34
 *   Av. Blasco Ib??ez, 50
35
 *   46010 VALENCIA
36
 *   SPAIN
37
 *
38
 *      +34 963862235
39
 *   gvsig@gva.es
40
 *      www.gvsig.gva.es
41
 *
42
 *    or
43
 *
44
 *   IVER T.I. S.A
45
 *   Salamanca 50
46
 *   46005 Valencia
47
 *   Spain
48
 *
49
 *   +34 963163400
50
 *   dac@iver.es
51
 */
52
/* CVS MESSAGES:
53
 *
54
 * $Id: FirstLayerTocMenuEntry.java 9532 2007-01-04 07:24:32Z caballero $
55
 * $Log$
56
 * Revision 1.3  2007-01-04 07:24:31  caballero
57
 * isModified
58
 *
59
 * Revision 1.2  2006/10/02 13:52:34  jaume
60
 * organize impots
61
 *
62
 * Revision 1.1  2006/09/15 10:41:30  caballero
63
 * extensibilidad de documentos
64
 *
65
 * Revision 1.1  2006/09/12 15:58:14  jorpiell
66
 * "Sacadas" las opcines del men? de FPopupMenu
67
 *
68
 *
69
 */
70
/**
71
 * Cambia la posici?n actual del layer a la primera posici?n.
72
 *
73
 * @author Vicente Caballero Navarro
74
 */
75
public class FirstLayerTocMenuEntry extends AbstractTocContextMenuAction {
76
        public String getGroup() {
77
                return "group4"; //FIXME
78
        }
79

    
80
        public int getGroupOrder() {
81
                return 40;
82
        }
83

    
84
        public int getOrder() {
85
                return 2;
86
        }
87

    
88
        public String getText() {
89
                return PluginServices.getText(this, "colocar_delante");
90
        }
91

    
92
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
93
                return true;
94
        }
95

    
96
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
97
                if (isTocItemBranch(item)){
98
                        return true;
99
                }
100
                return false;
101

    
102
        }
103

    
104

    
105
        public void execute(ITocItem item, FLayer[] selectedItems) {
106
              if (isTocItemBranch(item)){
107
            if (getMapContext().getLayers().getActives().length == 1) {
108
                FLayer layer=((TocItemBranch)item).getLayer();
109
                FLayers layers=layer.getParentLayer();
110
                for (int i=0;i<layers.getLayersCount();i++){
111
                    if(layers.getLayer(i).equals(layer)){
112
                        layers.removeLayer(i);
113
                        layers.addLayer(layer);
114
                    }
115
                }
116
            } else if (selectedItems.length > 1) {
117
                FLayer[] actives =selectedItems;
118
                FLayers layers=actives[0].getParentLayer();
119
                for (int i=0;i<actives.length;i++){
120
                    for (int j=0;j<layers.getLayersCount();j++){
121
                        if(layers.getLayer(j).equals(actives[i])){
122
                            layers.removeLayer(j);
123
                            layers.addLayer(actives[i]);
124
                        }
125
                    }
126
                }
127
            }
128
                }
129
                // TRUCO PARA REFRESCAR.
130
        getMapContext().invalidate();
131
        Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
132
                project.setModified(true);
133
        }
134
}