svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / project / documents / view / toc / actions / EditionPropertiesTocMenuEntry.java @ 40557
History | View | Annotate | Download (4.56 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
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 | 40435 | jjdelcerro | package org.gvsig.editing.project.documents.view.toc.actions; |
25 | |||
26 | import java.util.Iterator; |
||
27 | |||
28 | import org.gvsig.andami.PluginServices; |
||
29 | import org.gvsig.andami.messages.NotificationManager; |
||
30 | import org.gvsig.andami.preferences.AbstractPreferencePage; |
||
31 | import org.gvsig.andami.preferences.GenericDlgPreferences; |
||
32 | import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
||
33 | import org.gvsig.app.project.documents.view.toc.ITocItem; |
||
34 | import org.gvsig.editing.gui.preferences.EditionPreferencePage; |
||
35 | import org.gvsig.editing.gui.preferences.FlatnessPage; |
||
36 | import org.gvsig.editing.gui.preferences.SnapConfigPage; |
||
37 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
38 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
39 | import org.gvsig.tools.ToolsLocator; |
||
40 | import org.gvsig.tools.extensionpoint.ExtensionPoint; |
||
41 | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
||
42 | import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
||
43 | |||
44 | |||
45 | /**
|
||
46 | * Abre el di?logo de propiedades de edici?n.
|
||
47 | *
|
||
48 | * @author Vicente Caballero Navarro
|
||
49 | */
|
||
50 | public class EditionPropertiesTocMenuEntry extends AbstractTocContextMenuAction { |
||
51 | private ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
|
||
52 | |||
53 | public Object create() { |
||
54 | ExtensionPoint ep = this.extensionPoints.add("cad_editing_properties_pages", ""); |
||
55 | ep.append("flatness", "", FlatnessPage.class); |
||
56 | ep.append("snapping", "", SnapConfigPage.class); |
||
57 | return super.create(); |
||
58 | } |
||
59 | public String getGroup() { |
||
60 | return "edition"; |
||
61 | } |
||
62 | |||
63 | public int getGroupOrder() { |
||
64 | return 60; |
||
65 | } |
||
66 | |||
67 | public int getOrder() { |
||
68 | return 60; |
||
69 | } |
||
70 | |||
71 | public String getText() { |
||
72 | return PluginServices.getText(this, "Edition_Properties"); |
||
73 | } |
||
74 | |||
75 | public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
||
76 | return true; |
||
77 | } |
||
78 | |||
79 | public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
||
80 | return (isTocItemBranch(item)) && (selectedItems.length == 1 && selectedItems[0].isAvailable() && selectedItems[0] instanceof FLyrVect) && ((FLyrVect)selectedItems[0]).isEditing(); |
||
81 | } |
||
82 | |||
83 | public void execute(ITocItem item, FLayer[] selectedItems) { |
||
84 | EditionPreferencePage pref = new EditionPreferencePage();
|
||
85 | |||
86 | pref.setMapContext(getMapContext()); |
||
87 | // GridPage gridPage=new GridPage();
|
||
88 | // gridPage.setParentID(pref.getID());
|
||
89 | // FlatnessPage flatnessPage=new FlatnessPage();
|
||
90 | // flatnessPage.setParentID(pref.getID());
|
||
91 | |||
92 | |||
93 | GenericDlgPreferences dlg = new GenericDlgPreferences();
|
||
94 | dlg.addPreferencePage(pref); |
||
95 | ExtensionPoint ep = this.extensionPoints.get("cad_editing_properties_pages"); |
||
96 | |||
97 | // ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
|
||
98 | // ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("cad_editing_properties_pages");
|
||
99 | Iterator iterator = ep.iterator();
|
||
100 | while (iterator.hasNext()) {
|
||
101 | try {
|
||
102 | Extension obj= (Extension)iterator.next(); |
||
103 | AbstractPreferencePage app = (AbstractPreferencePage )ep.create(obj.getName()); |
||
104 | app.setParentID(pref.getID()); |
||
105 | dlg.addPreferencePage(app); |
||
106 | } catch (InstantiationException e) { |
||
107 | NotificationManager.addError(e.getMessage(),e); |
||
108 | } catch (IllegalAccessException e) { |
||
109 | NotificationManager.addError(e.getMessage(),e); |
||
110 | } catch (ClassCastException e) { |
||
111 | NotificationManager.addError(e.getMessage(),e); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | // dlg.addPreferencePage(gridPage);
|
||
116 | // dlg.addPreferencePage(flatnessPage);
|
||
117 | // dlg.addPreferencePage(fieldExpresionPage);
|
||
118 | dlg.getWindowInfo().setTitle(PluginServices.getText(this, "Edition_Properties")); |
||
119 | dlg.setActivePage(pref); |
||
120 | PluginServices.getMDIManager().addWindow(dlg); |
||
121 | } |
||
122 | } |