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 | 7304 | caballero | package com.iver.cit.gvsig.project.documents.view.toc.actions; |
---|---|---|---|
2 | |||
3 | import com.iver.andami.PluginServices; |
||
4 | 9532 | caballero | import com.iver.cit.gvsig.ProjectExtension; |
5 | 7304 | caballero | import com.iver.cit.gvsig.fmap.layers.FLayer; |
6 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
7 | 9532 | caballero | import com.iver.cit.gvsig.project.Project; |
8 | 7304 | caballero | 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$
|
||
55 | * $Log$
|
||
56 | 12213 | jcampos | * 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 | 10340 | caballero | * cancelar agrupaci?n
|
61 | *
|
||
62 | * Revision 1.5 2007/02/14 17:09:43 caballero
|
||
63 | 10330 | caballero | * posici?n layerGroup
|
64 | *
|
||
65 | * Revision 1.4 2007/01/04 07:24:31 caballero
|
||
66 | 9532 | caballero | * isModified
|
67 | *
|
||
68 | * Revision 1.3 2006/10/02 13:52:34 jaume
|
||
69 | 7738 | jaume | * organize impots
|
70 | *
|
||
71 | * Revision 1.2 2006/09/25 15:21:47 jmvivo
|
||
72 | 7567 | jmvivo | * * 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 | 7304 | caballero | * 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 | 7567 | jmvivo | if (selectedItems.length < 2) { |
111 | return false; |
||
112 | 7304 | caballero | } |
113 | 7567 | jmvivo | 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 | 7304 | caballero | |
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 | 10340 | caballero | if (!changename.isAccepted())
|
129 | return;
|
||
130 | 7304 | caballero | String nombre=changename.getName();
|
131 | |||
132 | if (nombre != null){ |
||
133 | 9532 | caballero | |
134 | 7567 | jmvivo | getMapContext().beginAtomicEvent(); |
135 | FLayers parent = selectedItems[0].getParentLayer();
|
||
136 | 12213 | jcampos | // FLayers newGroup = new FLayers(getMapContext(),parent);
|
137 | FLayers newGroup = getMapContext().getNewGroupLayer(parent); |
||
138 | 7567 | jmvivo | newGroup.setName(nombre); |
139 | 10330 | caballero | 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 | 7567 | jmvivo | for (int j=0;j < selectedItems.length;j++){ |
147 | FLayer layer = selectedItems[j]; |
||
148 | parent.removeLayer(layer); |
||
149 | newGroup.addLayer(layer); |
||
150 | 7304 | caballero | } |
151 | 10330 | caballero | parent.addLayer(pos,newGroup); |
152 | 9532 | caballero | |
153 | 7567 | jmvivo | getMapContext().endAtomicEvent(); |
154 | 7304 | caballero | // TRUCO PARA REFRESCAR.
|
155 | getMapContext().invalidate(); |
||
156 | 9532 | caballero | Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
157 | project.setModified(true);
|
||
158 | 7304 | caballero | } |
159 | } |
||
160 | } |