Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extEditing / src / org / gvsig / editing / TableCommandStackExtension.java @ 29616

History | View | Annotate | Download (2.68 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.table.FeatureTableDocument;
7
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
8
import org.gvsig.fmap.dal.exception.DataException;
9
import org.gvsig.fmap.dal.feature.FeatureStore;
10
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
11

    
12

    
13
/**
14
 * DOCUMENT ME!
15
 *
16
 * @author Vicente Caballero Navarro
17
 */
18
public class TableCommandStackExtension extends Extension {
19
        /**
20
         * @see org.gvsig.andami.plugins.IExtension#initialize()
21
         */
22
        public void initialize() {
23
                PluginServices.getIconTheme().registerDefault(
24
                                "commands-stack",
25
                                this.getClass().getClassLoader().getResource("images/commandstack.png")
26
                        );
27
        }
28

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

    
36
                FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f;
37
                FeatureTableDocument model = table.getModel();
38
                if (s.equals("COMMANDSTACK")) {
39
                        try {
40
                                FeatureStore featureStore=((FLyrVect)model.getAssociatedLayer()).getFeatureStore();
41
                                featureStore.addObserver(table);
42

    
43
//                                CommandsRecord cr=null;
44

    
45
//                                if (model.getAssociatedTable()!=null){
46
//                                try {
47
//                                cr=((FLyrVect)model.getAssociatedTable()).getFeatureStore().getCommandsRecord();
48
//                                } catch (ReadException e) {
49
//                                // TODO Auto-generated catch block
50
//                                e.printStackTrace();
51
//                                } catch (DataException e) {
52
//                                // TODO Auto-generated catch block
53
//                                e.printStackTrace();
54
//                                }
55
//                                cr.addObserver(table);
56
//                                }else{
57
//                                try {
58
//                                cr=model.getModel().getCommandsRecord();
59
//                                } catch (DataException e) {
60
//                                // TODO Auto-generated catch block
61
//                                e.printStackTrace();
62
//                                }
63
//                                cr.addObserver(table);
64
//                                }
65
                                CommandStackDialog csd = new CommandStackDialog();
66

    
67
                                csd.setModel(featureStore);
68

    
69
                                PluginServices.getMDIManager().addWindow(csd);
70
                        } catch (DataException e) {
71
                                e.printStackTrace();
72
                        }
73
                }
74
        }
75

    
76
        /**
77
         * @see org.gvsig.andami.plugins.IExtension#isEnabled()
78
         */
79
        public boolean isEnabled() {
80
                return true;
81
        }
82

    
83
        /**
84
         * @see org.gvsig.andami.plugins.IExtension#isVisible()
85
         */
86
        public boolean isVisible() {
87
                org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
88
                .getActiveWindow();
89
                if (f instanceof FeatureTableDocumentPanel){
90
                FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f;
91
                FeatureTableDocument model = table.getModel();
92
                if (model.getStore().isEditing())
93
                        return true;
94
                }
95
                        return false;
96

    
97
        }
98
}