Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / toc / actions / FirstLayerTocMenuEntry.java @ 29598

History | View | Annotate | Download (3.89 KB)

1
package org.gvsig.app.project.documents.view.toc.actions;
2

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

    
12

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

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

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

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

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

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

    
103
        }
104

    
105

    
106
        public void execute(ITocItem item, FLayer[] selectedItems) {
107
              if (isTocItemBranch(item)){
108
            if (getMapContext().getLayers().getActives().length == 1) {
109
                FLayer layer=((TocItemBranch)item).getLayer();
110
                FLayers layers=layer.getParentLayer();
111
                for (int i=0;i<layers.getLayersCount();i++){
112
                    if(layers.getLayer(i).equals(layer)){
113
                            layers.moveTo(layers.getLayersCount()-1-i, 0);
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.moveTo(layers.getLayersCount()-1-j, 0);
123
                        }
124
                    }
125
                }
126
            }
127
                }
128
                // TRUCO PARA REFRESCAR.
129
        getMapContext().invalidate();
130
        Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
131
                project.setModified(true);
132
                PluginServices.getMainFrame().enableControls();
133
        }
134
}