Statistics
| Revision:

root / branches / piloto3d / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / FirstLayerTocMenuEntry.java @ 9529

History | View | Annotate | Download (3.78 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 9529 2007-01-03 17:07:31Z sbayarri $
53
 * $Log$
54
 * Revision 1.2.4.1  2007-01-03 17:07:30  sbayarri
55
 * Fix wrong files
56
 *
57
 * Revision 1.2.2.1  2006/11/15 04:10:44  jjdelcerro
58
 * *** empty log message ***
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.removeLayer(i);
114
                        layers.addLayer(layer);
115
                    }
116
                }
117
            } else if (selectedItems.length > 1) {
118
                FLayer[] actives =selectedItems;
119
                FLayers layers=actives[0].getParentLayer();
120
                for (int i=0;i<actives.length;i++){
121
                    for (int j=0;j<layers.getLayersCount();j++){
122
                        if(layers.getLayer(j).equals(actives[i])){
123
                            layers.removeLayer(j);
124
                            layers.addLayer(actives[i]);
125
                        }
126
                    }
127
                }
128
            }
129
                }
130
                // TRUCO PARA REFRESCAR.
131
        getMapContext().invalidate();
132
        }
133
}