root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / toc / actions / FirstLayerTocMenuEntry.java @ 7504
History | View | Annotate | Download (3.44 KB)
1 |
package com.iver.cit.gvsig.gui.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.gui.toc.AbstractTocContextMenuAction; |
7 |
import com.iver.cit.gvsig.gui.toc.ITocItem; |
8 |
import com.iver.cit.gvsig.gui.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 7504 2006-09-23 16:05:48Z jorpiell $
|
53 |
* $Log$
|
54 |
* Revision 1.2.2.1 2006-09-23 16:05:48 jorpiell
|
55 |
* Se han sacado las opciones de men? del TOC de FPopupMenu a una nueva clase
|
56 |
*
|
57 |
*
|
58 |
*/
|
59 |
/**
|
60 |
* Cambia la posici?n actual del layer a la primera posici?n.
|
61 |
*
|
62 |
* @author Vicente Caballero Navarro
|
63 |
*/
|
64 |
public class FirstLayerTocMenuEntry extends AbstractTocContextMenuAction { |
65 |
public String getGroup() { |
66 |
return "group4"; //FIXME |
67 |
} |
68 |
|
69 |
public int getGroupOrder() { |
70 |
return 40; |
71 |
} |
72 |
|
73 |
public int getOrder() { |
74 |
return 2; |
75 |
} |
76 |
|
77 |
public String getText() { |
78 |
return PluginServices.getText(this, "colocar_delante"); |
79 |
} |
80 |
|
81 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
82 |
return true; |
83 |
} |
84 |
|
85 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
86 |
if (isTocItemBranch(item)){
|
87 |
return true; |
88 |
} |
89 |
return false; |
90 |
|
91 |
} |
92 |
|
93 |
|
94 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
95 |
if (isTocItemBranch(item)){
|
96 |
if (getMapContext().getLayers().getActives().length == 1) { |
97 |
FLayer layer=((TocItemBranch)item).getLayer(); |
98 |
FLayers layers=layer.getParentLayer(); |
99 |
for (int i=0;i<layers.getLayersCount();i++){ |
100 |
if(layers.getLayer(i).equals(layer)){
|
101 |
layers.removeLayer(i); |
102 |
layers.addLayer(layer); |
103 |
} |
104 |
} |
105 |
} else if (selectedItems.length > 1) { |
106 |
FLayer[] actives =selectedItems;
|
107 |
FLayers layers=actives[0].getParentLayer();
|
108 |
for (int i=0;i<actives.length;i++){ |
109 |
for (int j=0;j<layers.getLayersCount();j++){ |
110 |
if(layers.getLayer(j).equals(actives[i])){
|
111 |
layers.removeLayer(j); |
112 |
layers.addLayer(actives[i]); |
113 |
} |
114 |
} |
115 |
} |
116 |
} |
117 |
} |
118 |
// TRUCO PARA REFRESCAR.
|
119 |
getMapContext().invalidate(); |
120 |
} |
121 |
} |