Statistics
| Revision:

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

History | View | Annotate | Download (3.63 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.fmap.layers.FLayer;
5
import com.iver.cit.gvsig.fmap.layers.FLayers;
6
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
7
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
8
import com.iver.cit.gvsig.project.documents.view.toc.TocItemBranch;
9

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

    
75
        public int getGroupOrder() {
76
                return 40;
77
        }
78

    
79
        public int getOrder() {
80
                return 2;
81
        }
82

    
83
        public String getText() {
84
                return PluginServices.getText(this, "colocar_delante");
85
        }
86

    
87
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
88
                return true;
89
        }
90

    
91
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
92
                if (isTocItemBranch(item)){
93
                        return true;
94
                }
95
                return false;
96

    
97
        }
98

    
99

    
100
        public void execute(ITocItem item, FLayer[] selectedItems) {
101
              if (isTocItemBranch(item)){
102
            if (getMapContext().getLayers().getActives().length == 1) {
103
                FLayer layer=((TocItemBranch)item).getLayer();
104
                FLayers layers=layer.getParentLayer();
105
                for (int i=0;i<layers.getLayersCount();i++){
106
                    if(layers.getLayer(i).equals(layer)){
107
                        layers.removeLayer(i);
108
                        layers.addLayer(layer);
109
                    }
110
                }
111
            } else if (selectedItems.length > 1) {
112
                FLayer[] actives =selectedItems;
113
                FLayers layers=actives[0].getParentLayer();
114
                for (int i=0;i<actives.length;i++){
115
                    for (int j=0;j<layers.getLayersCount();j++){
116
                        if(layers.getLayer(j).equals(actives[i])){
117
                            layers.removeLayer(j);
118
                            layers.addLayer(actives[i]);
119
                        }
120
                    }
121
                }
122
            }
123
                }
124
                // TRUCO PARA REFRESCAR.
125
        getMapContext().invalidate();
126
        }
127
}