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 | 5 | jldominguez | /* 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 | 24 | jldominguez | import org.gvsig.andami.IconThemeHelper; |
28 | 5 | jldominguez | 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 | 24 | jldominguez | |
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 | 5 | jldominguez | |
58 | 24 | jldominguez | 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 | 5 | jldominguez | |
63 | 24 | jldominguez | 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 | 5 | jldominguez | |
68 | 24 | jldominguez | IconThemeHelper.registerIcon("action", "layout-insert-north", this); |
69 | IconThemeHelper.registerIcon("action", "layout-insert-box", this); |
||
70 | 5 | jldominguez | |
71 | 24 | jldominguez | // ============================================================
|
72 | |||
73 | IconThemeHelper.registerIcon("action", "edit-delete", this); |
||
74 | IconThemeHelper.registerIcon("action", "selection-by-rectangle", this); |
||
75 | 5 | jldominguez | } |
76 | |||
77 | public void execute(String s) { |
||
78 | layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
||
79 | |||
80 | logger.debug("Comand : " + s);
|
||
81 | boolean insertGroupPosibility = false; |
||
82 | 24 | jldominguez | |
83 | 36 | jldominguez | if (s.equals("selection-select-by-rectangle-layout")) { |
84 | 5 | jldominguez | layout.getLayoutControl().setTool("layoutselect");
|
85 | } else
|
||
86 | 24 | jldominguez | if (s.equals("layout-insert-view")) { |
87 | 5 | jldominguez | layout.getLayoutControl().setTool("layoutaddview");
|
88 | insertGroupPosibility = true;
|
||
89 | } else
|
||
90 | 24 | jldominguez | if (s.equals("layout-insert-locator")) { |
91 | 5 | jldominguez | layout.getLayoutControl().setTool("layoutaddoverview");
|
92 | insertGroupPosibility = true;
|
||
93 | } else
|
||
94 | 24 | jldominguez | if (s.equals("layout-insert-image")) { |
95 | 5 | jldominguez | layout.getLayoutControl().setTool("layoutaddpicture");
|
96 | insertGroupPosibility = true;
|
||
97 | } else
|
||
98 | 24 | jldominguez | if (s.equals("layout-insert-scalebar")) { |
99 | 5 | jldominguez | layout.getLayoutControl().setTool("layoutaddscale");
|
100 | insertGroupPosibility = true;
|
||
101 | } else
|
||
102 | 24 | jldominguez | if (s.equals("layout-insert-legend")) { |
103 | 5 | jldominguez | layout.getLayoutControl().setTool( |
104 | "layoutaddlegend");
|
||
105 | insertGroupPosibility = true;
|
||
106 | } else
|
||
107 | 24 | jldominguez | if (s.equals("layout-insert-text")) { |
108 | 5 | jldominguez | layout.getLayoutControl().setTool( |
109 | "layoutaddtext");
|
||
110 | insertGroupPosibility = true;
|
||
111 | } else
|
||
112 | 24 | jldominguez | if (s.equals("layout-insert-north")) { |
113 | 5 | jldominguez | layout.getLayoutControl().setTool( |
114 | "layoutaddnorth");
|
||
115 | insertGroupPosibility = true;
|
||
116 | } else
|
||
117 | 24 | jldominguez | if (s.equals("layout-insert-box")) { |
118 | 5 | jldominguez | layout.getLayoutControl().setTool( |
119 | "layoutaddbox");
|
||
120 | insertGroupPosibility = true;
|
||
121 | } else
|
||
122 | 24 | jldominguez | if (s.equals("layout-insert-point")) { |
123 | 5 | jldominguez | layout.getLayoutControl() |
124 | .setTool("layoutaddpoint");
|
||
125 | } else
|
||
126 | 24 | jldominguez | if (s.equals("layout-insert-line")) { |
127 | 5 | jldominguez | layout.getLayoutControl() |
128 | .setTool( |
||
129 | "layoutaddline");
|
||
130 | } else
|
||
131 | 24 | jldominguez | if (s.equals("layout-insert-polyline")) { |
132 | 5 | jldominguez | layout |
133 | .getLayoutControl() |
||
134 | .setTool( |
||
135 | "layoutaddpolyline");
|
||
136 | } else
|
||
137 | 24 | jldominguez | if (s.equals("layout-insert-circle")) { |
138 | 5 | jldominguez | layout |
139 | .getLayoutControl() |
||
140 | .setTool( |
||
141 | "layoutaddcircle");
|
||
142 | } else
|
||
143 | if (s
|
||
144 | 24 | jldominguez | .equals("layout-insert-rectangle")) {
|
145 | 5 | jldominguez | layout |
146 | .getLayoutControl() |
||
147 | .setTool( |
||
148 | "layoutaddrectangle");
|
||
149 | } else
|
||
150 | if (s
|
||
151 | 24 | jldominguez | .equals("layout-insert-polygon")) {
|
152 | 5 | jldominguez | layout |
153 | .getLayoutControl() |
||
154 | .setTool( |
||
155 | "layoutaddpolygon");
|
||
156 | } else
|
||
157 | if (s
|
||
158 | 24 | jldominguez | .equals("edit-delete-layout")) {
|
159 | 5 | jldominguez | 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 | } |