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