Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / toc / actions / FirstLayerTocMenuEntry.java @ 40558

History | View | Annotate | Download (4.89 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.app.project.documents.view.toc.actions;
25

    
26
import org.gvsig.andami.PluginServices;
27
import org.gvsig.app.extension.ProjectExtension;
28
import org.gvsig.app.project.Project;
29
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
30
import org.gvsig.app.project.documents.view.toc.ITocItem;
31
import org.gvsig.app.project.documents.view.toc.TocItemBranch;
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.fmap.mapcontext.layers.FLayers;
34

    
35

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

    
104
        public int getGroupOrder() {
105
                return 40;
106
        }
107

    
108
        public int getOrder() {
109
                return 2;
110
        }
111

    
112
        public String getText() {
113
                return PluginServices.getText(this, "colocar_delante");
114
        }
115

    
116
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
117
                return true;
118
        }
119

    
120
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
121
                if (isTocItemBranch(item)){
122
                        return true;
123
                }
124
                return false;
125

    
126
        }
127

    
128

    
129
        public void execute(ITocItem item, FLayer[] selectedItems) {
130
              if (isTocItemBranch(item)){
131
            if (getMapContext().getLayers().getActives().length == 1) {
132
                FLayer layer=((TocItemBranch)item).getLayer();
133
                FLayers layers=layer.getParentLayer();
134
                for (int i=0;i<layers.getLayersCount();i++){
135
                    if(layers.getLayer(i).equals(layer)){
136
                            layers.moveTo(layers.getLayersCount()-1-i, 0);
137
                    }
138
                }
139
            } else if (selectedItems.length > 1) {
140
                FLayer[] actives =selectedItems;
141
                FLayers layers=actives[0].getParentLayer();
142
                for (int i=0;i<actives.length;i++){
143
                    for (int j=0;j<layers.getLayersCount();j++){
144
                        if(layers.getLayer(j).equals(actives[i])){
145
                                layers.moveTo(layers.getLayersCount()-1-j, 0);
146
                        }
147
                    }
148
                }
149
            }
150
                }
151
                // TRUCO PARA REFRESCAR.
152
        getMapContext().invalidate();
153
        Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
154
                project.setModified(true);
155
                PluginServices.getMainFrame().enableControls();
156
        }
157
}