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 / LayoutEditVertexExtension.java @ 36648

History | View | Annotate | Download (3.51 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.slf4j.Logger;
25
import org.slf4j.LoggerFactory;
26

    
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.andami.ui.mdiManager.IWindow;
30
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
31

    
32
/**
33
 * Extensi?n que contiene todas las herramientas de edici?n.
34
 * 
35
 * @author Vicente Caballero Navarro
36
 */
37
public class LayoutEditVertexExtension extends Extension {
38

    
39
    private static final Logger logger = LoggerFactory
40
        .getLogger(LayoutEditVertexExtension.class);;
41
    private LayoutPanel layout = null;
42

    
43
    /**
44
     * DOCUMENT ME!
45
     */
46
    public void initialize() {
47
        // TODO Auto-generated method stub
48
        registerIcons();
49
    }
50

    
51
    private void registerIcons() {
52
        PluginServices.getIconTheme().registerDefault("layout-edit-vertex",
53
            this.getClass().getClassLoader().getResource("images/Select1.png"));
54
    }
55

    
56
    /**
57
     * DOCUMENT ME!
58
     * 
59
     * @param s
60
     *            DOCUMENT ME!
61
     */
62
    public void execute(String s) {
63
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
64

    
65
        logger.debug("Comand : " + s);
66
        if (s.compareTo("VERTEX") == 0) {
67
            layout.getLayoutControl().setTool("layoutedit");
68
            layout.getDocument().setModified(true);
69
        }
70
    }
71

    
72
    /**
73
     * DOCUMENT ME!
74
     * 
75
     * @return DOCUMENT ME!
76
     */
77
    public boolean isEnabled() {
78
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
79

    
80
        if (f == null) {
81
            return false;
82
        }
83

    
84
        if (f instanceof LayoutPanel) {
85
            LayoutPanel layout = (LayoutPanel) f;
86
            if (layout.getLayoutContext().isEditable()) {
87
                return true;
88
                // IFFrame[] fframes = layout.getFFrames();
89
                // for (int i = 0; i < fframes.length; i++) {
90
                // if (fframes[i].getSelected() != IFFrame.NOSELECT
91
                // && fframes[i] instanceof IFFrameEditableVertex) {
92
                // return true;
93
                // }
94
                // }
95
            }
96
        }
97
        return false;
98
    }
99

    
100
    /**
101
     * DOCUMENT ME!
102
     * 
103
     * @return DOCUMENT ME!
104
     */
105
    public boolean isVisible() {
106
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
107

    
108
        if (f == null) {
109
            return false;
110
        }
111

    
112
        if (f instanceof LayoutPanel) {
113
            // Layout layout = (Layout) f;
114
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
115
                         // > 0;
116
        } else {
117
            return false;
118
        }
119
    }
120
}