Statistics
| Revision:

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 @ 41081

History | View | Annotate | Download (4.61 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.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 EditionPropertiesTocMenuEntry() {
54
                
55
        }
56
        
57
        public Object create() {
58
                ExtensionPoint ep = this.extensionPoints.add("cad_editing_properties_pages", "");
59
                ep.append("flatness", "", FlatnessPage.class);
60
                ep.append("snapping", "", SnapConfigPage.class);
61
            return super.create();
62
        }
63
        public String getGroup() {
64
                return "edition";
65
        }
66

    
67
        public int getGroupOrder() {
68
                return 60;
69
        }
70

    
71
        public int getOrder() {
72
                return 60;
73
        }
74

    
75
        public String getText() {
76
                return PluginServices.getText(this, "Edition_Properties");
77
        }
78

    
79
        public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
80
                return true;
81
        }
82

    
83
        public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
84
                return (isTocItemBranch(item)) && (selectedItems.length == 1 && selectedItems[0].isAvailable() && selectedItems[0] instanceof FLyrVect) && ((FLyrVect)selectedItems[0]).isEditing();
85
        }
86

    
87
        public void execute(ITocItem item, FLayer[] selectedItems) {
88
                EditionPreferencePage pref = new EditionPreferencePage();
89

    
90
                pref.setMapContext(getMapContext());
91
//                GridPage gridPage=new GridPage();
92
//                gridPage.setParentID(pref.getID());
93
//                FlatnessPage flatnessPage=new FlatnessPage();
94
//                flatnessPage.setParentID(pref.getID());
95

    
96

    
97
                GenericDlgPreferences dlg = new GenericDlgPreferences();
98
                dlg.addPreferencePage(pref);
99
                ExtensionPoint ep = this.extensionPoints.get("cad_editing_properties_pages");
100

    
101
//                 ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
102
//                ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("cad_editing_properties_pages");
103
                Iterator iterator = ep.iterator();
104
                while (iterator.hasNext()) {
105
                    try {
106
                            Extension obj= (Extension)iterator.next();
107
                            AbstractPreferencePage  app = (AbstractPreferencePage )ep.create(obj.getName());
108
                            app.setParentID(pref.getID());
109
                            dlg.addPreferencePage(app);
110
                    } catch (InstantiationException e) {
111
                            NotificationManager.addError(e.getMessage(),e);
112
                    } catch (IllegalAccessException e) {
113
                            NotificationManager.addError(e.getMessage(),e);
114
                    } catch (ClassCastException e) {
115
                            NotificationManager.addError(e.getMessage(),e);
116
                    }
117
                }
118

    
119
//                dlg.addPreferencePage(gridPage);
120
//                dlg.addPreferencePage(flatnessPage);
121
//                dlg.addPreferencePage(fieldExpresionPage);
122
                dlg.getWindowInfo().setTitle(PluginServices.getText(this, "Edition_Properties"));
123
                dlg.setActivePage(pref);
124
                PluginServices.getMDIManager().addWindow(dlg);
125
   }
126
}