svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / extension / develtools / ActionsInfoDevelTool.java @ 43101
History | View | Annotate | Download (11.1 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.extension.develtools; |
25 |
|
26 |
import java.awt.Component; |
27 |
import java.util.Arrays; |
28 |
import java.util.Comparator; |
29 |
import java.util.Iterator; |
30 |
import org.gvsig.andami.PluginsLocator; |
31 |
import org.gvsig.andami.actioninfo.ActionInfo; |
32 |
import org.gvsig.andami.actioninfo.ActionInfoManager; |
33 |
import org.gvsig.andami.ui.mdiFrame.MainFrame; |
34 |
import org.gvsig.andami.ui.mdiFrame.SelectableToolBar; |
35 |
import org.gvsig.app.ApplicationLocator; |
36 |
import org.gvsig.app.ApplicationManager; |
37 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
38 |
|
39 |
public class ActionsInfoDevelTool { |
40 |
|
41 |
public void showActions() { |
42 |
String html = "<html>\n<body>\n"+ this.getActionsInformation(null)+"</body>\n</html>\n"; |
43 |
|
44 |
InfoPanel.save2file("actions-report", html);
|
45 |
InfoPanel.showPanel("Actions information", WindowManager.MODE.WINDOW, html);
|
46 |
} |
47 |
|
48 |
public void showToolBars() { |
49 |
ActionInfoManager actionsManager = PluginsLocator.getActionInfoManager(); |
50 |
MainFrame mainFrame = ApplicationLocator.getManager().getMainFrame(); |
51 |
SelectableToolBar[] toolbars = mainFrame.getToolbars();
|
52 |
Arrays.sort(toolbars, new Comparator<SelectableToolBar>() { |
53 |
@Override
|
54 |
public int compare(SelectableToolBar o1, SelectableToolBar o2) { |
55 |
return Integer.compare(o1.getPosition(), o2.getPosition()); |
56 |
} |
57 |
}); |
58 |
|
59 |
StringBuilder buffer = new StringBuilder(); |
60 |
|
61 |
buffer.append("<html>\n");
|
62 |
buffer.append("<body>\n");
|
63 |
|
64 |
buffer.append("<div>\n");
|
65 |
buffer.append("<h2>Toolbars information</h2>\n");
|
66 |
buffer.append("<br>\n");
|
67 |
|
68 |
buffer.append("<table border=\"0\">\n");
|
69 |
buffer.append(" <tr>\n");
|
70 |
buffer.append(" <td>Position</td>\n");
|
71 |
buffer.append(" <td>Name</td>\n");
|
72 |
buffer.append(" <td></td>\n");
|
73 |
buffer.append(" <td>Plugin</td>\n");
|
74 |
buffer.append(" </tr>\n");
|
75 |
for (SelectableToolBar toolBar : toolbars) {
|
76 |
buffer.append(" <tr valign=\"top\">\n");
|
77 |
buffer.append(" <td>")
|
78 |
.append(toolBar.getPosition()) |
79 |
.append("</td>\n");
|
80 |
buffer.append(" <td colspan=\"3\"><b>")
|
81 |
.append(toolBar.getName()) |
82 |
.append("</b> - ")
|
83 |
.append(toolBar.getDescription()) |
84 |
.append("</td>\n");
|
85 |
buffer.append(" </tr>\n");
|
86 |
Component item;;
|
87 |
for( int i=0; (item=toolBar.getComponentAtIndex(i))!=null; i++) { |
88 |
String name = item.getName();
|
89 |
ActionInfo action = null;
|
90 |
if( name!=null ) { |
91 |
action = actionsManager.getAction(name); |
92 |
} |
93 |
buffer.append(" <tr valign=\"top\">\n");
|
94 |
buffer.append(" <td></td>\n");
|
95 |
buffer.append(" <td>");
|
96 |
buffer.append(name); |
97 |
buffer.append(" </td>\n");
|
98 |
if( action!=null ) { |
99 |
buffer.append(" <td>");
|
100 |
buffer.append(action.getPosition()); |
101 |
buffer.append("</td>\n");
|
102 |
buffer.append(" <td>");
|
103 |
buffer.append(action.getPluginName()); |
104 |
buffer.append("</td>\n");
|
105 |
} else {
|
106 |
buffer.append(" <td></td>\n");
|
107 |
buffer.append(" <td></td>\n");
|
108 |
} |
109 |
buffer.append(" </tr>\n");
|
110 |
} |
111 |
} |
112 |
buffer.append("</table>\n");
|
113 |
buffer.append("</div>\n");
|
114 |
buffer.append("</body>\n");
|
115 |
buffer.append("</html>\n");
|
116 |
|
117 |
String html = buffer.toString();
|
118 |
InfoPanel.save2file("toolbars-report", html);
|
119 |
InfoPanel.showPanel("Toolbars report", WindowManager.MODE.WINDOW, html);
|
120 |
} |
121 |
|
122 |
public void showReportOfPlugin() { |
123 |
ApplicationManager application = ApplicationLocator.getManager(); |
124 |
String pluginName = null; |
125 |
|
126 |
pluginName = application.inputDialog("Introduzca el nombre del plugin del que desea el informe", "Plugin actions report"); |
127 |
if( pluginName == null ) { |
128 |
return;
|
129 |
} |
130 |
String actionsHtml = this.getActionsInformation(pluginName); |
131 |
String menusHtml = new MenusDevelTool().getMenusOfPlugin(pluginName); |
132 |
String iconsHtml = new IconThemeDevelTool().getIconThemeInformationOfPlugin(pluginName); |
133 |
|
134 |
String html = "<html>\n<body>\n"+actionsHtml+"<br>"+menusHtml+"<br>"+iconsHtml+"</body>\n</html>\n"; |
135 |
|
136 |
InfoPanel.save2file("plugin-report", html);
|
137 |
InfoPanel.showPanel("Plugin report", WindowManager.MODE.WINDOW, html);
|
138 |
} |
139 |
|
140 |
|
141 |
|
142 |
public String getActionsInformation(String pluginName) { |
143 |
|
144 |
String previousPluginName = null; |
145 |
|
146 |
String warning_open = "<b>"; |
147 |
String warning_close = "</b>"; |
148 |
|
149 |
String error_open = "<b><font color=\"red\">"; |
150 |
String error_close = "</font></b>"; |
151 |
|
152 |
StringBuffer buffer = new StringBuffer(); |
153 |
|
154 |
buffer.append("<html>\n");
|
155 |
buffer.append("<body>\n");
|
156 |
|
157 |
buffer.append("<div>\n");
|
158 |
buffer.append("<h2>Actions information </h2>\n");
|
159 |
buffer.append("<br>\n");
|
160 |
|
161 |
buffer.append("<table border=\"0\">\n");
|
162 |
buffer.append(" <tr>\n");
|
163 |
buffer.append(" <td>Plugin</td>\n");
|
164 |
buffer.append(" <td>Extension</td>\n");
|
165 |
buffer.append(" <td>Name</td>\n");
|
166 |
buffer.append(" <td>Position</td>\n");
|
167 |
buffer.append(" <td>Text</td>\n");
|
168 |
buffer.append(" <td>Command</td>\n");
|
169 |
buffer.append(" <td>Icon</td>\n");
|
170 |
buffer.append(" <td>Tip</td>\n");
|
171 |
buffer.append(" <td>Accelerator</td>\n");
|
172 |
buffer.append(" </tr>\n");
|
173 |
Iterator<ActionInfo> actions = PluginsLocator.getActionInfoManager().getActions();
|
174 |
while (actions.hasNext()) {
|
175 |
ActionInfo action = actions.next(); |
176 |
if( pluginName!=null && !pluginName.equalsIgnoreCase(action.getPluginName()) ) { |
177 |
continue;
|
178 |
} |
179 |
if( previousPluginName!=null && !action.getPluginName().equals(previousPluginName) ) { |
180 |
buffer |
181 |
.append(" <tr>\n")
|
182 |
.append(" <td colspan=\"9\"><hr></td>\n")
|
183 |
.append(" </tr>\n");
|
184 |
previousPluginName = action.getPluginName(); |
185 |
} |
186 |
buffer.append(" <tr valign=\"top\">\n");
|
187 |
buffer.append(" <td>")
|
188 |
.append(action.getPluginName()) |
189 |
.append("</td>\n");
|
190 |
buffer.append(" <td>")
|
191 |
.append(action.getExtensionName()) |
192 |
.append("</td>\n");
|
193 |
if( action.getName().startsWith("anonymous__") ) { |
194 |
buffer.append(" <td title=\"Missing action name, asigned one by default\">")
|
195 |
.append(error_open) |
196 |
.append(action.getName()) |
197 |
.append(error_close) |
198 |
.append("</td>\n");
|
199 |
} else if( !action.getName().contains("-") ) { |
200 |
buffer.append(" <td title=\"Name don't have recomended syntax\">")
|
201 |
.append(warning_open) |
202 |
.append(action.getName()) |
203 |
.append(warning_close) |
204 |
.append("</td>\n");
|
205 |
} else {
|
206 |
buffer.append(" <td>")
|
207 |
.append(action.getName()) |
208 |
.append("</td>\n");
|
209 |
} |
210 |
if( action.getPosition()<100000000 ) { |
211 |
buffer.append(" <td title=\"Incorrect position\">")
|
212 |
.append(error_open) |
213 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
214 |
.append(error_close) |
215 |
.append("</td>\n");
|
216 |
} else {
|
217 |
buffer.append(" <td>")
|
218 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
219 |
.append("</td>\n");
|
220 |
} |
221 |
if( action.getLabel()==null ) { |
222 |
buffer.append(" <td title=\"Missing label of action\">")
|
223 |
.append(error_open) |
224 |
.append("(missing)")
|
225 |
.append(error_close) |
226 |
.append("</td>\n");
|
227 |
} else {
|
228 |
buffer.append(" <td>")
|
229 |
.append(action.getLabel()) |
230 |
.append("</td>\n");
|
231 |
} |
232 |
if( action.getCommand()==null ) { |
233 |
buffer.append(" <td title=\"Missing command of action\">")
|
234 |
.append(error_open) |
235 |
.append(action.getCommand()) |
236 |
.append(error_close) |
237 |
.append("</td>\n");
|
238 |
|
239 |
} else if(!action.getCommand().contains("-") && !action.getCommand().equals(action.getName())) { |
240 |
buffer.append(" <td title=\"Command don't have recomended syntax and differ fron action name\">")
|
241 |
.append(warning_open) |
242 |
.append(action.getCommand()) |
243 |
.append(warning_close) |
244 |
.append("</td>\n");
|
245 |
|
246 |
} else if(!action.getCommand().contains("-") ) { |
247 |
buffer.append(" <td title=\"Command don't have recomended syntax\">")
|
248 |
.append(warning_open) |
249 |
.append(action.getCommand()) |
250 |
.append(warning_close) |
251 |
.append("</td>\n");
|
252 |
|
253 |
} else if(!action.getCommand().equals(action.getName())) { |
254 |
buffer.append(" <td title=\"Command differ fron action name\">")
|
255 |
.append(warning_open) |
256 |
.append(action.getCommand()) |
257 |
.append(warning_close) |
258 |
.append("</td>\n");
|
259 |
|
260 |
} else {
|
261 |
buffer.append(" <td>")
|
262 |
.append(action.getCommand()) |
263 |
.append("</td>\n");
|
264 |
} |
265 |
if( action.getIconName()==null ) { |
266 |
buffer.append(" <td title=\"Missing icon name\">")
|
267 |
.append(error_open) |
268 |
.append("(missing)")
|
269 |
.append(error_close) |
270 |
.append("</td>\n");
|
271 |
} else if( action.getIcon()==null ) { |
272 |
buffer.append(" <td title=\"Missing icon\">")
|
273 |
.append(error_open) |
274 |
.append(action.getIconName()) |
275 |
.append(error_close) |
276 |
.append("</td>\n");
|
277 |
} else {
|
278 |
buffer.append(" <td>")
|
279 |
.append(action.getIconName()) |
280 |
.append("</td>\n");
|
281 |
} |
282 |
if( action.getTooltip()==null ) { |
283 |
buffer.append(" <td title=\"Missing tooltip\">")
|
284 |
.append(error_open) |
285 |
.append(action.getTooltip()) |
286 |
.append(error_close) |
287 |
.append("</td>\n");
|
288 |
|
289 |
} else {
|
290 |
buffer.append(" <td>")
|
291 |
.append(action.getTooltip()) |
292 |
.append("</td>\n");
|
293 |
} |
294 |
if( action.getAccelerator()!=null && action.getKeyStroke()==null ) { |
295 |
buffer.append(" <td title=\"Incorrect syntax of the accelerator key\">")
|
296 |
.append(error_open) |
297 |
.append(action.getAccelerator()) |
298 |
.append(error_close) |
299 |
.append("</td>\n");
|
300 |
|
301 |
} else {
|
302 |
buffer.append(" <td>")
|
303 |
.append(action.getAccelerator()) |
304 |
.append("</td>\n");
|
305 |
} |
306 |
buffer.append(" </tr>\n");
|
307 |
|
308 |
} |
309 |
buffer.append("</table>\n");
|
310 |
buffer.append("</div>\n");
|
311 |
|
312 |
return buffer.toString();
|
313 |
} |
314 |
|
315 |
|
316 |
} |