Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutCommandStackExtension.java @ 36648

History | View | Annotate | Download (2.99 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22
package org.gvsig.app.extension;
23

    
24
import org.gvsig.andami.PluginServices;
25
import org.gvsig.andami.plugins.Extension;
26
import org.gvsig.app.gui.command.CommandStackDialog;
27
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
28

    
29
public class LayoutCommandStackExtension extends Extension {
30

    
31
    private LayoutPanel layout = null;
32

    
33
    public void initialize() {
34
        registerIcons();
35
    }
36

    
37
    private void registerIcons() {
38
        PluginServices.getIconTheme().registerDefault(
39
            "edition-command-stack",
40
            this.getClass().getClassLoader()
41
                .getResource("images/commandstack.png"));
42
        PluginServices.getIconTheme().registerDefault(
43
            "edition-modify-command",
44
            this.getClass().getClassLoader()
45
                .getResource("images/ModifyCommand.png"));
46
        PluginServices.getIconTheme().registerDefault(
47
            "edition-add-command",
48
            this.getClass().getClassLoader()
49
                .getResource("images/AddCommand.png"));
50
        PluginServices.getIconTheme().registerDefault(
51
            "edition-del-command",
52
            this.getClass().getClassLoader()
53
                .getResource("images/DelCommand.png"));
54
    }
55

    
56
    public void execute(String s) {
57
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
58
        if (s.equals("COMMANDSTACK")) {
59
            CommandStackDialog csd = new CommandStackDialog();
60
            csd.setModel(layout.getLayoutContext().getFrameCommandsRecord());
61
            layout.getLayoutContext().getFrameCommandsRecord()
62
                .addObserver(layout);
63
            PluginServices.getMDIManager().addWindow(csd);
64
            layout.getDocument().setModified(true);
65
        }
66
    }
67

    
68
    public boolean isEnabled() {
69
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
70
        if (layout.getLayoutContext().isEditable())
71
            return true;
72
        return false;
73
    }
74

    
75
    public boolean isVisible() {
76
        if (PluginServices.getMDIManager().getActiveWindow() instanceof LayoutPanel) {
77
            return true;
78
        }
79
        return false;
80
    }
81

    
82
}