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 @ 47423
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.showInBrowser("report-byplugin", "Report "+pluginName, html); |
137 |
} |
138 |
|
139 |
|
140 |
|
141 |
public String getActionsInformation(String pluginName) { |
142 |
|
143 |
String previousPluginName = null; |
144 |
|
145 |
String warning_open = "<b>"; |
146 |
String warning_close = "</b>"; |
147 |
|
148 |
String error_open = "<b><font color=\"red\">"; |
149 |
String error_close = "</font></b>"; |
150 |
|
151 |
StringBuffer buffer = new StringBuffer(); |
152 |
|
153 |
buffer.append("<html>\n");
|
154 |
buffer.append("<body>\n");
|
155 |
|
156 |
buffer.append("<div>\n");
|
157 |
buffer.append("<h2>Actions information </h2>\n");
|
158 |
buffer.append("<br>\n");
|
159 |
|
160 |
buffer.append("<table border=\"0\">\n");
|
161 |
buffer.append(" <tr>\n");
|
162 |
buffer.append(" <td>Plugin</td>\n");
|
163 |
buffer.append(" <td>Extension</td>\n");
|
164 |
buffer.append(" <td>Name</td>\n");
|
165 |
buffer.append(" <td>Position</td>\n");
|
166 |
buffer.append(" <td>Text</td>\n");
|
167 |
buffer.append(" <td>Command</td>\n");
|
168 |
buffer.append(" <td>Icon</td>\n");
|
169 |
buffer.append(" <td>Tip</td>\n");
|
170 |
buffer.append(" <td>Accelerator</td>\n");
|
171 |
buffer.append(" </tr>\n");
|
172 |
Iterator<ActionInfo> actions = PluginsLocator.getActionInfoManager().getActions();
|
173 |
while (actions.hasNext()) {
|
174 |
ActionInfo action = actions.next(); |
175 |
if( pluginName!=null && !pluginName.equalsIgnoreCase(action.getPluginName()) ) { |
176 |
continue;
|
177 |
} |
178 |
if( previousPluginName!=null && !action.getPluginName().equals(previousPluginName) ) { |
179 |
buffer |
180 |
.append(" <tr>\n")
|
181 |
.append(" <td colspan=\"9\"><hr></td>\n")
|
182 |
.append(" </tr>\n");
|
183 |
previousPluginName = action.getPluginName(); |
184 |
} |
185 |
buffer.append(" <tr valign=\"top\">\n");
|
186 |
buffer.append(" <td>")
|
187 |
.append(action.getPluginName()) |
188 |
.append("</td>\n");
|
189 |
buffer.append(" <td>")
|
190 |
.append(action.getExtensionName()) |
191 |
.append("</td>\n");
|
192 |
if( action.getName().startsWith("anonymous__") ) { |
193 |
buffer.append(" <td title=\"Missing action name, asigned one by default\">")
|
194 |
.append(error_open) |
195 |
.append(action.getName()) |
196 |
.append(error_close) |
197 |
.append("</td>\n");
|
198 |
} else if( !action.getName().contains("-") ) { |
199 |
buffer.append(" <td title=\"Name don't have recomended syntax\">")
|
200 |
.append(warning_open) |
201 |
.append(action.getName()) |
202 |
.append(warning_close) |
203 |
.append("</td>\n");
|
204 |
} else {
|
205 |
buffer.append(" <td>")
|
206 |
.append(action.getName()) |
207 |
.append("</td>\n");
|
208 |
} |
209 |
if( action.getPosition()<100000000 ) { |
210 |
buffer.append(" <td title=\"Incorrect position\">")
|
211 |
.append(error_open) |
212 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
213 |
.append(error_close) |
214 |
.append("</td>\n");
|
215 |
} else {
|
216 |
buffer.append(" <td>")
|
217 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
218 |
.append("</td>\n");
|
219 |
} |
220 |
if( action.getLabel()==null ) { |
221 |
buffer.append(" <td title=\"Missing label of action\">")
|
222 |
.append(error_open) |
223 |
.append("(missing)")
|
224 |
.append(error_close) |
225 |
.append("</td>\n");
|
226 |
} else {
|
227 |
buffer.append(" <td>")
|
228 |
.append(action.getLabel()) |
229 |
.append("</td>\n");
|
230 |
} |
231 |
if( action.getCommand()==null ) { |
232 |
buffer.append(" <td title=\"Missing command of action\">")
|
233 |
.append(error_open) |
234 |
.append(action.getCommand()) |
235 |
.append(error_close) |
236 |
.append("</td>\n");
|
237 |
|
238 |
} else if(!action.getCommand().contains("-") && !action.getCommand().equals(action.getName())) { |
239 |
buffer.append(" <td title=\"Command don't have recomended syntax and differ fron action name\">")
|
240 |
.append(warning_open) |
241 |
.append(action.getCommand()) |
242 |
.append(warning_close) |
243 |
.append("</td>\n");
|
244 |
|
245 |
} else if(!action.getCommand().contains("-") ) { |
246 |
buffer.append(" <td title=\"Command don't have recomended syntax\">")
|
247 |
.append(warning_open) |
248 |
.append(action.getCommand()) |
249 |
.append(warning_close) |
250 |
.append("</td>\n");
|
251 |
|
252 |
} else if(!action.getCommand().equals(action.getName())) { |
253 |
buffer.append(" <td title=\"Command differ fron action name\">")
|
254 |
.append(warning_open) |
255 |
.append(action.getCommand()) |
256 |
.append(warning_close) |
257 |
.append("</td>\n");
|
258 |
|
259 |
} else {
|
260 |
buffer.append(" <td>")
|
261 |
.append(action.getCommand()) |
262 |
.append("</td>\n");
|
263 |
} |
264 |
if( action.getIconName()==null ) { |
265 |
buffer.append(" <td title=\"Missing icon name\">")
|
266 |
.append(error_open) |
267 |
.append("(missing)")
|
268 |
.append(error_close) |
269 |
.append("</td>\n");
|
270 |
} else if( action.getIcon()==null ) { |
271 |
buffer.append(" <td title=\"Missing icon\">")
|
272 |
.append(error_open) |
273 |
.append(action.getIconName()) |
274 |
.append(error_close) |
275 |
.append("</td>\n");
|
276 |
} else {
|
277 |
buffer.append(" <td>")
|
278 |
.append(action.getIconName()) |
279 |
.append("</td>\n");
|
280 |
} |
281 |
if( action.getTooltip()==null ) { |
282 |
buffer.append(" <td title=\"Missing tooltip\">")
|
283 |
.append(error_open) |
284 |
.append(action.getTooltip()) |
285 |
.append(error_close) |
286 |
.append("</td>\n");
|
287 |
|
288 |
} else {
|
289 |
buffer.append(" <td>")
|
290 |
.append(action.getTooltip()) |
291 |
.append("</td>\n");
|
292 |
} |
293 |
if( action.getAccelerator()!=null && action.getKeyStroke()==null ) { |
294 |
buffer.append(" <td title=\"Incorrect syntax of the accelerator key\">")
|
295 |
.append(error_open) |
296 |
.append(action.getAccelerator()) |
297 |
.append(error_close) |
298 |
.append("</td>\n");
|
299 |
|
300 |
} else {
|
301 |
buffer.append(" <td>")
|
302 |
.append(action.getAccelerator()) |
303 |
.append("</td>\n");
|
304 |
} |
305 |
buffer.append(" </tr>\n");
|
306 |
|
307 |
} |
308 |
buffer.append("</table>\n");
|
309 |
buffer.append("</div>\n");
|
310 |
|
311 |
return buffer.toString();
|
312 |
} |
313 |
|
314 |
|
315 |
} |