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 / FFrameViewExtension.java @ 36648
History | View | Annotate | Download (4.63 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 |
registerIcons(); |
49 |
} |
50 |
|
51 |
private void registerIcons() { |
52 |
PluginServices.getIconTheme().registerDefault("view-zoom-in",
|
53 |
this.getClass().getClassLoader().getResource("images/ZoomIn.png")); |
54 |
PluginServices.getIconTheme().registerDefault("view-zoom-out",
|
55 |
this.getClass().getClassLoader().getResource("images/ZoomOut.png")); |
56 |
PluginServices.getIconTheme().registerDefault( |
57 |
"view-zoom-map-contents",
|
58 |
this.getClass().getClassLoader()
|
59 |
.getResource("images/MapContents.png"));
|
60 |
PluginServices.getIconTheme().registerDefault("view-pan",
|
61 |
this.getClass().getClassLoader().getResource("images/Pan.png")); |
62 |
} |
63 |
|
64 |
/**
|
65 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
66 |
*/
|
67 |
public void execute(String s) { |
68 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
69 |
|
70 |
if (s.compareTo("VIEW_ZOOMIN") == 0) { |
71 |
layout.getLayoutControl().setTool("layoutviewzoomin");
|
72 |
} else
|
73 |
if (s.compareTo("VIEW_ZOOMOUT") == 0) { |
74 |
layout.getLayoutControl().setTool("layoutviewzoomout");
|
75 |
} else
|
76 |
if (s.compareTo("VIEW_FULL") == 0) { |
77 |
try {
|
78 |
layout.getLayoutControl().viewFull(); |
79 |
} catch (ReadException e) {
|
80 |
NotificationManager.addError("Error de Driver", e);
|
81 |
} |
82 |
} else
|
83 |
if (s.compareTo("VIEW_PAN") == 0) { |
84 |
layout.getLayoutControl().setTool("layoutviewpan");
|
85 |
} |
86 |
layout.getDocument().setModified(true);
|
87 |
} |
88 |
|
89 |
/**
|
90 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
91 |
*/
|
92 |
public boolean isEnabled() { |
93 |
LayoutPanel l = |
94 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
95 |
IFFrame[] fframes = l.getLayoutContext().getFFrameSelected();
|
96 |
if (!l.getLayoutContext().isEditable()) {
|
97 |
return false; |
98 |
} |
99 |
for (int i = 0; i < fframes.length; i++) { |
100 |
if (fframes[i] instanceof FFrameView |
101 |
&& !(fframes[i] instanceof FFrameOverView)) {
|
102 |
if (((FFrameView) fframes[i]).getView() != null) { |
103 |
return true; |
104 |
} |
105 |
} |
106 |
} |
107 |
|
108 |
return false; |
109 |
} |
110 |
|
111 |
/**
|
112 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
113 |
*/
|
114 |
public boolean isVisible() { |
115 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
116 |
|
117 |
if (f == null) { |
118 |
return false; |
119 |
} |
120 |
|
121 |
if (f instanceof LayoutPanel) { |
122 |
// Layout layout = (Layout) f;
|
123 |
|
124 |
return true; // layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() |
125 |
// > 0;
|
126 |
} else {
|
127 |
return false; |
128 |
} |
129 |
} |
130 |
} |