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