Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extCAD / src / com / iver / cit / gvsig / TableCommandStackExtension.java @ 22932

History | View | Annotate | Download (2.09 KB)

1
package com.iver.cit.gvsig;
2

    
3
import org.gvsig.fmap.data.ReadException;
4
import org.gvsig.fmap.data.commands.CommandsRecord;
5
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
6

    
7
import com.iver.andami.PluginServices;
8
import com.iver.andami.plugins.Extension;
9
import com.iver.cit.gvsig.gui.command.CommandStackDialog;
10
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
11
import com.iver.cit.gvsig.project.documents.table.gui.Table;
12

    
13
/**
14
 * DOCUMENT ME!
15
 *
16
 * @author Vicente Caballero Navarro
17
 */
18
public class TableCommandStackExtension extends Extension {
19
        /**
20
         * @see com.iver.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 com.iver.andami.plugins.IExtension#execute(java.lang.String)
31
         */
32
        public void execute(String s) {
33
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
34
                                .getActiveWindow();
35

    
36
                Table table = (Table) f;
37
                ProjectTable model = table.getModel();
38
                if (s.equals("COMMANDSTACK")) {
39
                        CommandsRecord cr=null;
40

    
41
                        if (model.getAssociatedTable()!=null){
42
                                try {
43
                                        cr=((FLyrVect)model.getAssociatedTable()).getFeatureStore().getCommandsRecord();
44
                                } catch (ReadException e) {
45
                                        // TODO Auto-generated catch block
46
                                        e.printStackTrace();
47
                                }
48
                                cr.addObserver(table);
49
                        }else{
50
                                cr=model.getModel().getCommandsRecord();
51
                                cr.addObserver(table);
52
                        }
53
                        CommandStackDialog csd = new CommandStackDialog();
54
                        csd.setModel(cr);
55
                        PluginServices.getMDIManager().addWindow(csd);
56
                }
57
        }
58

    
59
        /**
60
         * @see com.iver.andami.plugins.IExtension#isEnabled()
61
         */
62
        public boolean isEnabled() {
63
                return true;
64
        }
65

    
66
        /**
67
         * @see com.iver.andami.plugins.IExtension#isVisible()
68
         */
69
        public boolean isVisible() {
70
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
71
                .getActiveWindow();
72
                if (f instanceof Table){
73
                Table table = (Table) f;
74
                ProjectTable model = table.getModel();
75
                if (model.getModel().isEditing())
76
                        return true;
77
                }
78
                        return false;
79

    
80
        }
81
}