Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / TableCommandStackExtension.java @ 25069

History | View | Annotate | Download (2.9 KB)

1
package com.iver.cit.gvsig;
2

    
3
import org.gvsig.fmap.dal.exception.DataException;
4
import org.gvsig.fmap.dal.exception.ReadException;
5
import org.gvsig.fmap.dal.feature.CommandsRecord;
6
import org.gvsig.fmap.dal.feature.FeatureStore;
7
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
8
import org.gvsig.project.document.table.FeatureTableDocument;
9
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
10

    
11
import com.iver.andami.PluginServices;
12
import com.iver.andami.plugins.Extension;
13
import com.iver.cit.gvsig.gui.command.CommandStackDialog;
14
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
15
import com.iver.cit.gvsig.project.documents.table.gui.Table;
16

    
17
/**
18
 * DOCUMENT ME!
19
 *
20
 * @author Vicente Caballero Navarro
21
 */
22
public class TableCommandStackExtension extends Extension {
23
        /**
24
         * @see com.iver.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 com.iver.andami.plugins.IExtension#execute(java.lang.String)
35
         */
36
        public void execute(String s) {
37
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
38
                .getActiveWindow();
39

    
40
                FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f;
41
                FeatureTableDocument model = table.getModel();
42
                if (s.equals("COMMANDSTACK")) {
43
                        try {
44
                                FeatureStore featureStore=((FLyrVect)model.getAssociatedLayer()).getFeatureStore();
45
                                featureStore.addObserver(table);
46

    
47
//                                CommandsRecord cr=null;
48

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

    
71
                                csd.setModel(featureStore.getCommandsRecord());
72

    
73
                                PluginServices.getMDIManager().addWindow(csd);
74
                        } catch (DataException e) {
75
                                e.printStackTrace();
76
                        }
77
                }
78
        }
79

    
80
        /**
81
         * @see com.iver.andami.plugins.IExtension#isEnabled()
82
         */
83
        public boolean isEnabled() {
84
                return true;
85
        }
86

    
87
        /**
88
         * @see com.iver.andami.plugins.IExtension#isVisible()
89
         */
90
        public boolean isVisible() {
91
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
92
                .getActiveWindow();
93
                if (f instanceof FeatureTableDocumentPanel){
94
                FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f;
95
                FeatureTableDocument model = table.getModel();
96
                if (model.getStore().isEditing())
97
                        return true;
98
                }
99
                        return false;
100

    
101
        }
102
}