svn-gvsig-desktop / tags / v2_0_0_Build_2060 / applications / appgvSIG / src / org / gvsig / app / extension / develtools / IconThemeDevelTool.java @ 39341
History | View | Annotate | Download (15.2 KB)
1 |
package org.gvsig.app.extension.develtools; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.Collections; |
5 |
import java.util.Comparator; |
6 |
import java.util.HashSet; |
7 |
import java.util.Iterator; |
8 |
import java.util.List; |
9 |
import java.util.Set; |
10 |
|
11 |
import javax.swing.ImageIcon; |
12 |
|
13 |
import org.gvsig.andami.PluginsLocator; |
14 |
import org.gvsig.andami.actioninfo.ActionInfo; |
15 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
16 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
17 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
18 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
19 |
|
20 |
public class IconThemeDevelTool { |
21 |
|
22 |
public void showDefaultIconTheme() { |
23 |
String html = "<html>\n<body>\n"+ this.getIconThemeInformationByGroup()+"</body>\n</html>\n"; |
24 |
InfoPanel.save2file("icontheme-report", html);
|
25 |
InfoPanel.showPanel("Icon theme information", WindowManager.MODE.WINDOW, html);
|
26 |
} |
27 |
|
28 |
public void showDefaultIconThemeByPlugin() { |
29 |
String html = "<html>\n<body>\n"+ this.getIconThemeInformationByPlugin()+"</body>\n</html>\n"; |
30 |
InfoPanel.save2file("icontheme-report", html);
|
31 |
InfoPanel.showPanel("Icon theme information", WindowManager.MODE.WINDOW, html);
|
32 |
} |
33 |
|
34 |
private String getIconThemeInformationByPlugin() { |
35 |
IconThemeManager manager = ToolsSwingLocator.getIconThemeManager(); |
36 |
IconTheme theme = manager.getDefault(); |
37 |
|
38 |
List<IconTheme.Icon>themeIcons = new ArrayList<IconTheme.Icon>(); |
39 |
Iterator<IconTheme.Icon> themeIconsIt = theme.getThemeIcons();
|
40 |
while (themeIconsIt.hasNext()) {
|
41 |
themeIcons.add(themeIconsIt.next()); |
42 |
} |
43 |
Collections.sort(themeIcons, new Comparator<IconTheme.Icon>() { |
44 |
public int compare(IconTheme.Icon o1, IconTheme.Icon o2) { |
45 |
String s1 = String.format("%s:%s:%s", o1.getProviderName(), o1.getGroup(), o1.getName()); |
46 |
String s2 = String.format("%s:%s:%s", o2.getProviderName(), o2.getGroup(), o2.getName()); |
47 |
return s1.compareTo(s2);
|
48 |
} |
49 |
}); |
50 |
themeIconsIt = themeIcons.iterator(); |
51 |
return getIconThemeInformation(theme, themeIconsIt);
|
52 |
} |
53 |
|
54 |
public String getIconThemeInformationOfPlugin(String pluginName) { |
55 |
if( pluginName == null ) { |
56 |
return ""; |
57 |
} |
58 |
IconThemeManager manager = ToolsSwingLocator.getIconThemeManager(); |
59 |
IconTheme theme = manager.getDefault(); |
60 |
|
61 |
List<IconTheme.Icon>themeIcons = new ArrayList<IconTheme.Icon>(); |
62 |
Iterator<IconTheme.Icon> themeIconsIt = theme.getThemeIcons();
|
63 |
while (themeIconsIt.hasNext()) {
|
64 |
IconTheme.Icon iconTheme = (IconTheme.Icon) themeIconsIt.next(); |
65 |
if( !pluginName.equalsIgnoreCase(iconTheme.getProviderName()) ) {
|
66 |
continue;
|
67 |
} |
68 |
themeIcons.add(iconTheme); |
69 |
} |
70 |
Collections.sort(themeIcons, new Comparator<IconTheme.Icon>() { |
71 |
public int compare(IconTheme.Icon o1, IconTheme.Icon o2) { |
72 |
String s1 = String.format("%s:%s:%s", o1.getProviderName(), o1.getGroup(), o1.getName()); |
73 |
String s2 = String.format("%s:%s:%s", o2.getProviderName(), o2.getGroup(), o2.getName()); |
74 |
return s1.compareTo(s2);
|
75 |
} |
76 |
}); |
77 |
themeIconsIt = themeIcons.iterator(); |
78 |
return getIconThemeInformation(theme, themeIconsIt);
|
79 |
} |
80 |
|
81 |
private String getIconThemeInformationByGroup() { |
82 |
IconThemeManager manager = ToolsSwingLocator.getIconThemeManager(); |
83 |
IconTheme theme = manager.getDefault(); |
84 |
|
85 |
List<IconTheme.Icon>themeIcons = new ArrayList<IconTheme.Icon>(); |
86 |
Iterator<IconTheme.Icon> themeIconsIt = theme.getThemeIcons();
|
87 |
while (themeIconsIt.hasNext()) {
|
88 |
themeIcons.add(themeIconsIt.next()); |
89 |
} |
90 |
Collections.sort(themeIcons, new Comparator<IconTheme.Icon>() { |
91 |
public int compare(IconTheme.Icon o1, IconTheme.Icon o2) { |
92 |
String s1 = String.format("%s:%s:%s", o1.getGroup(), o1.getName(), o1.getProviderName()); |
93 |
String s2 = String.format("%s:%s:%s", o2.getGroup(), o2.getName(), o2.getProviderName()); |
94 |
return s1.compareTo(s2);
|
95 |
} |
96 |
}); |
97 |
themeIconsIt = themeIcons.iterator(); |
98 |
return getIconThemeInformation(theme,themeIconsIt);
|
99 |
} |
100 |
|
101 |
private String getIconThemeInformation(IconTheme theme, Iterator<IconTheme.Icon> themeIconsIt) { |
102 |
Set<String> actionIcons = new HashSet<String>(); |
103 |
Iterator<ActionInfo> actions = PluginsLocator.getActionInfoManager().getActions();
|
104 |
while (actions.hasNext()) {
|
105 |
ActionInfo action = actions.next(); |
106 |
if( action.getIconName()!=null ) { |
107 |
actionIcons.add(action.getIconName()); |
108 |
} |
109 |
} |
110 |
Set<String> tangoIconNames = getTangoIconNames(); |
111 |
|
112 |
StringBuffer buffer = new StringBuffer(); |
113 |
|
114 |
String warning_open = "<b>"; |
115 |
String warning_close = "</b>"; |
116 |
|
117 |
String error_open = "<b><font color=\"red\">"; |
118 |
String error_close = "</font></b>"; |
119 |
|
120 |
String tangoicon_open = "<b><font color=\"green\">"; |
121 |
String tangoicon_close = "</font></b>"; |
122 |
|
123 |
String previousPluginName = null; |
124 |
|
125 |
buffer.append("<div>\n");
|
126 |
buffer.append("<h2>Icon theme information</h2>\n");
|
127 |
buffer.append("<br>\n");
|
128 |
buffer.append("Theme: ");
|
129 |
buffer.append(theme.getName()); |
130 |
buffer.append("<br>\n");
|
131 |
buffer.append("Description: ");
|
132 |
buffer.append(theme.getDescription()); |
133 |
buffer.append("<br>\n");
|
134 |
|
135 |
buffer.append("<table border=\"0\">\n");
|
136 |
buffer.append(" <tr>\n");
|
137 |
buffer.append(" <td>Preview</td>\n");
|
138 |
buffer.append(" <td>Group</td>\n");
|
139 |
buffer.append(" <td>Name</td>\n");
|
140 |
buffer.append(" <td>Provider/Plugin</td>\n");
|
141 |
buffer.append(" <td>Resource</td>\n");
|
142 |
buffer.append(" </tr>\n");
|
143 |
|
144 |
|
145 |
while (themeIconsIt.hasNext()) {
|
146 |
IconTheme.Icon themeIcon = themeIconsIt.next(); |
147 |
if( previousPluginName!=null && !themeIcon.getProviderName().equals(previousPluginName) ) { |
148 |
buffer |
149 |
.append(" <tr>\n")
|
150 |
.append(" <td colspan=\"4\"><hr></td>\n")
|
151 |
.append(" </tr>\n");
|
152 |
previousPluginName = themeIcon.getProviderName(); |
153 |
} |
154 |
|
155 |
buffer.append(" <tr valign=\"top\">\n");
|
156 |
|
157 |
// Preview
|
158 |
if( themeIcon.getLabel().length()>0 && themeIcon.getImageIcon()!=null ) { |
159 |
try {
|
160 |
ImageIcon img = themeIcon.getImageIcon();
|
161 |
if( img.getIconHeight() > 48 || img.getIconWidth() > 48 ) { |
162 |
buffer |
163 |
.append(" <td nowrap>")
|
164 |
.append("<img width=\"48\" height=\"48\" src=\"")
|
165 |
.append(themeIcon.getLabel()) |
166 |
.append("\">(*)</td>");
|
167 |
} else {
|
168 |
buffer |
169 |
.append(" <td>")
|
170 |
.append("<img src=\"")
|
171 |
.append(themeIcon.getLabel()) |
172 |
.append("\"></td>");
|
173 |
} |
174 |
} catch(Exception ex) { |
175 |
buffer |
176 |
.append(" <td>")
|
177 |
.append("<img src=\"")
|
178 |
.append(themeIcon.getLabel()) |
179 |
.append("\"></td>");
|
180 |
} |
181 |
} else {
|
182 |
buffer.append(" <td></td>");
|
183 |
} |
184 |
|
185 |
// Group
|
186 |
if( themeIcon.getGroup()==null ) { |
187 |
buffer.append(" <td title=\"missing recomended group\">")
|
188 |
.append(warning_open) |
189 |
.append(themeIcon.getGroup()) |
190 |
.append(warning_close) |
191 |
.append("</td>\n");
|
192 |
} else {
|
193 |
buffer.append(" <td>")
|
194 |
.append(themeIcon.getGroup()) |
195 |
.append("</td>\n");
|
196 |
} |
197 |
|
198 |
// Name
|
199 |
if( "action".equals(themeIcon.getGroup()) && !actionIcons.contains(themeIcon.getName())) { |
200 |
buffer.append(" <td title=\"Don't exists an action associated to this icon\">")
|
201 |
.append(error_open) |
202 |
.append(themeIcon.getName()) |
203 |
.append(error_close) |
204 |
.append("</td>\n");
|
205 |
} else if( !themeIcon.getName().contains("-") ) { |
206 |
buffer.append(" <td title=\"Name don't have recomended format\">")
|
207 |
.append(warning_open) |
208 |
.append(themeIcon.getName()) |
209 |
.append(warning_close) |
210 |
.append("</td>\n");
|
211 |
} else if( tangoIconNames.contains(themeIcon.getName()) ){ |
212 |
buffer.append(" <td>")
|
213 |
.append(tangoicon_open) |
214 |
.append(themeIcon.getName()) |
215 |
.append(tangoicon_close) |
216 |
.append("</td>\n");
|
217 |
} else {
|
218 |
buffer.append(" <td>")
|
219 |
.append(themeIcon.getName()) |
220 |
.append("</td>\n");
|
221 |
} |
222 |
|
223 |
// Plugin
|
224 |
if( themeIcon.getProviderName()== null ) { |
225 |
buffer.append(" <td title=\"missing recomended associated plugin\">")
|
226 |
.append(warning_open) |
227 |
.append(themeIcon.getProviderName()) |
228 |
.append(warning_close) |
229 |
.append("</td>\n");
|
230 |
|
231 |
} else {
|
232 |
buffer.append(" <td>")
|
233 |
.append(themeIcon.getProviderName()) |
234 |
.append("</td>\n");
|
235 |
} |
236 |
|
237 |
// Resource
|
238 |
if( themeIcon.getLabel().length()<1 ) { |
239 |
buffer.append(" <td title=\"Resource icon not specified\">")
|
240 |
.append(error_open) |
241 |
.append("(missing)")
|
242 |
.append(error_close) |
243 |
.append("</td>\n");
|
244 |
} else if( themeIcon.getImageIcon()==null ) { |
245 |
buffer.append(" <td title=\"Can't locate icon\">")
|
246 |
.append(error_open) |
247 |
.append(themeIcon.getLabel()) |
248 |
.append(error_close) |
249 |
.append("</td>\n");
|
250 |
} else {
|
251 |
buffer.append(" <td>")
|
252 |
.append(themeIcon.getLabel()) |
253 |
.append("</td>\n");
|
254 |
|
255 |
} |
256 |
buffer.append(" </tr>\n");
|
257 |
} |
258 |
buffer.append("</table>\n");
|
259 |
buffer.append("</div>\n");
|
260 |
|
261 |
return buffer.toString();
|
262 |
} |
263 |
|
264 |
private Set<String> getTangoIconNames() { |
265 |
String[] iconNames = new String[] { |
266 |
"address-book-new",
|
267 |
"application-exit",
|
268 |
"appointment-new",
|
269 |
"call-start",
|
270 |
"call-stop",
|
271 |
"contact-new",
|
272 |
"document-new",
|
273 |
"document-open",
|
274 |
"document-open-recent",
|
275 |
"document-page-setup",
|
276 |
"document-print",
|
277 |
"document-print-preview",
|
278 |
"document-properties",
|
279 |
"document-revert",
|
280 |
"document-save",
|
281 |
"document-save-as",
|
282 |
"document-send",
|
283 |
"edit-clear",
|
284 |
"edit-copy",
|
285 |
"edit-cut",
|
286 |
"edit-delete",
|
287 |
"edit-find",
|
288 |
"edit-find-replace",
|
289 |
"edit-paste",
|
290 |
"edit-redo",
|
291 |
"edit-select-all",
|
292 |
"edit-undo",
|
293 |
"folder-new",
|
294 |
"format-indent-less",
|
295 |
"format-indent-more",
|
296 |
"format-justify-center",
|
297 |
"format-justify-fill",
|
298 |
"format-justify-left",
|
299 |
"format-justify-right",
|
300 |
"format-text-direction-ltr",
|
301 |
"format-text-direction-rtl",
|
302 |
"format-text-bold",
|
303 |
"format-text-italic",
|
304 |
"format-text-underline",
|
305 |
"format-text-strikethrough",
|
306 |
"go-bottom",
|
307 |
"go-down",
|
308 |
"go-first",
|
309 |
"go-home",
|
310 |
"go-jump",
|
311 |
"go-last",
|
312 |
"go-next",
|
313 |
"go-previous",
|
314 |
"go-top",
|
315 |
"go-up",
|
316 |
"help-about",
|
317 |
"help-contents",
|
318 |
"help-faq",
|
319 |
"insert-image",
|
320 |
"insert-link",
|
321 |
"insert-object",
|
322 |
"insert-text",
|
323 |
"list-add",
|
324 |
"list-remove",
|
325 |
"mail-forward",
|
326 |
"mail-mark-important",
|
327 |
"mail-mark-junk",
|
328 |
"mail-mark-notjunk",
|
329 |
"mail-mark-read",
|
330 |
"mail-mark-unread",
|
331 |
"mail-message-new",
|
332 |
"mail-reply-all",
|
333 |
"mail-reply-sender",
|
334 |
"mail-send",
|
335 |
"mail-send-receive",
|
336 |
"media-eject",
|
337 |
"media-playback-pause",
|
338 |
"media-playback-start",
|
339 |
"media-playback-stop",
|
340 |
"media-record",
|
341 |
"media-seek-backward",
|
342 |
"media-seek-forward",
|
343 |
"media-skip-backward",
|
344 |
"media-skip-forward",
|
345 |
"object-flip-horizontal",
|
346 |
"object-flip-vertical",
|
347 |
"object-rotate-left",
|
348 |
"object-rotate-right",
|
349 |
"process-stop",
|
350 |
"system-lock-screen",
|
351 |
"system-log-out",
|
352 |
"system-run",
|
353 |
"system-search",
|
354 |
"system-reboot",
|
355 |
"system-shutdown",
|
356 |
"tools-check-spelling",
|
357 |
"view-fullscreen",
|
358 |
"view-refresh",
|
359 |
"view-restore",
|
360 |
"view-sort-ascending",
|
361 |
"view-sort-descending",
|
362 |
"window-close",
|
363 |
"window-new",
|
364 |
"zoom-fit-best",
|
365 |
"zoom-in",
|
366 |
"zoom-original",
|
367 |
"zoom-out",
|
368 |
"process-working",
|
369 |
"accessories-calculator",
|
370 |
"accessories-character-map",
|
371 |
"accessories-dictionary",
|
372 |
"accessories-text-editor",
|
373 |
"help-browser",
|
374 |
"multimedia-volume-control",
|
375 |
"preferences-desktop-accessibility",
|
376 |
"preferences-desktop-font",
|
377 |
"preferences-desktop-keyboard",
|
378 |
"preferences-desktop-locale",
|
379 |
"preferences-desktop-multimedia",
|
380 |
"preferences-desktop-screensaver",
|
381 |
"preferences-desktop-theme",
|
382 |
"preferences-desktop-wallpaper",
|
383 |
"system-file-manager",
|
384 |
"system-software-install",
|
385 |
"system-software-update",
|
386 |
"utilities-system-monitor",
|
387 |
"utilities-terminal",
|
388 |
"applications-accessories",
|
389 |
"applications-development",
|
390 |
"applications-engineering",
|
391 |
"applications-games",
|
392 |
"applications-graphics",
|
393 |
"applications-internet",
|
394 |
"applications-multimedia",
|
395 |
"applications-office",
|
396 |
"applications-other",
|
397 |
"applications-science",
|
398 |
"applications-system",
|
399 |
"applications-utilities",
|
400 |
"preferences-desktop",
|
401 |
"preferences-desktop-peripherals",
|
402 |
"preferences-desktop-personal",
|
403 |
"preferences-other",
|
404 |
"preferences-system",
|
405 |
"preferences-system-network",
|
406 |
"system-help",
|
407 |
"audio-card",
|
408 |
"audio-input-microphone",
|
409 |
"battery",
|
410 |
"camera-photo",
|
411 |
"camera-video",
|
412 |
"camera-web",
|
413 |
"computer",
|
414 |
"drive-harddisk",
|
415 |
"drive-optical",
|
416 |
"drive-removable-media",
|
417 |
"input-gaming",
|
418 |
"input-keyboard",
|
419 |
"input-mouse",
|
420 |
"input-tablet",
|
421 |
"media-flash",
|
422 |
"media-floppy",
|
423 |
"media-optical",
|
424 |
"media-tape",
|
425 |
"modem",
|
426 |
"multimedia-player",
|
427 |
"network-wired",
|
428 |
"network-wireless",
|
429 |
"pda",
|
430 |
"phone",
|
431 |
"printer",
|
432 |
"scanner",
|
433 |
"video-display",
|
434 |
"emblem-default",
|
435 |
"emblem-documents",
|
436 |
"emblem-downloads",
|
437 |
"emblem-favorite",
|
438 |
"emblem-important",
|
439 |
"emblem-mail",
|
440 |
"emblem-photos",
|
441 |
"emblem-readonly",
|
442 |
"emblem-shared",
|
443 |
"emblem-symbolic-link",
|
444 |
"emblem-synchronized",
|
445 |
"emblem-system",
|
446 |
"emblem-unreadable",
|
447 |
"face-angel",
|
448 |
"face-angry",
|
449 |
"face-cool",
|
450 |
"face-crying",
|
451 |
"face-devilish",
|
452 |
"face-embarrassed",
|
453 |
"face-kiss",
|
454 |
"face-laugh",
|
455 |
"face-monkey",
|
456 |
"face-plain",
|
457 |
"face-raspberry",
|
458 |
"face-sad",
|
459 |
"face-sick",
|
460 |
"face-smile",
|
461 |
"face-smile-big",
|
462 |
"face-smirk",
|
463 |
"face-surprise",
|
464 |
"face-tired",
|
465 |
"face-uncertain",
|
466 |
"face-wink",
|
467 |
"face-worried",
|
468 |
"flag-aa",
|
469 |
"application-x-executable",
|
470 |
"audio-x-generic",
|
471 |
"font-x-generic",
|
472 |
"image-x-generic",
|
473 |
"package-x-generic",
|
474 |
"text-html",
|
475 |
"text-x-generic",
|
476 |
"text-x-generic-template",
|
477 |
"text-x-script",
|
478 |
"video-x-generic",
|
479 |
"x-office-address-book",
|
480 |
"x-office-calendar",
|
481 |
"x-office-document",
|
482 |
"x-office-presentation",
|
483 |
"x-office-spreadsheet",
|
484 |
"folder",
|
485 |
"folder-remote",
|
486 |
"network-server",
|
487 |
"network-workgroup",
|
488 |
"start-here",
|
489 |
"user-bookmarks",
|
490 |
"user-desktop",
|
491 |
"user-home",
|
492 |
"user-trash",
|
493 |
"appointment-missed",
|
494 |
"appointment-soon",
|
495 |
"audio-volume-high",
|
496 |
"audio-volume-low",
|
497 |
"audio-volume-medium",
|
498 |
"audio-volume-muted",
|
499 |
"battery-caution",
|
500 |
"battery-low",
|
501 |
"dialog-error",
|
502 |
"dialog-information",
|
503 |
"dialog-password",
|
504 |
"dialog-question",
|
505 |
"dialog-warning",
|
506 |
"folder-drag-accept",
|
507 |
"folder-open",
|
508 |
"folder-visiting",
|
509 |
"image-loading",
|
510 |
"image-missing",
|
511 |
"mail-attachment",
|
512 |
"mail-unread",
|
513 |
"mail-read",
|
514 |
"mail-replied",
|
515 |
"mail-signed",
|
516 |
"mail-signed-verified",
|
517 |
"media-playlist-repeat",
|
518 |
"media-playlist-shuffle",
|
519 |
"network-error",
|
520 |
"network-idle",
|
521 |
"network-offline",
|
522 |
"network-receive",
|
523 |
"network-transmit",
|
524 |
"network-transmit-receive",
|
525 |
"printer-error",
|
526 |
"printer-printing",
|
527 |
"security-high",
|
528 |
"security-medium",
|
529 |
"security-low",
|
530 |
"software-update-available",
|
531 |
"software-update-urgent",
|
532 |
"sync-error",
|
533 |
"sync-synchronizing",
|
534 |
"task-due",
|
535 |
"task-past-due",
|
536 |
"user-available",
|
537 |
"user-away",
|
538 |
"user-idle",
|
539 |
"user-offline",
|
540 |
"user-trash-full",
|
541 |
"weather-clear",
|
542 |
"weather-clear-night",
|
543 |
"weather-few-clouds",
|
544 |
"weather-few-clouds-night",
|
545 |
"weather-fog",
|
546 |
"weather-overcast",
|
547 |
"weather-severe-alert",
|
548 |
"weather-showers",
|
549 |
"weather-showers-scattered",
|
550 |
"weather-snow",
|
551 |
"weather-storm"
|
552 |
}; |
553 |
Set<String> icons = new HashSet<String>(); |
554 |
for (int i = 0; i < iconNames.length; i++) { |
555 |
icons.add(iconNames[i]); |
556 |
} |
557 |
return icons;
|
558 |
} |
559 |
|
560 |
} |