root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / toc / actions / LayersGroupTocMenuEntry.java @ 12213
History | View | Annotate | Download (4.4 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.ProjectExtension; |
5 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
6 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
7 |
import com.iver.cit.gvsig.project.Project; |
8 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
9 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
10 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.ChangeName; |
11 |
|
12 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
13 |
*
|
14 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
15 |
*
|
16 |
* This program is free software; you can redistribute it and/or
|
17 |
* modify it under the terms of the GNU General Public License
|
18 |
* as published by the Free Software Foundation; either version 2
|
19 |
* of the License, or (at your option) any later version.
|
20 |
*
|
21 |
* This program is distributed in the hope that it will be useful,
|
22 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
26 |
* You should have received a copy of the GNU General Public License
|
27 |
* along with this program; if not, write to the Free Software
|
28 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
29 |
*
|
30 |
* For more information, contact:
|
31 |
*
|
32 |
* Generalitat Valenciana
|
33 |
* Conselleria d'Infraestructures i Transport
|
34 |
* Av. Blasco Ib??ez, 50
|
35 |
* 46010 VALENCIA
|
36 |
* SPAIN
|
37 |
*
|
38 |
* +34 963862235
|
39 |
* gvsig@gva.es
|
40 |
* www.gvsig.gva.es
|
41 |
*
|
42 |
* or
|
43 |
*
|
44 |
* IVER T.I. S.A
|
45 |
* Salamanca 50
|
46 |
* 46005 Valencia
|
47 |
* Spain
|
48 |
*
|
49 |
* +34 963163400
|
50 |
* dac@iver.es
|
51 |
*/
|
52 |
/* CVS MESSAGES:
|
53 |
*
|
54 |
* $Id: LayersGroupTocMenuEntry.java 12213 2007-06-19 08:42:17Z jcampos $
|
55 |
* $Log$
|
56 |
* Revision 1.7 2007-06-19 08:42:17 jcampos
|
57 |
* New method to get new group layers
|
58 |
*
|
59 |
* Revision 1.6 2007/02/15 11:04:54 caballero
|
60 |
* cancelar agrupaci?n
|
61 |
*
|
62 |
* Revision 1.5 2007/02/14 17:09:43 caballero
|
63 |
* posici?n layerGroup
|
64 |
*
|
65 |
* Revision 1.4 2007/01/04 07:24:31 caballero
|
66 |
* isModified
|
67 |
*
|
68 |
* Revision 1.3 2006/10/02 13:52:34 jaume
|
69 |
* organize impots
|
70 |
*
|
71 |
* Revision 1.2 2006/09/25 15:21:47 jmvivo
|
72 |
* * Modificada la condicion de visibilidad, no permitir si no tienen el mismo padre.
|
73 |
* * Modificada la implementacion.
|
74 |
*
|
75 |
* Revision 1.1 2006/09/15 10:41:30 caballero
|
76 |
* extensibilidad de documentos
|
77 |
*
|
78 |
* Revision 1.1 2006/09/12 15:58:14 jorpiell
|
79 |
* "Sacadas" las opcines del men? de FPopupMenu
|
80 |
*
|
81 |
*
|
82 |
*/
|
83 |
/**
|
84 |
* Realiza una agrupaci?n de capas, a partir de las capas que se encuentren activas.
|
85 |
*
|
86 |
* @author Vicente Caballero Navarro
|
87 |
*/
|
88 |
public class LayersGroupTocMenuEntry extends AbstractTocContextMenuAction { |
89 |
public String getGroup() { |
90 |
return "group4"; //FIXME |
91 |
} |
92 |
|
93 |
public int getGroupOrder() { |
94 |
return 40; |
95 |
} |
96 |
|
97 |
public int getOrder() { |
98 |
return 0; |
99 |
} |
100 |
|
101 |
public String getText() { |
102 |
return PluginServices.getText(this, "agrupar_capas"); |
103 |
} |
104 |
|
105 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
106 |
return selectedItems.length > 1; |
107 |
} |
108 |
|
109 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
110 |
if (selectedItems.length < 2) { |
111 |
return false; |
112 |
} |
113 |
FLayers parent = selectedItems[0].getParentLayer();
|
114 |
for (int i = 1; i < selectedItems.length;i++){ |
115 |
if (parent != selectedItems[i].getParentLayer()){
|
116 |
return false; |
117 |
} |
118 |
} |
119 |
return true; |
120 |
|
121 |
} |
122 |
|
123 |
|
124 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
125 |
//ITocItem tocItem = (ITocItem) getNodeUserObject();
|
126 |
ChangeName changename=new ChangeName(null); |
127 |
PluginServices.getMDIManager().addWindow(changename); |
128 |
if (!changename.isAccepted())
|
129 |
return;
|
130 |
String nombre=changename.getName();
|
131 |
|
132 |
if (nombre != null){ |
133 |
|
134 |
getMapContext().beginAtomicEvent(); |
135 |
FLayers parent = selectedItems[0].getParentLayer();
|
136 |
// FLayers newGroup = new FLayers(getMapContext(),parent);
|
137 |
FLayers newGroup = getMapContext().getNewGroupLayer(parent); |
138 |
newGroup.setName(nombre); |
139 |
int pos=0; |
140 |
for (int i=0;i<parent.getLayersCount();i++){ |
141 |
if (parent.getLayer(i).equals(selectedItems[0])){ |
142 |
pos=i; |
143 |
continue;
|
144 |
} |
145 |
} |
146 |
for (int j=0;j < selectedItems.length;j++){ |
147 |
FLayer layer = selectedItems[j]; |
148 |
parent.removeLayer(layer); |
149 |
newGroup.addLayer(layer); |
150 |
} |
151 |
parent.addLayer(pos,newGroup); |
152 |
|
153 |
getMapContext().endAtomicEvent(); |
154 |
// TRUCO PARA REFRESCAR.
|
155 |
getMapContext().invalidate(); |
156 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
157 |
project.setModified(true);
|
158 |
} |
159 |
} |
160 |
} |