Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / ViewCommandStackExtension.java @ 31496

History | View | Annotate | Download (3.04 KB)

1
package org.gvsig.editing;
2

    
3
import org.gvsig.andami.PluginServices;
4
import org.gvsig.andami.plugins.Extension;
5
import org.gvsig.app.gui.command.CommandStackDialog;
6
import org.gvsig.app.project.documents.view.ViewDocument;
7
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
8
import org.gvsig.fmap.dal.exception.DataException;
9
import org.gvsig.fmap.dal.feature.FeatureStore;
10
import org.gvsig.fmap.mapcontext.MapContext;
11
import org.gvsig.fmap.mapcontext.layers.FLayers;
12
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
13

    
14

    
15
/**
16
 * DOCUMENT ME!
17
 *
18
 * @author Vicente Caballero Navarro
19
 */
20
public class ViewCommandStackExtension extends Extension {
21

    
22
        public static CommandStackDialog csd=null;
23
        /**
24
         * @see org.gvsig.andami.plugins.IExtension#initialize()
25
         */
26
        public void initialize() {
27
                PluginServices.getIconTheme().registerDefault(
28
                                "commands-stack",
29
                                this.getClass().getClassLoader().getResource("images/commandstack.png")
30
                        );
31
        }
32

    
33
        /**
34
         * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
35
         */
36
        public void execute(String s) {
37
                org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
38
                                .getActiveWindow();
39

    
40
                DefaultViewPanel vista = (DefaultViewPanel) f;
41
                ViewDocument model = vista.getModel();
42
                MapContext mapa = model.getMapContext();
43
                FLayers layers = mapa.getLayers();
44
                if (s.equals("COMMANDSTACK")) {
45
                        for (int i =0;i<layers.getLayersCount();i++){
46
                                if (layers.getLayer(i) instanceof FLyrVect){
47
                                        FLyrVect lyrVect=(FLyrVect)layers.getLayer(i);
48
                                        if (lyrVect.isEditing() && lyrVect.isActive()){
49
//                                                try{
50
                                                FeatureStore featureStore=lyrVect.getFeatureStore();
51
//                                        CommandsRecord commandsRecord=null;
52
//                                                try {
53
//                                                        commandsRecord = lyrVect.getFeatureStore().getCommandsRecord();
54
//                                                } catch (ReadException e) {
55
//                                                        // TODO Auto-generated catch block
56
//                                                        e.printStackTrace();
57
//                                                } catch (DataException e) {
58
//                                                        // TODO Auto-generated catch block
59
//                                                        e.printStackTrace();
60
//                                                }
61
//                                                commandsRecord.addObserver(this);
62
                                                csd=new CommandStackDialog();
63
                                                csd.setModel(featureStore);
64
                                                PluginServices.getMDIManager().addWindow(csd);
65
//                                                } catch (DataException e) {
66
//                                                        e.printStackTrace();
67
//                                                }
68
                                                return;
69
                                        }
70
                                }
71
                        }
72
                }
73

    
74
                //PluginServices.getMainFrame().enableControls();
75

    
76
        }
77

    
78
        /**
79
         * @see org.gvsig.andami.plugins.IExtension#isEnabled()
80
         */
81
        public boolean isEnabled() {
82

    
83
                return true;
84
        }
85

    
86
        /**
87
         * @see org.gvsig.andami.plugins.IExtension#isVisible()
88
         */
89
        public boolean isVisible() {
90
                if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
91
                        return true;
92
                return false;
93

    
94
        }
95

    
96
//        public void commandRepaint() {
97
//                try {
98
//                        CADExtension.getCADTool().clearSelection();
99
//                } catch (ReadException e) {
100
//                        NotificationManager.addError(e.getMessage(),e);
101
//                }
102
//
103
//        }
104
//
105
//        public void commandRefresh() {
106
//                try {
107
//                        CADExtension.getCADTool().clearSelection();
108
//                } catch (ReadException e) {
109
//                        NotificationManager.addError(e.getMessage(),e);
110
//                }
111
//        }
112

    
113
}