Revision 47411

View differences:

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
23 23
 */
24 24
package org.gvsig.app.extension.develtools;
25 25

  
26
import java.io.File;
26 27
import java.util.ArrayList;
27 28
import java.util.Collections;
28 29
import java.util.Comparator;
......
30 31
import java.util.Iterator;
31 32
import java.util.List;
32 33
import java.util.Set;
33

  
34 34
import javax.swing.ImageIcon;
35

  
35
import javax.swing.JOptionPane;
36 36
import org.gvsig.andami.PluginsLocator;
37 37
import org.gvsig.andami.actioninfo.ActionInfo;
38
import org.gvsig.desktopopen.DesktopOpen;
39
import org.gvsig.tools.ToolsLocator;
40
import org.gvsig.tools.exception.BaseException;
41
import org.gvsig.tools.folders.FoldersManager;
42
import org.gvsig.tools.i18n.I18nManager;
43
import org.gvsig.tools.swing.api.SimpleImage;
38 44
import org.gvsig.tools.swing.api.ToolsSwingLocator;
45
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
39 46
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
40 47
import org.gvsig.tools.swing.icontheme.IconTheme;
41 48
import org.gvsig.tools.swing.icontheme.IconThemeManager;
49
import org.gvsig.tools.util.ToolsUtilLocator;
50
import org.slf4j.Logger;
51
import org.slf4j.LoggerFactory;
42 52

  
43 53
public class IconThemeDevelTool {
54
    
55
    public static final Logger LOGGER = LoggerFactory.getLogger(IconThemeDevelTool.class);
44 56

  
45 57
	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);
58
            try {
59
                IconThemeManager manager = ToolsSwingLocator.getIconThemeManager();
60
		String html = "<html>"
61
                        + "<style type=\"text/css\" media=\"print\">"
62
                        + "@page {\n"
63
                        + "  size: A4 landscape;\n"
64
                        + "}"
65
                        + "</style>"
66
                        + "\n<body>\n"+ this.getIconThemeInformationByGroup(manager.getDefault())+"</body>\n</html>\n";
67
                FoldersManager fm = ToolsLocator.getFoldersManager();
68
                File f = fm.createTemporaryFile("defaulticontheme-report.html", html);
69
                DesktopOpen desktopOpen = ToolsUtilLocator.getToolsUtilManager().createDesktopOpen();
70
                desktopOpen.browse(f.toURI());
71
                
72
 
73
//                ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
74
//                ActionInfo showPdf = actionManager.getAction("show-pdf");
75
//                if(showPdf == null) {
76
//                    InfoPanel.save2file("defaulticontheme-report", html);
77
//                    InfoPanel.showPanel("Default icon theme information", WindowManager.MODE.WINDOW, html);
78
//                } else {
79
//                    showPdf.execute(
80
//                            new Object[]{
81
//                                "--title=", "Default icon theme information",
82
//                                "--mode=", WindowManager.MODE.WINDOW,
83
//                                "--source=", html
84
//                            }
85
//                    );
86
//                }
87
            } catch (Exception ex) {
88
                LOGGER.warn("Can't show default icon theme.'", ex);
89
                I18nManager i18n = ToolsLocator.getI18nManager();
90
                ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
91
                dialogs.messageDialog(
92
                        i18n.getTranslation("_Cant_show_default_icon_theme") + ")\n\n"+BaseException.getMessageStack(ex, 0),
93
                        i18n.getTranslation("_Show_default_icon_theme"),
94
                        JOptionPane.WARNING_MESSAGE
95
                );
96
            }
97

  
98
                
49 99
	}
50 100

  
101
	public void showCurrentIconTheme() {
102
            try {
103
                IconThemeManager manager = ToolsSwingLocator.getIconThemeManager();
104
                String html = "<html>"
105
                        + "<style type=\"text/css\" media=\"print\">"
106
                        + "@page {\n"
107
                        + "  size: A4 landscape;\n"
108
                        + "}"
109
                        + "</style>"
110
                        + "\n<body>\n"+ this.getIconThemeInformationByGroup(manager.getCurrent())+"</body>\n</html>\n";
111
 
112
                FoldersManager fm = ToolsLocator.getFoldersManager();
113
                File f = fm.createTemporaryFile("currenticontheme-report.html", html);
114
                DesktopOpen desktopOpen = ToolsUtilLocator.getToolsUtilManager().createDesktopOpen();
115
                desktopOpen.browse(f.toURI());
116

  
117
//                ActionInfoManager actionManager = PluginsLocator.getActionInfoManager();
118
//                ActionInfo showPdf = actionManager.getAction("show-pdf");
119
//                if(showPdf == null) {
120
//                    InfoPanel.save2file("currenticontheme-report", html);
121
//                    InfoPanel.showPanel("Current icon theme information", WindowManager.MODE.WINDOW, html);
122
//                } else {
123
//                    showPdf.execute(
124
//                            new Object[]{
125
//                                "--title=", "Current icon theme information",
126
//                                "--mode=", WindowManager.MODE.WINDOW,
127
//                                "--source=", html
128
//                            }
129
//                    );
130
//                }
131
            } catch (Exception ex) {
132
                LOGGER.warn("Can't show current icon theme.'", ex);
133
                I18nManager i18n = ToolsLocator.getI18nManager();
134
                ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
135
                dialogs.messageDialog(
136
                        i18n.getTranslation("_Cant_show_current_icon_theme") + ")\n\n"+BaseException.getMessageStack(ex, 0),
137
                        i18n.getTranslation("_Show_current_icon_theme"),
138
                        JOptionPane.WARNING_MESSAGE
139
                );
140
            }
141

  
142
	}
143

  
51 144
	public void showDefaultIconThemeByPlugin() {
52 145
		String html = "<html>\n<body>\n"+ this.getIconThemeInformationByPlugin()+"</body>\n</html>\n";
53 146
		InfoPanel.save2file("icontheme-report", html);
......
101 194
		return getIconThemeInformation(theme, themeIconsIt);
102 195
	}
103 196
	
104
	private String getIconThemeInformationByGroup() {
105
		IconThemeManager manager = ToolsSwingLocator.getIconThemeManager();
106
		IconTheme theme = manager.getDefault();
197
	private String getIconThemeInformationByGroup(IconTheme theme) {
107 198
		
108 199
		List<IconTheme.Icon>themeIcons = new ArrayList<IconTheme.Icon>();
109 200
		Iterator<IconTheme.Icon> themeIconsIt = theme.getThemeIcons();
......
181 272
			if( themeIcon.getLabel().length()>0 && themeIcon.getImageIcon()!=null ) {
182 273
				try {
183 274
					ImageIcon img = themeIcon.getImageIcon();
275
                                        SimpleImage simpleImg = ToolsSwingLocator.getToolsSwingManager().createSimpleImage(img);
184 276
					if( img.getIconHeight() > 48 || img.getIconWidth() > 48 ) {
185 277
						buffer
186 278
							.append("    <td nowrap>")
187
							.append("<img width=\"48\" height=\"48\" src=\"")
188
							.append(themeIcon.getLabel())
189
							.append("\">(*)</td>");
279
							.append("<img width=\"48\" height=\"48\" src=\"data:image/")
280
                                                        .append(simpleImg.getFormatName())
281
                                                        .append(";base64,")
282
                                                        .append(simpleImg.toStringBase64())
283
                                                        .append("\"><sup>(1)</sup>");
284
//                                                buffer.append("</td>");
190 285
					} else {
191 286
						buffer
192 287
							.append("    <td>")
193
							.append("<img src=\"")
194
							.append(themeIcon.getLabel())
195
							.append("\"></td>");
288
							.append("<img src=\"data:image/")
289
                                                        .append(simpleImg.getFormatName())
290
                                                        .append(";base64,")
291
                                                        .append(simpleImg.toStringBase64())
292
							.append("\">");
293
//                                                buffer.append("</td>");
196 294
					}
295
                                        if(!theme.isMyIcon(themeIcon.getName())){
296
                                            buffer.append("<sup>(2)</sup>");
297
                                        }
298
                                        buffer.append("</td>");
299
                                        
197 300
				} catch(Exception ex) {
198 301
					buffer
199 302
						.append("    <td>")
......
279 382
			buffer.append("  </tr>\n");
280 383
		}
281 384
		buffer.append("</table>\n");
385
                buffer.append("<p><sup>(1)</sup> Resized Icon<br><sup>(2)</sup> Icon in default theme</p>");
282 386
		buffer.append("</div>\n");
283 387

  
284 388
		return buffer.toString();
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ShowDevelInfoExtension.java
66 66
	public void execute(String actionCommand) {
67 67
		if ("tools-devel-show-persistencefactories".equalsIgnoreCase(actionCommand)) {
68 68
			new PersistenceDevelTool().showPersistenceFactories();
69
		} else if ("tools-devel-show-icontheme".equalsIgnoreCase(actionCommand)) {
69
		} else if ("tools-devel-show-defaulticontheme".equalsIgnoreCase(actionCommand)) {
70 70
			new IconThemeDevelTool().showDefaultIconTheme();
71
		} else if ("tools-devel-show-currenticontheme".equalsIgnoreCase(actionCommand)) {
72
			new IconThemeDevelTool().showCurrentIconTheme();
71 73
		} else if ("tools-devel-show-actions".equalsIgnoreCase(actionCommand)) {
72 74
			new ActionsInfoDevelTool().showActions();
73 75
		} else if ("tools-devel-show-toolbars".equalsIgnoreCase(actionCommand)) {

Also available in: Unified diff