svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutInsertToolsExtension.java @ 46
History | View | Annotate | Download (9.48 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.IconThemeHelper; |
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
32 |
|
33 |
/**
|
34 |
* Extensi?n para editar los v?rtices de las geometr?as a?adidas en un
|
35 |
* FFrameGraphics.
|
36 |
*
|
37 |
* @author Vicente Caballero Navarro
|
38 |
*/
|
39 |
public class LayoutInsertToolsExtension extends Extension { |
40 |
|
41 |
private static final Logger logger = LoggerFactory |
42 |
.getLogger(LayoutInsertToolsExtension.class); |
43 |
|
44 |
private LayoutPanel layout = null; |
45 |
|
46 |
public void initialize() { |
47 |
// TODO Auto-generated method stub
|
48 |
registerIcons(); |
49 |
} |
50 |
|
51 |
private void registerIcons() { |
52 |
|
53 |
IconThemeHelper.registerIcon("action", "layout-insert-text", this); |
54 |
IconThemeHelper.registerIcon("action", "layout-insert-point", this); |
55 |
IconThemeHelper.registerIcon("action", "layout-insert-rectangle", this); |
56 |
IconThemeHelper.registerIcon("action", "layout-insert-circle", this); |
57 |
|
58 |
IconThemeHelper.registerIcon("action", "layout-insert-line", this); |
59 |
IconThemeHelper.registerIcon("action", "layout-insert-polyline", this); |
60 |
IconThemeHelper.registerIcon("action", "layout-insert-polygon", this); |
61 |
IconThemeHelper.registerIcon("action", "layout-insert-image", this); |
62 |
|
63 |
IconThemeHelper.registerIcon("action", "layout-insert-view", this); |
64 |
IconThemeHelper.registerIcon("action", "layout-insert-locator", this); |
65 |
IconThemeHelper.registerIcon("action", "layout-insert-legend", this); |
66 |
IconThemeHelper.registerIcon("action", "layout-insert-scalebar", this); |
67 |
|
68 |
IconThemeHelper.registerIcon("action", "layout-insert-north", this); |
69 |
IconThemeHelper.registerIcon("action", "layout-insert-box", this); |
70 |
|
71 |
// ============================================================
|
72 |
|
73 |
IconThemeHelper.registerIcon("action", "edit-delete", this); |
74 |
IconThemeHelper.registerIcon("action", "selection-by-rectangle", this); |
75 |
} |
76 |
|
77 |
public void execute(String s) { |
78 |
layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
79 |
|
80 |
logger.debug("Comand : " + s);
|
81 |
boolean insertGroupPosibility = false; |
82 |
|
83 |
if (s.equals("selection-select-by-rectangle-layout")) { |
84 |
layout.getLayoutControl().setTool("layoutselect");
|
85 |
} else
|
86 |
if (s.equals("layout-insert-view")) { |
87 |
layout.getLayoutControl().setTool("layoutaddview");
|
88 |
insertGroupPosibility = true;
|
89 |
} else
|
90 |
if (s.equals("layout-insert-locator")) { |
91 |
layout.getLayoutControl().setTool("layoutaddoverview");
|
92 |
insertGroupPosibility = true;
|
93 |
} else
|
94 |
if (s.equals("layout-insert-image")) { |
95 |
layout.getLayoutControl().setTool("layoutaddpicture");
|
96 |
insertGroupPosibility = true;
|
97 |
} else
|
98 |
if (s.equals("layout-insert-scalebar")) { |
99 |
layout.getLayoutControl().setTool("layoutaddscale");
|
100 |
insertGroupPosibility = true;
|
101 |
} else
|
102 |
if (s.equals("layout-insert-legend")) { |
103 |
layout.getLayoutControl().setTool( |
104 |
"layoutaddlegend");
|
105 |
insertGroupPosibility = true;
|
106 |
} else
|
107 |
if (s.equals("layout-insert-text")) { |
108 |
layout.getLayoutControl().setTool( |
109 |
"layoutaddtext");
|
110 |
insertGroupPosibility = true;
|
111 |
} else
|
112 |
if (s.equals("layout-insert-north")) { |
113 |
layout.getLayoutControl().setTool( |
114 |
"layoutaddnorth");
|
115 |
insertGroupPosibility = true;
|
116 |
} else
|
117 |
if (s.equals("layout-insert-box")) { |
118 |
layout.getLayoutControl().setTool( |
119 |
"layoutaddbox");
|
120 |
insertGroupPosibility = true;
|
121 |
} else
|
122 |
if (s.equals("layout-insert-point")) { |
123 |
layout.getLayoutControl() |
124 |
.setTool("layoutaddpoint");
|
125 |
} else
|
126 |
if (s.equals("layout-insert-line")) { |
127 |
layout.getLayoutControl() |
128 |
.setTool( |
129 |
"layoutaddline");
|
130 |
} else
|
131 |
if (s.equals("layout-insert-polyline")) { |
132 |
layout |
133 |
.getLayoutControl() |
134 |
.setTool( |
135 |
"layoutaddpolyline");
|
136 |
} else
|
137 |
if (s.equals("layout-insert-circle")) { |
138 |
layout |
139 |
.getLayoutControl() |
140 |
.setTool( |
141 |
"layoutaddcircle");
|
142 |
} else
|
143 |
if (s
|
144 |
.equals("layout-insert-rectangle")) {
|
145 |
layout |
146 |
.getLayoutControl() |
147 |
.setTool( |
148 |
"layoutaddrectangle");
|
149 |
} else
|
150 |
if (s
|
151 |
.equals("layout-insert-polygon")) {
|
152 |
layout |
153 |
.getLayoutControl() |
154 |
.setTool( |
155 |
"layoutaddpolygon");
|
156 |
} else
|
157 |
if (s
|
158 |
.equals("edit-delete-layout")) {
|
159 |
layout |
160 |
.getLayoutContext() |
161 |
.delFFrameSelected(); |
162 |
layout |
163 |
.getLayoutControl() |
164 |
.refresh(); |
165 |
} |
166 |
layout.getDocument().setModified(true);
|
167 |
} |
168 |
|
169 |
public boolean isEnabled() { |
170 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
171 |
|
172 |
if (f == null) { |
173 |
return false; |
174 |
} |
175 |
|
176 |
if (f instanceof LayoutPanel) { |
177 |
return ((LayoutPanel) f).getLayoutContext().isEditable();
|
178 |
} |
179 |
|
180 |
return false; |
181 |
} |
182 |
|
183 |
public boolean isVisible() { |
184 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
185 |
|
186 |
if (f == null) { |
187 |
return false; |
188 |
} |
189 |
|
190 |
if (f instanceof LayoutPanel) { |
191 |
return true; |
192 |
} else {
|
193 |
return false; |
194 |
} |
195 |
} |
196 |
} |