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 @ 43099
History | View | Annotate | Download (10.7 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>Plugin</td>\n");
|
73 |
buffer.append(" </tr>\n");
|
74 |
for (SelectableToolBar toolBar : toolbars) {
|
75 |
buffer.append(" <tr valign=\"top\">\n");
|
76 |
buffer.append(" <td>")
|
77 |
.append(toolBar.getPosition()) |
78 |
.append("</td>\n");
|
79 |
buffer.append(" <td colspan=\"2\"><b>")
|
80 |
.append(toolBar.getName()) |
81 |
.append("</b> - ")
|
82 |
.append(toolBar.getDescription()) |
83 |
.append("</td>\n");
|
84 |
buffer.append(" </tr>\n");
|
85 |
Component item;;
|
86 |
for( int i=0; (item=toolBar.getComponentAtIndex(i))!=null; i++) { |
87 |
String name = item.getName();
|
88 |
ActionInfo action = null;
|
89 |
if( name!=null ) { |
90 |
action = actionsManager.getAction(name); |
91 |
} |
92 |
buffer.append(" <tr valign=\"top\">\n");
|
93 |
buffer.append(" <td></td>\n");
|
94 |
buffer.append(" <td>");
|
95 |
buffer.append(name); |
96 |
buffer.append(" </td>\n");
|
97 |
buffer.append(" <td>");
|
98 |
if( action!=null ) { |
99 |
buffer.append(action.getPluginName()); |
100 |
} |
101 |
buffer.append("</td>\n");
|
102 |
buffer.append(" </tr>\n");
|
103 |
} |
104 |
} |
105 |
buffer.append("</table>\n");
|
106 |
buffer.append("</div>\n");
|
107 |
buffer.append("</body>\n");
|
108 |
buffer.append("</html>\n");
|
109 |
|
110 |
String html = buffer.toString();
|
111 |
InfoPanel.save2file("toolbars-report", html);
|
112 |
InfoPanel.showPanel("Toolbars report", WindowManager.MODE.WINDOW, html);
|
113 |
} |
114 |
|
115 |
public void showReportOfPlugin() { |
116 |
ApplicationManager application = ApplicationLocator.getManager(); |
117 |
String pluginName = null; |
118 |
|
119 |
pluginName = application.inputDialog("Introduzca el nombre del plugin del que desea el informe", "Plugin actions report"); |
120 |
if( pluginName == null ) { |
121 |
return;
|
122 |
} |
123 |
String actionsHtml = this.getActionsInformation(pluginName); |
124 |
String menusHtml = new MenusDevelTool().getMenusOfPlugin(pluginName); |
125 |
String iconsHtml = new IconThemeDevelTool().getIconThemeInformationOfPlugin(pluginName); |
126 |
|
127 |
String html = "<html>\n<body>\n"+actionsHtml+"<br>"+menusHtml+"<br>"+iconsHtml+"</body>\n</html>\n"; |
128 |
|
129 |
InfoPanel.save2file("plugin-report", html);
|
130 |
InfoPanel.showPanel("Plugin report", WindowManager.MODE.WINDOW, html);
|
131 |
} |
132 |
|
133 |
|
134 |
|
135 |
public String getActionsInformation(String pluginName) { |
136 |
|
137 |
String previousPluginName = null; |
138 |
|
139 |
String warning_open = "<b>"; |
140 |
String warning_close = "</b>"; |
141 |
|
142 |
String error_open = "<b><font color=\"red\">"; |
143 |
String error_close = "</font></b>"; |
144 |
|
145 |
StringBuffer buffer = new StringBuffer(); |
146 |
|
147 |
buffer.append("<html>\n");
|
148 |
buffer.append("<body>\n");
|
149 |
|
150 |
buffer.append("<div>\n");
|
151 |
buffer.append("<h2>Actions information </h2>\n");
|
152 |
buffer.append("<br>\n");
|
153 |
|
154 |
buffer.append("<table border=\"0\">\n");
|
155 |
buffer.append(" <tr>\n");
|
156 |
buffer.append(" <td>Plugin</td>\n");
|
157 |
buffer.append(" <td>Extension</td>\n");
|
158 |
buffer.append(" <td>Name</td>\n");
|
159 |
buffer.append(" <td>Position</td>\n");
|
160 |
buffer.append(" <td>Text</td>\n");
|
161 |
buffer.append(" <td>Command</td>\n");
|
162 |
buffer.append(" <td>Icon</td>\n");
|
163 |
buffer.append(" <td>Tip</td>\n");
|
164 |
buffer.append(" <td>Accelerator</td>\n");
|
165 |
buffer.append(" </tr>\n");
|
166 |
Iterator<ActionInfo> actions = PluginsLocator.getActionInfoManager().getActions();
|
167 |
while (actions.hasNext()) {
|
168 |
ActionInfo action = actions.next(); |
169 |
if( pluginName!=null && !pluginName.equalsIgnoreCase(action.getPluginName()) ) { |
170 |
continue;
|
171 |
} |
172 |
if( previousPluginName!=null && !action.getPluginName().equals(previousPluginName) ) { |
173 |
buffer |
174 |
.append(" <tr>\n")
|
175 |
.append(" <td colspan=\"9\"><hr></td>\n")
|
176 |
.append(" </tr>\n");
|
177 |
previousPluginName = action.getPluginName(); |
178 |
} |
179 |
buffer.append(" <tr valign=\"top\">\n");
|
180 |
buffer.append(" <td>")
|
181 |
.append(action.getPluginName()) |
182 |
.append("</td>\n");
|
183 |
buffer.append(" <td>")
|
184 |
.append(action.getExtensionName()) |
185 |
.append("</td>\n");
|
186 |
if( action.getName().startsWith("anonymous__") ) { |
187 |
buffer.append(" <td title=\"Missing action name, asigned one by default\">")
|
188 |
.append(error_open) |
189 |
.append(action.getName()) |
190 |
.append(error_close) |
191 |
.append("</td>\n");
|
192 |
} else if( !action.getName().contains("-") ) { |
193 |
buffer.append(" <td title=\"Name don't have recomended syntax\">")
|
194 |
.append(warning_open) |
195 |
.append(action.getName()) |
196 |
.append(warning_close) |
197 |
.append("</td>\n");
|
198 |
} else {
|
199 |
buffer.append(" <td>")
|
200 |
.append(action.getName()) |
201 |
.append("</td>\n");
|
202 |
} |
203 |
if( action.getPosition()<100000000 ) { |
204 |
buffer.append(" <td title=\"Incorrect position\">")
|
205 |
.append(error_open) |
206 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
207 |
.append(error_close) |
208 |
.append("</td>\n");
|
209 |
} else {
|
210 |
buffer.append(" <td>")
|
211 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
212 |
.append("</td>\n");
|
213 |
} |
214 |
if( action.getLabel()==null ) { |
215 |
buffer.append(" <td title=\"Missing label of action\">")
|
216 |
.append(error_open) |
217 |
.append("(missing)")
|
218 |
.append(error_close) |
219 |
.append("</td>\n");
|
220 |
} else {
|
221 |
buffer.append(" <td>")
|
222 |
.append(action.getLabel()) |
223 |
.append("</td>\n");
|
224 |
} |
225 |
if( action.getCommand()==null ) { |
226 |
buffer.append(" <td title=\"Missing command of action\">")
|
227 |
.append(error_open) |
228 |
.append(action.getCommand()) |
229 |
.append(error_close) |
230 |
.append("</td>\n");
|
231 |
|
232 |
} else if(!action.getCommand().contains("-") && !action.getCommand().equals(action.getName())) { |
233 |
buffer.append(" <td title=\"Command don't have recomended syntax and differ fron action name\">")
|
234 |
.append(warning_open) |
235 |
.append(action.getCommand()) |
236 |
.append(warning_close) |
237 |
.append("</td>\n");
|
238 |
|
239 |
} else if(!action.getCommand().contains("-") ) { |
240 |
buffer.append(" <td title=\"Command don't have recomended syntax\">")
|
241 |
.append(warning_open) |
242 |
.append(action.getCommand()) |
243 |
.append(warning_close) |
244 |
.append("</td>\n");
|
245 |
|
246 |
} else if(!action.getCommand().equals(action.getName())) { |
247 |
buffer.append(" <td title=\"Command differ fron action name\">")
|
248 |
.append(warning_open) |
249 |
.append(action.getCommand()) |
250 |
.append(warning_close) |
251 |
.append("</td>\n");
|
252 |
|
253 |
} else {
|
254 |
buffer.append(" <td>")
|
255 |
.append(action.getCommand()) |
256 |
.append("</td>\n");
|
257 |
} |
258 |
if( action.getIconName()==null ) { |
259 |
buffer.append(" <td title=\"Missing icon name\">")
|
260 |
.append(error_open) |
261 |
.append("(missing)")
|
262 |
.append(error_close) |
263 |
.append("</td>\n");
|
264 |
} else if( action.getIcon()==null ) { |
265 |
buffer.append(" <td title=\"Missing icon\">")
|
266 |
.append(error_open) |
267 |
.append(action.getIconName()) |
268 |
.append(error_close) |
269 |
.append("</td>\n");
|
270 |
} else {
|
271 |
buffer.append(" <td>")
|
272 |
.append(action.getIconName()) |
273 |
.append("</td>\n");
|
274 |
} |
275 |
if( action.getTooltip()==null ) { |
276 |
buffer.append(" <td title=\"Missing tooltip\">")
|
277 |
.append(error_open) |
278 |
.append(action.getTooltip()) |
279 |
.append(error_close) |
280 |
.append("</td>\n");
|
281 |
|
282 |
} else {
|
283 |
buffer.append(" <td>")
|
284 |
.append(action.getTooltip()) |
285 |
.append("</td>\n");
|
286 |
} |
287 |
if( action.getAccelerator()!=null && action.getKeyStroke()==null ) { |
288 |
buffer.append(" <td title=\"Incorrect syntax of the accelerator key\">")
|
289 |
.append(error_open) |
290 |
.append(action.getAccelerator()) |
291 |
.append(error_close) |
292 |
.append("</td>\n");
|
293 |
|
294 |
} else {
|
295 |
buffer.append(" <td>")
|
296 |
.append(action.getAccelerator()) |
297 |
.append("</td>\n");
|
298 |
} |
299 |
buffer.append(" </tr>\n");
|
300 |
|
301 |
} |
302 |
buffer.append("</table>\n");
|
303 |
buffer.append("</div>\n");
|
304 |
|
305 |
return buffer.toString();
|
306 |
} |
307 |
|
308 |
|
309 |
} |