svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / ViewManager.java @ 47585
History | View | Annotate | Download (21 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.project.documents.view; |
25 |
|
26 |
import java.text.NumberFormat; |
27 |
import java.util.ArrayList; |
28 |
import java.util.Collections; |
29 |
import java.util.Comparator; |
30 |
import java.util.HashMap; |
31 |
import java.util.Iterator; |
32 |
import java.util.List; |
33 |
import java.util.Map; |
34 |
import javax.swing.ImageIcon; |
35 |
import org.apache.commons.lang3.StringUtils; |
36 |
import org.apache.commons.lang3.tuple.ImmutablePair; |
37 |
import org.apache.commons.lang3.tuple.Pair; |
38 |
import org.gvsig.andami.IconThemeHelper; |
39 |
import org.gvsig.andami.PluginServices; |
40 |
import org.gvsig.andami.PluginsLocator; |
41 |
import org.gvsig.andami.actioninfo.ActionInfo; |
42 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
43 |
import org.gvsig.andami.messages.NotificationManager; |
44 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
45 |
import org.gvsig.app.project.Project; |
46 |
import org.gvsig.app.project.ProjectManager; |
47 |
import org.gvsig.app.project.documents.AbstractDocument; |
48 |
import org.gvsig.app.project.documents.AbstractDocumentManager; |
49 |
import org.gvsig.app.project.documents.Document; |
50 |
import org.gvsig.app.project.documents.actions.CopyDocumentAction; |
51 |
import org.gvsig.app.project.documents.actions.CutDocumentAction; |
52 |
import org.gvsig.app.project.documents.actions.PasteDocumentAction; |
53 |
import org.gvsig.app.project.documents.gui.IDocumentWindow; |
54 |
import org.gvsig.app.project.documents.gui.WindowLayout; |
55 |
import org.gvsig.app.project.documents.view.dalactions.AddFilterToLayerAction.AddFilterToLayerActionFactory; |
56 |
import org.gvsig.app.project.documents.view.dalactions.CreateTemporalLayerAction; |
57 |
import org.gvsig.app.project.documents.view.dalactions.ViewZoomAction.ViewZoomActionFactory; |
58 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
59 |
import org.gvsig.app.project.documents.view.gui.ViewProperties; |
60 |
import org.gvsig.app.project.documents.view.toc.AbstractActionInfoAdapterToTocContextMenuAction; |
61 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
62 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
63 |
import org.gvsig.app.project.documents.view.toc.TocItemBranch; |
64 |
import org.gvsig.app.project.documents.view.toc.actions.OldTocContextMenuAction; |
65 |
import org.gvsig.fmap.dal.AbstractStoresRepository; |
66 |
import org.gvsig.fmap.dal.DALLocator; |
67 |
import org.gvsig.fmap.dal.DataManager; |
68 |
import org.gvsig.fmap.dal.DataStore; |
69 |
import org.gvsig.fmap.dal.DataStoreParameters; |
70 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
71 |
import org.gvsig.fmap.dal.feature.FeatureType; |
72 |
import org.gvsig.fmap.mapcontext.MapContext; |
73 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
74 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
75 |
import org.gvsig.fmap.mapcontext.layers.ExtendedPropertiesHelper; |
76 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
77 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
78 |
import org.gvsig.tools.ToolsLocator; |
79 |
import org.gvsig.tools.dispose.DisposeUtils; |
80 |
import org.gvsig.tools.dynobject.DynStruct; |
81 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
82 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
83 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
84 |
import org.gvsig.tools.persistence.PersistenceManager; |
85 |
import org.gvsig.tools.util.UnmodifiableBasicSet; |
86 |
import org.gvsig.tools.util.UnmodifiableBasicSetAdapter; |
87 |
import org.slf4j.Logger; |
88 |
import org.slf4j.LoggerFactory; |
89 |
|
90 |
/**
|
91 |
* Factory of View.
|
92 |
*
|
93 |
* @author gvSIG Team
|
94 |
*
|
95 |
*/
|
96 |
public class ViewManager extends AbstractDocumentManager { |
97 |
|
98 |
private static final Logger LOGGER = LoggerFactory.getLogger(ViewManager.class); |
99 |
|
100 |
|
101 |
private static final String PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME |
102 |
= "DefaultViewDocument";
|
103 |
public static String TYPENAME = "project.document.view2d"; |
104 |
private DynStruct persistenceDefinition;
|
105 |
private static int countSeparators = 0; |
106 |
|
107 |
public ViewManager() {
|
108 |
// Do nothing
|
109 |
} |
110 |
|
111 |
@Override
|
112 |
public int getPriority() { |
113 |
return 0; |
114 |
} |
115 |
|
116 |
@Override
|
117 |
public ImageIcon getIcon() { |
118 |
return PluginServices.getIconTheme().get("document-view-icon"); |
119 |
} |
120 |
|
121 |
@Override
|
122 |
public ImageIcon getIconSelected() { |
123 |
return PluginServices.getIconTheme().get("document-view-icon-sel"); |
124 |
} |
125 |
|
126 |
@Override
|
127 |
public String getTitle() { |
128 |
return PluginServices.getText(this, "Vista"); |
129 |
} |
130 |
|
131 |
@Override
|
132 |
public String getTypeName() { |
133 |
return TYPENAME;
|
134 |
} |
135 |
|
136 |
@Override
|
137 |
public Class getMainWindowClass() { |
138 |
return DefaultViewPanel.class;
|
139 |
} |
140 |
|
141 |
@Override
|
142 |
public AbstractDocument createDocument() { |
143 |
AbstractDocument doc = new DefaultViewDocument(this); |
144 |
if (this.notifyObservers(NOTIFY_AFTER_CREATEDOCUMENT, doc).isCanceled()) { |
145 |
return null; |
146 |
} |
147 |
return doc;
|
148 |
|
149 |
} |
150 |
|
151 |
@Override
|
152 |
public IWindow getMainWindow(Document doc, WindowLayout layout) { |
153 |
IDocumentWindow win = (IDocumentWindow) super.getMainWindow(doc, layout);
|
154 |
if (win == null) { |
155 |
win = this.createDocumentWindow(doc);
|
156 |
if (layout != null && win != null) { |
157 |
win.setWindowLayout(layout); |
158 |
} |
159 |
if (this.notifyObservers(NOTIFY_AFTER_CREATEMAINWINDOW, win).isCanceled()) { |
160 |
return null; |
161 |
} |
162 |
} |
163 |
if (this.notifyObservers(NOTIFY_AFTER_GETMAINWINDOW, win).isCanceled()) { |
164 |
return null; |
165 |
} |
166 |
((AbstractDocument) doc).raiseEventCreateWindow(win);
|
167 |
return win;
|
168 |
} |
169 |
|
170 |
@Override
|
171 |
public IWindow getPropertiesWindow(Document doc) { |
172 |
IWindow win = super.getPropertiesWindow(doc);
|
173 |
if (win == null) { |
174 |
win = new ViewProperties((DefaultViewDocument) doc);
|
175 |
if (this.notifyObservers(NOTIFY_AFTER_CREATEPROPERTIESWINDOW, win).isCanceled()) { |
176 |
return null; |
177 |
} |
178 |
} |
179 |
if (this.notifyObservers(NOTIFY_AFTER_GETPROPERTIESWINDOW, win).isCanceled()) { |
180 |
return null; |
181 |
} |
182 |
return win;
|
183 |
} |
184 |
|
185 |
public void addTOCContextAction(String theAction) { |
186 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
187 |
ActionInfo action = actionManager.getAction(theAction); |
188 |
if (action == null) { |
189 |
String errmsg = "Action '" + theAction + "' not found"; |
190 |
LOGGER.info(errmsg); |
191 |
throw new RuntimeException(errmsg); |
192 |
} |
193 |
this.addTOCContextAction(action);
|
194 |
} |
195 |
|
196 |
public void addTOCContextAction(String theAction, String group, int groupOrder, int order) { |
197 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
198 |
ActionInfo action = actionManager.getAction(theAction); |
199 |
if (action == null) { |
200 |
String errmsg = "Action '" + theAction + "' not found"; |
201 |
LOGGER.info(errmsg); |
202 |
throw new RuntimeException(errmsg); |
203 |
} |
204 |
this.addTOCContextAction(
|
205 |
action.getName(), |
206 |
new ActionInfoAdapterToContextMenuAction(action, group, groupOrder, order)
|
207 |
); |
208 |
} |
209 |
|
210 |
public void addTOCContextAction(ActionInfo action) { |
211 |
this.addTOCContextAction(action.getName(), new ActionInfoAdapterToContextMenuAction(action, "default", 9000)); |
212 |
} |
213 |
|
214 |
public void addTOCContextAction(ActionInfo action, String group, int groupOrder) { |
215 |
this.addTOCContextAction(action.getName(), new ActionInfoAdapterToContextMenuAction(action, group, groupOrder)); |
216 |
} |
217 |
|
218 |
public void addTOCSeparator(String group, int groupOrder, int order) { |
219 |
|
220 |
String effectiveGroup = group + "/-" + (countSeparators++) + "-"; |
221 |
|
222 |
this.addTOCContextAction(
|
223 |
// group + "/-",
|
224 |
effectiveGroup, |
225 |
new IContextMenuAction() {
|
226 |
@Override
|
227 |
public boolean isVisible(Object item, Object[] selectedItems) { |
228 |
return true; |
229 |
} |
230 |
|
231 |
@Override
|
232 |
public boolean isEnabled(Object item, Object[] selectedItems) { |
233 |
return true; |
234 |
} |
235 |
|
236 |
@Override
|
237 |
public void execute(Object item, Object[] selectedItems) { |
238 |
} |
239 |
|
240 |
@Override
|
241 |
public String getGroup() { |
242 |
return effectiveGroup; //group + "/-"; |
243 |
} |
244 |
|
245 |
@Override
|
246 |
public int getGroupOrder() { |
247 |
return groupOrder;
|
248 |
} |
249 |
|
250 |
@Override
|
251 |
public int getOrder() { |
252 |
return order;
|
253 |
} |
254 |
|
255 |
@Override
|
256 |
public String getText() { |
257 |
return "-"; |
258 |
} |
259 |
|
260 |
@Override
|
261 |
public String getDescription() { |
262 |
return ""; |
263 |
} |
264 |
} |
265 |
); |
266 |
} |
267 |
|
268 |
class ActionInfoAdapterToContextMenuAction extends AbstractActionInfoAdapterToTocContextMenuAction { |
269 |
|
270 |
ActionInfoAdapterToContextMenuAction(ActionInfo action, String group, int groupOrder) { |
271 |
super(action, group, groupOrder);
|
272 |
} |
273 |
|
274 |
ActionInfoAdapterToContextMenuAction(ActionInfo action, String group, int groupOrder, int order) { |
275 |
super(action, group, groupOrder, order);
|
276 |
} |
277 |
} |
278 |
|
279 |
/**
|
280 |
* @deprecated use addTOCContextAction(ActionInfo action, String group, int
|
281 |
* groupOrder)
|
282 |
* @param id
|
283 |
* @param action
|
284 |
*/
|
285 |
public void addTOCContextAction(String id, IContextMenuAction action) { |
286 |
initializeRegisterTOCActions(); |
287 |
ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add( |
288 |
"View_TocActions", ""); |
289 |
if (action instanceof ExtensionBuilder) { |
290 |
exPoint.append(id, "", (ExtensionBuilder) action);
|
291 |
return;
|
292 |
} |
293 |
exPoint.append(id, "", new ContextMenuActionAdapterToExtensionBuilder(action)); |
294 |
} |
295 |
|
296 |
class ContextMenuActionAdapterToExtensionBuilder implements ExtensionBuilder { |
297 |
|
298 |
IContextMenuAction menuAction = null;
|
299 |
|
300 |
ContextMenuActionAdapterToExtensionBuilder(IContextMenuAction menuAction) { |
301 |
this.menuAction = menuAction;
|
302 |
} |
303 |
|
304 |
@Override
|
305 |
public Object create() { |
306 |
return this.menuAction; |
307 |
} |
308 |
|
309 |
@Override
|
310 |
public Object create(Object[] args) { |
311 |
return this.menuAction; |
312 |
} |
313 |
|
314 |
@Override
|
315 |
public Object create(Map args) { |
316 |
return this.menuAction; |
317 |
} |
318 |
} |
319 |
|
320 |
private static void initializeRegisterTOCActions() { |
321 |
ExtensionPointManager epManager = ToolsLocator.getExtensionPointManager(); |
322 |
|
323 |
if (!epManager.has("View_TocActions")) { |
324 |
epManager.add( |
325 |
"View_TocActions",
|
326 |
"Context menu options of the TOC "
|
327 |
+ " in the view window "
|
328 |
+ "(register instances of "
|
329 |
+ "org.gvsig.app.gui.toc.AbstractTocContextMenuAction)"
|
330 |
); |
331 |
} |
332 |
} |
333 |
|
334 |
/**
|
335 |
* Registers in the points of extension the Factory with alias.
|
336 |
*
|
337 |
*/
|
338 |
public static void register() { |
339 |
ViewManager factory = new ViewManager();
|
340 |
ProjectManager.getInstance().registerDocumentFactory(factory); |
341 |
|
342 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
343 |
manager.registerFactory(factory); |
344 |
|
345 |
initializeRegisterTOCActions(); |
346 |
|
347 |
ProjectManager.getInstance().registerDocumentAction(TYPENAME, new CopyDocumentAction());
|
348 |
ProjectManager.getInstance().registerDocumentAction(TYPENAME, new CutDocumentAction());
|
349 |
ProjectManager.getInstance().registerDocumentAction(TYPENAME, new PasteDocumentAction());
|
350 |
|
351 |
IconThemeHelper.registerIcon("document", "document-view-icon", ViewManager.class); |
352 |
IconThemeHelper.registerIcon("document", "document-view-icon-sel", ViewManager.class); |
353 |
|
354 |
IconThemeHelper.registerIcon("cursor", "cursor-busy", ViewManager.class); |
355 |
IconThemeHelper.registerIcon("cursor", "cursor-crux", ViewManager.class); |
356 |
IconThemeHelper.registerIcon("cursor", "cursor-info-by-point", ViewManager.class); |
357 |
IconThemeHelper.registerIcon("cursor", "cursor-pan", ViewManager.class); |
358 |
IconThemeHelper.registerIcon("cursor", "cursor-query-area", ViewManager.class); |
359 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-point", ViewManager.class); |
360 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-polygon", ViewManager.class); |
361 |
IconThemeHelper.registerIcon("cursor", "cursor-select-by-rectangle", ViewManager.class); |
362 |
IconThemeHelper.registerIcon("cursor", "cursor-zoom-in", ViewManager.class); |
363 |
IconThemeHelper.registerIcon("cursor", "cursor-zoom-out", ViewManager.class); |
364 |
|
365 |
IconThemeHelper.registerIcon("layer", "layer-icon", ViewManager.class); |
366 |
IconThemeHelper.registerIcon("layer", "layer-icon-group", ViewManager.class); |
367 |
IconThemeHelper.registerIcon("layer", "layer-icon-vectorial", ViewManager.class); |
368 |
IconThemeHelper.registerIcon("layer", "layer-icon-csv", ViewManager.class); |
369 |
IconThemeHelper.registerIcon("layer", "layer-icon-dgn", ViewManager.class); |
370 |
IconThemeHelper.registerIcon("layer", "layer-icon-dxf", ViewManager.class); |
371 |
IconThemeHelper.registerIcon("layer", "layer-icon-postgresql", ViewManager.class); |
372 |
IconThemeHelper.registerIcon("layer", "layer-icon-mysql", ViewManager.class); |
373 |
IconThemeHelper.registerIcon("layer", "layer-icon-jdbc", ViewManager.class); |
374 |
//IconThemeHelper.registerIcon("layer", "layer-icon-unavailable", ViewManager.class);
|
375 |
IconThemeHelper.registerIcon("layer", "layer-chk-unavailable", ViewManager.class); |
376 |
IconThemeHelper.registerIcon("layer", "layer-chk-temporary", ViewManager.class); |
377 |
IconThemeHelper.registerIcon("action", "active-layer-bring-front", ViewManager.class); |
378 |
IconThemeHelper.registerIcon("action", "active-layer-move-ahead", ViewManager.class); |
379 |
IconThemeHelper.registerIcon("action", "active-layer-move-behind", ViewManager.class); |
380 |
IconThemeHelper.registerIcon("action", "active-layer-send-back", ViewManager.class); |
381 |
IconThemeHelper.registerIcon("action", "active-layer-set-hide", ViewManager.class); |
382 |
IconThemeHelper.registerIcon("action", "active-layer-set-visible", ViewManager.class); |
383 |
IconThemeHelper.registerIcon("action", "layer-set-visible", ViewManager.class); |
384 |
IconThemeHelper.registerIcon("action", "layer-set-hide", ViewManager.class); |
385 |
IconThemeHelper.registerIcon("action", "layer-set-inactive", ViewManager.class); |
386 |
IconThemeHelper.registerIcon("action", "layer-set-active", ViewManager.class); |
387 |
|
388 |
IconThemeHelper.registerIcon("legend", "legend-overview-single-symbol", ViewManager.class); |
389 |
IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-interval", ViewManager.class); |
390 |
IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-unique-value", ViewManager.class); |
391 |
|
392 |
MapContextManager mapContextMgr = MapContextLocator.getMapContextManager(); |
393 |
mapContextMgr.registerIconLayer("CSV", "layer-icon-csv"); |
394 |
mapContextMgr.registerIconLayer("DGN", "layer-icon-dgn"); |
395 |
mapContextMgr.registerIconLayer("DXF", "layer-icon-dxf"); |
396 |
mapContextMgr.registerIconLayer("jdbc", "layer-icon-jdbc"); |
397 |
mapContextMgr.registerIconLayer("PostgreSQL", "layer-icon-postgresql"); |
398 |
mapContextMgr.registerIconLayer("MySQL", "layer-icon-mysql"); |
399 |
|
400 |
if (factory.persistenceDefinition == null) { |
401 |
factory.persistenceDefinition = manager.addDefinition( |
402 |
ViewDocument.class, |
403 |
PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME, |
404 |
"Default view document persistence definition",
|
405 |
null,
|
406 |
null
|
407 |
); |
408 |
factory.persistenceDefinition.extend(manager.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
|
409 |
|
410 |
factory.persistenceDefinition.addDynFieldBoolean("useMapOverview").setMandatory(true); |
411 |
factory.persistenceDefinition.addDynFieldObject("mainMapContext").setClassOfValue(MapContext.class).setMandatory(true); |
412 |
factory.persistenceDefinition.addDynFieldObject("overviewMapContext").setClassOfValue(MapContext.class).setMandatory(false); |
413 |
factory.persistenceDefinition.addDynFieldObject("propertiesHelper").setClassOfValue(ExtendedPropertiesHelper.class)
|
414 |
.setMandatory(false);
|
415 |
|
416 |
} |
417 |
ViewsDocumentStoresRepository.selfRegister(); |
418 |
ViewZoomActionFactory.selfRegister(); |
419 |
AddFilterToLayerActionFactory.selfRegister(); |
420 |
CreateTemporalLayerAction.CreateTemporalLayerActionFactory.selfRegister(); |
421 |
} |
422 |
|
423 |
@SuppressWarnings("rawtypes") |
424 |
@Override
|
425 |
public DynStruct getDefinition(String className) { |
426 |
|
427 |
if (this.persistenceDefinition.getName().equalsIgnoreCase(className)) { |
428 |
return this.persistenceDefinition; |
429 |
} |
430 |
if (this.persistenceDefinition.getFullName().equalsIgnoreCase(className)) { |
431 |
return this.persistenceDefinition; |
432 |
} |
433 |
if (this.getDocumentClass().getName().equals(className)) { |
434 |
return this.persistenceDefinition; |
435 |
} |
436 |
|
437 |
return null; |
438 |
} |
439 |
|
440 |
@SuppressWarnings("rawtypes") |
441 |
@Override
|
442 |
protected Class getDocumentClass() { |
443 |
return DefaultViewDocument.class;
|
444 |
} |
445 |
|
446 |
@Override
|
447 |
public boolean manages(Object object) { |
448 |
return object instanceof ViewDocument; |
449 |
} |
450 |
|
451 |
public List<IContextMenuAction> getTOCContextMenuActions(MapContext mapContext, FLayer[] selecteds, ITocItem nodeUserObject) { |
452 |
List<IContextMenuAction> actions = new ArrayList<>(); |
453 |
ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add("View_TocActions", ""); |
454 |
Iterator<org.gvsig.tools.extensionpoint.ExtensionPoint.Extension> iter = exPoint.iterator();
|
455 |
IContextMenuAction action; |
456 |
boolean contains = false; |
457 |
ITocItem tocItem = nodeUserObject; |
458 |
if (tocItem instanceof TocItemBranch) { |
459 |
for (int i = 0; i < selecteds.length; i++) { |
460 |
if (selecteds[i].equals(((TocItemBranch) tocItem)
|
461 |
.getLayer())) { |
462 |
contains = true;
|
463 |
break;
|
464 |
} |
465 |
} |
466 |
} else {
|
467 |
contains = true;
|
468 |
} |
469 |
if (contains) {
|
470 |
while (iter.hasNext()) {
|
471 |
action = null;
|
472 |
try {
|
473 |
action = (IContextMenuAction) iter.next().create(); |
474 |
} catch (Exception e) { |
475 |
NotificationManager.addError(e); |
476 |
} |
477 |
if (action != null ) { |
478 |
if( action instanceof AbstractTocContextMenuAction |
479 |
&& !(action instanceof OldTocContextMenuAction)) {
|
480 |
((AbstractTocContextMenuAction)action).setMapContext(mapContext); |
481 |
} |
482 |
if (action.isVisible(nodeUserObject,
|
483 |
selecteds)) { |
484 |
actions.add(action); |
485 |
} |
486 |
} |
487 |
|
488 |
} |
489 |
Collections.sort(actions, new CompareAction()); |
490 |
return actions;
|
491 |
} |
492 |
return null; |
493 |
} |
494 |
|
495 |
private class CompareAction implements Comparator<IContextMenuAction> { |
496 |
|
497 |
public int compare(IContextMenuAction o1, IContextMenuAction o2) { |
498 |
// FIXME: falta formatear los enteros!!!!
|
499 |
NumberFormat formater = NumberFormat.getInstance(); |
500 |
formater.setMinimumIntegerDigits(6);
|
501 |
String key1 =
|
502 |
"" + formater.format(o1.getGroupOrder()) + formater.format(o1.getOrder()) + o1.getGroup();
|
503 |
String key2 =
|
504 |
"" + formater.format(o2.getGroupOrder()) + formater.format(o2.getOrder()) + o2.getGroup();
|
505 |
return key1.compareTo(key2);
|
506 |
} |
507 |
} |
508 |
|
509 |
public boolean existsTOCContextMenuActions(String name) { |
510 |
ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add("View_TocActions", ""); |
511 |
Iterator<org.gvsig.tools.extensionpoint.ExtensionPoint.Extension> iter = exPoint.iterator();
|
512 |
while (iter.hasNext()) {
|
513 |
ExtensionPoint.Extension action = iter.next(); |
514 |
if (action != null ) { |
515 |
if(StringUtils.equalsIgnoreCase(name, action.getName())){
|
516 |
return true; |
517 |
} |
518 |
} |
519 |
} |
520 |
return false; |
521 |
} |
522 |
|
523 |
|
524 |
} |