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