Statistics
| Revision:

svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / FFrameViewExtension.java @ 46

History | View | Annotate | Download (4.03 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.messages.NotificationManager;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.andami.ui.mdiManager.IWindow;
28
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView;
29
import org.gvsig.app.project.documents.layout.fframes.FFrameView;
30
import org.gvsig.app.project.documents.layout.fframes.IFFrame;
31
import org.gvsig.app.project.documents.layout.gui.LayoutPanel;
32
import org.gvsig.fmap.dal.exception.ReadException;
33

    
34
/**
35
 * Extensi?n preparada para controlar las opciones que se pueden realizar sobre
36
 * una vista a?adida en el Layout.
37
 * 
38
 * @author Vicente Caballero Navarro
39
 */
40
public class FFrameViewExtension extends Extension {
41

    
42
    private LayoutPanel layout = null;
43

    
44
    /**
45
     * @see org.gvsig.andami.plugins.IExtension#initialize()
46
     */
47
    public void initialize() {
48

    
49
    }
50

    
51
    /**
52
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
53
     */
54
    public void execute(String s) {
55
        layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
56

    
57
        if (s.compareTo("layout-view-navigation-zoom-in-topoint") == 0) {
58
            layout.getLayoutControl().setTool("layoutviewzoomin");
59
        } else
60
            if (s.compareTo("layout-view-navigation-zoom-out-topoint") == 0) {
61
                layout.getLayoutControl().setTool("layoutviewzoomout");
62
            } else
63
                if (s.compareTo("layout-view-navigation-zoom-all") == 0) {
64
                    try {
65
                        layout.getLayoutControl().viewFull();
66
                    } catch (ReadException e) {
67
                        NotificationManager.addError("Error de Driver", e);
68
                    }
69
                } else
70
                    if (s.compareTo("layout-view-navigation-pan") == 0) {
71
                        layout.getLayoutControl().setTool("layoutviewpan");
72
                    }
73
        layout.getDocument().setModified(true);
74
    }
75

    
76
    /**
77
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
78
     */
79
    public boolean isEnabled() {
80
        LayoutPanel l =
81
            (LayoutPanel) PluginServices.getMDIManager().getActiveWindow();
82
        IFFrame[] fframes = l.getLayoutContext().getFFrameSelected();
83
        if (!l.getLayoutContext().isEditable()) {
84
            return false;
85
        }
86
        for (int i = 0; i < fframes.length; i++) {
87
            if (fframes[i] instanceof FFrameView
88
                && !(fframes[i] instanceof FFrameOverView)) {
89
                if (((FFrameView) fframes[i]).getView() != null) {
90
                    return true;
91
                }
92
            }
93
        }
94

    
95
        return false;
96
    }
97

    
98
    /**
99
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
100
     */
101
    public boolean isVisible() {
102
        IWindow f = PluginServices.getMDIManager().getActiveWindow();
103

    
104
        if (f == null) {
105
            return false;
106
        }
107

    
108
        if (f instanceof LayoutPanel) {
109
            // Layout layout = (Layout) f;
110

    
111
            return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount()
112
                         // > 0;
113
        } else {
114
            return false;
115
        }
116
    }
117
}