svn-gvsig-desktop / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / view / toc / gui / FLyrVectEditPropertiesTocMenuEntry2.java @ 11588
History | View | Annotate | Download (6.77 KB)
1 |
package com.iver.cit.gvsig.project.documents.view.toc.gui; |
---|---|
2 |
|
3 |
import javax.swing.JDialog; |
4 |
|
5 |
import com.iver.andami.PluginServices; |
6 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer; |
7 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
8 |
import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation; |
9 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
10 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
11 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.FThemeManagerWindow; |
12 |
import com.iver.cit.gvsig.project.documents.view.legend.gui.FThemeManagerWindow2; |
13 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
14 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
16 |
*
|
17 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
18 |
*
|
19 |
* This program is free software; you can redistribute it and/or
|
20 |
* modify it under the terms of the GNU General Public License
|
21 |
* as published by the Free Software Foundation; either version 2
|
22 |
* of the License, or (at your option) any later version.
|
23 |
*
|
24 |
* This program is distributed in the hope that it will be useful,
|
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
* GNU General Public License for more details.
|
28 |
*
|
29 |
* You should have received a copy of the GNU General Public License
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
32 |
*
|
33 |
* For more information, contact:
|
34 |
*
|
35 |
* Generalitat Valenciana
|
36 |
* Conselleria d'Infraestructures i Transport
|
37 |
* Av. Blasco Ib??ez, 50
|
38 |
* 46010 VALENCIA
|
39 |
* SPAIN
|
40 |
*
|
41 |
* +34 963862235
|
42 |
* gvsig@gva.es
|
43 |
* www.gvsig.gva.es
|
44 |
*
|
45 |
* or
|
46 |
*
|
47 |
* IVER T.I. S.A
|
48 |
* Salamanca 50
|
49 |
* 46005 Valencia
|
50 |
* Spain
|
51 |
*
|
52 |
* +34 963163400
|
53 |
* dac@iver.es
|
54 |
*/
|
55 |
/**
|
56 |
* Muestra el men? de propiedades del tema.
|
57 |
*
|
58 |
* @author jmorell
|
59 |
*/
|
60 |
|
61 |
|
62 |
public class FLyrVectEditPropertiesTocMenuEntry2 extends AbstractTocContextMenuAction { |
63 |
public String getGroup() { |
64 |
return "group2"; //FIXME |
65 |
} |
66 |
|
67 |
public int getGroupOrder() { |
68 |
return 20; |
69 |
} |
70 |
|
71 |
public int getOrder() { |
72 |
return 0; |
73 |
} |
74 |
|
75 |
public String getText() { |
76 |
return PluginServices.getText(this, "propiedades"); |
77 |
} |
78 |
|
79 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
80 |
return selectedItems.length == 1; |
81 |
} |
82 |
|
83 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
84 |
if (isTocItemBranch(item)) {
|
85 |
FLayer lyr = getNodeLayer(item); |
86 |
if ((lyr instanceof ClassifiableVectorial)) { |
87 |
if (!((lyr instanceof FLyrVect) && |
88 |
!((FLyrVect)lyr).isPropertiesMenuVisible())){ |
89 |
if (!(lyr instanceof FLyrAnnotation)) |
90 |
return true; |
91 |
} |
92 |
|
93 |
} |
94 |
} |
95 |
return false; |
96 |
|
97 |
} |
98 |
|
99 |
|
100 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
101 |
FLayer[] actives = selectedItems;
|
102 |
if (actives[0] instanceof Annotation_Layer) |
103 |
annotationExecute(item,selectedItems); |
104 |
else
|
105 |
vectorialExecute(item,selectedItems); |
106 |
} |
107 |
|
108 |
private void vectorialExecute(ITocItem item, FLayer[] selectedItems) { |
109 |
FLayer[] actives = selectedItems;
|
110 |
FThemeManagerWindow fThemeManagerWindow; |
111 |
if (actives.length==1) { |
112 |
if (!actives[0].isAvailable()) return; |
113 |
System.out.println("openPliegoThemeProperties(): Una sola capa. Abrimos el panel para la capa " + actives[0]); |
114 |
fThemeManagerWindow = new FThemeManagerWindow(actives[0],actives[0].getMapContext()); |
115 |
try {
|
116 |
fThemeManagerWindow.setMapContext(getMapContext()); |
117 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
118 |
e1.printStackTrace(); |
119 |
} |
120 |
//PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
121 |
if (PluginServices.getMainFrame() == null) { |
122 |
JDialog dlg = new JDialog(); |
123 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize()); |
124 |
dlg.getContentPane().add(fThemeManagerWindow); |
125 |
dlg.setModal(false);
|
126 |
dlg.pack(); |
127 |
dlg.show(); |
128 |
} else {
|
129 |
PluginServices.getMDIManager().addWindow(fThemeManagerWindow); |
130 |
} |
131 |
} else {
|
132 |
for (int i = 0; i < actives.length; i++){ |
133 |
if (actives[0].isAvailable()) { |
134 |
System.out.println("openPliegoThemeProperties(): Muchas capas. Abrimos el panel para la capa " + actives[i]); |
135 |
fThemeManagerWindow = new FThemeManagerWindow(actives[i], getMapContext());
|
136 |
//PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
137 |
if (PluginServices.getMainFrame() == null) { |
138 |
JDialog dlg = new JDialog(); |
139 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize()); |
140 |
dlg.getContentPane().add(fThemeManagerWindow); |
141 |
dlg.setModal(false);
|
142 |
dlg.pack(); |
143 |
dlg.show(); |
144 |
} else {
|
145 |
PluginServices.getMDIManager().addWindow(fThemeManagerWindow); |
146 |
} |
147 |
} |
148 |
} |
149 |
} |
150 |
} |
151 |
|
152 |
private void annotationExecute(ITocItem item, FLayer[] selectedItems) { |
153 |
FLayer[] actives = selectedItems;
|
154 |
FThemeManagerWindow2 fThemeManagerWindow; |
155 |
if (actives.length==1) { |
156 |
if (!actives[0].isAvailable()) return; |
157 |
System.out.println("openPliegoThemeProperties(): Una sola capa. Abrimos el panel para la capa " + actives[0]); |
158 |
fThemeManagerWindow = new FThemeManagerWindow2(actives[0],actives[0].getMapContext()); |
159 |
try {
|
160 |
fThemeManagerWindow.setMapContext(getMapContext()); |
161 |
} catch (com.iver.cit.gvsig.fmap.DriverException e1) {
|
162 |
e1.printStackTrace(); |
163 |
} |
164 |
//PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
165 |
if (PluginServices.getMainFrame() == null) { |
166 |
JDialog dlg = new JDialog(); |
167 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize()); |
168 |
dlg.getContentPane().add(fThemeManagerWindow); |
169 |
dlg.setModal(false);
|
170 |
dlg.pack(); |
171 |
dlg.show(); |
172 |
} else {
|
173 |
PluginServices.getMDIManager().addWindow(fThemeManagerWindow); |
174 |
} |
175 |
} else {
|
176 |
for (int i = 0; i < actives.length; i++){ |
177 |
if (actives[0].isAvailable()) { |
178 |
System.out.println("openPliegoThemeProperties(): Muchas capas. Abrimos el panel para la capa " + actives[i]); |
179 |
fThemeManagerWindow = new FThemeManagerWindow2(actives[i], getMapContext());
|
180 |
//PluginServices.getMDIManager().addView(fThemeManagerWindow);
|
181 |
if (PluginServices.getMainFrame() == null) { |
182 |
JDialog dlg = new JDialog(); |
183 |
fThemeManagerWindow.setPreferredSize(fThemeManagerWindow.getSize()); |
184 |
dlg.getContentPane().add(fThemeManagerWindow); |
185 |
dlg.setModal(false);
|
186 |
dlg.pack(); |
187 |
dlg.show(); |
188 |
} else {
|
189 |
PluginServices.getMDIManager().addWindow(fThemeManagerWindow); |
190 |
} |
191 |
} |
192 |
} |
193 |
} |
194 |
} |
195 |
|
196 |
} |