svn-gvsig-desktop / tags / v2_0_0_Build_2060 / applications / appgvSIG / src / org / gvsig / app / extension / develtools / ActionsInfoDevelTool.java @ 39341
History | View | Annotate | Download (6.65 KB)
1 |
package org.gvsig.app.extension.develtools; |
---|---|
2 |
|
3 |
import java.util.Iterator; |
4 |
|
5 |
import org.gvsig.andami.PluginsLocator; |
6 |
import org.gvsig.andami.actioninfo.ActionInfo; |
7 |
import org.gvsig.app.ApplicationLocator; |
8 |
import org.gvsig.app.ApplicationManager; |
9 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
10 |
|
11 |
public class ActionsInfoDevelTool { |
12 |
|
13 |
public void showActions() { |
14 |
String html = "<html>\n<body>\n"+ this.getActionsInformation(null)+"</body>\n</html>\n"; |
15 |
|
16 |
InfoPanel.save2file("actions-report", html);
|
17 |
InfoPanel.showPanel("Actions information", WindowManager.MODE.WINDOW, html);
|
18 |
} |
19 |
|
20 |
public void showReportOfPlugin() { |
21 |
ApplicationManager application = ApplicationLocator.getManager(); |
22 |
String pluginName = null; |
23 |
|
24 |
pluginName = application.inputDialog("Introduzca el nombre del plugin del que desea el informe", "Plugin actions report"); |
25 |
if( pluginName == null ) { |
26 |
return;
|
27 |
} |
28 |
String actionsHtml = this.getActionsInformation(pluginName); |
29 |
String menusHtml = new MenusDevelTool().getMenusOfPlugin(pluginName); |
30 |
String iconsHtml = new IconThemeDevelTool().getIconThemeInformationOfPlugin(pluginName); |
31 |
|
32 |
String html = "<html>\n<body>\n"+actionsHtml+"<br>"+menusHtml+"<br>"+iconsHtml+"</body>\n</html>\n"; |
33 |
|
34 |
InfoPanel.save2file("plugin-report", html);
|
35 |
InfoPanel.showPanel("Plugin report", WindowManager.MODE.WINDOW, html);
|
36 |
} |
37 |
|
38 |
|
39 |
|
40 |
public String getActionsInformation(String pluginName) { |
41 |
|
42 |
String previousPluginName = null; |
43 |
|
44 |
String warning_open = "<b>"; |
45 |
String warning_close = "</b>"; |
46 |
|
47 |
String error_open = "<b><font color=\"red\">"; |
48 |
String error_close = "</font></b>"; |
49 |
|
50 |
StringBuffer buffer = new StringBuffer(); |
51 |
|
52 |
buffer.append("<html>\n");
|
53 |
buffer.append("<body>\n");
|
54 |
|
55 |
buffer.append("<div>\n");
|
56 |
buffer.append("<h2>Actions information </h2>\n");
|
57 |
buffer.append("<br>\n");
|
58 |
|
59 |
buffer.append("<table border=\"0\">\n");
|
60 |
buffer.append(" <tr>\n");
|
61 |
buffer.append(" <td>Plugin</td>\n");
|
62 |
buffer.append(" <td>Extension</td>\n");
|
63 |
buffer.append(" <td>Name</td>\n");
|
64 |
buffer.append(" <td>Position</td>\n");
|
65 |
buffer.append(" <td>Text</td>\n");
|
66 |
buffer.append(" <td>Command</td>\n");
|
67 |
buffer.append(" <td>Icon</td>\n");
|
68 |
buffer.append(" <td>Tip</td>\n");
|
69 |
buffer.append(" <td>Accelerator</td>\n");
|
70 |
buffer.append(" </tr>\n");
|
71 |
Iterator<ActionInfo> actions = PluginsLocator.getActionInfoManager().getActions();
|
72 |
while (actions.hasNext()) {
|
73 |
ActionInfo action = actions.next(); |
74 |
if( pluginName!=null && !pluginName.equalsIgnoreCase(action.getPluginName()) ) { |
75 |
continue;
|
76 |
} |
77 |
if( previousPluginName!=null && !action.getPluginName().equals(previousPluginName) ) { |
78 |
buffer |
79 |
.append(" <tr>\n")
|
80 |
.append(" <td colspan=\"9\"><hr></td>\n")
|
81 |
.append(" </tr>\n");
|
82 |
previousPluginName = action.getPluginName(); |
83 |
} |
84 |
buffer.append(" <tr valign=\"top\">\n");
|
85 |
buffer.append(" <td>")
|
86 |
.append(action.getPluginName()) |
87 |
.append("</td>\n");
|
88 |
buffer.append(" <td>")
|
89 |
.append(action.getExtensionName()) |
90 |
.append("</td>\n");
|
91 |
if( action.getName().startsWith("anonymous__") ) { |
92 |
buffer.append(" <td title=\"Missing action name, asigned one by default\">")
|
93 |
.append(error_open) |
94 |
.append(action.getName()) |
95 |
.append(error_close) |
96 |
.append("</td>\n");
|
97 |
} else if( !action.getName().contains("-") ) { |
98 |
buffer.append(" <td title=\"Name don't have recomended syntax\">")
|
99 |
.append(warning_open) |
100 |
.append(action.getName()) |
101 |
.append(warning_close) |
102 |
.append("</td>\n");
|
103 |
} else {
|
104 |
buffer.append(" <td>")
|
105 |
.append(action.getName()) |
106 |
.append("</td>\n");
|
107 |
} |
108 |
if( action.getPosition()<100000000 ) { |
109 |
buffer.append(" <td title=\"Incorrect position\">")
|
110 |
.append(error_open) |
111 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
112 |
.append(error_close) |
113 |
.append("</td>\n");
|
114 |
} else {
|
115 |
buffer.append(" <td>")
|
116 |
.append(MenusDevelTool.formatPosition(action.getPosition())) |
117 |
.append("</td>\n");
|
118 |
} |
119 |
if( action.getLabel()==null ) { |
120 |
buffer.append(" <td title=\"Missing label of action\">")
|
121 |
.append(error_open) |
122 |
.append("(missing)")
|
123 |
.append(error_close) |
124 |
.append("</td>\n");
|
125 |
} else {
|
126 |
buffer.append(" <td>")
|
127 |
.append(action.getLabel()) |
128 |
.append("</td>\n");
|
129 |
} |
130 |
if( action.getCommand()==null ) { |
131 |
buffer.append(" <td title=\"Missing command of action\">")
|
132 |
.append(error_open) |
133 |
.append(action.getCommand()) |
134 |
.append(error_close) |
135 |
.append("</td>\n");
|
136 |
|
137 |
} else if(!action.getCommand().contains("-") && !action.getCommand().equals(action.getName())) { |
138 |
buffer.append(" <td title=\"Command don't have recomended syntax and differ fron action name\">")
|
139 |
.append(warning_open) |
140 |
.append(action.getCommand()) |
141 |
.append(warning_close) |
142 |
.append("</td>\n");
|
143 |
|
144 |
} else if(!action.getCommand().contains("-") ) { |
145 |
buffer.append(" <td title=\"Command don't have recomended syntax\">")
|
146 |
.append(warning_open) |
147 |
.append(action.getCommand()) |
148 |
.append(warning_close) |
149 |
.append("</td>\n");
|
150 |
|
151 |
} else if(!action.getCommand().equals(action.getName())) { |
152 |
buffer.append(" <td title=\"Command differ fron action name\">")
|
153 |
.append(warning_open) |
154 |
.append(action.getCommand()) |
155 |
.append(warning_close) |
156 |
.append("</td>\n");
|
157 |
|
158 |
} else {
|
159 |
buffer.append(" <td>")
|
160 |
.append(action.getCommand()) |
161 |
.append("</td>\n");
|
162 |
} |
163 |
if( action.getIconName()==null ) { |
164 |
buffer.append(" <td title=\"Missing icon name\">")
|
165 |
.append(error_open) |
166 |
.append("(missing)")
|
167 |
.append(error_close) |
168 |
.append("</td>\n");
|
169 |
} else if( action.getIcon()==null ) { |
170 |
buffer.append(" <td title=\"Missing icon\">")
|
171 |
.append(error_open) |
172 |
.append(action.getIconName()) |
173 |
.append(error_close) |
174 |
.append("</td>\n");
|
175 |
} else {
|
176 |
buffer.append(" <td>")
|
177 |
.append(action.getIconName()) |
178 |
.append("</td>\n");
|
179 |
} |
180 |
if( action.getTooltip()==null ) { |
181 |
buffer.append(" <td title=\"Missing tooltip\">")
|
182 |
.append(error_open) |
183 |
.append(action.getTooltip()) |
184 |
.append(error_close) |
185 |
.append("</td>\n");
|
186 |
|
187 |
} else {
|
188 |
buffer.append(" <td>")
|
189 |
.append(action.getTooltip()) |
190 |
.append("</td>\n");
|
191 |
} |
192 |
if( action.getAccelerator()!=null && action.getKeyStroke()==null ) { |
193 |
buffer.append(" <td title=\"Incorrect syntax of the accelerator key\">")
|
194 |
.append(error_open) |
195 |
.append(action.getAccelerator()) |
196 |
.append(error_close) |
197 |
.append("</td>\n");
|
198 |
|
199 |
} else {
|
200 |
buffer.append(" <td>")
|
201 |
.append(action.getAccelerator()) |
202 |
.append("</td>\n");
|
203 |
} |
204 |
buffer.append(" </tr>\n");
|
205 |
|
206 |
} |
207 |
buffer.append("</table>\n");
|
208 |
buffer.append("</div>\n");
|
209 |
|
210 |
return buffer.toString();
|
211 |
} |
212 |
|
213 |
|
214 |
} |