1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.glxdesktop.gui.about;
18
19 import java.io.FileNotFoundException;
20
21 import net.sf.glxdesktop.Utils;
22 import net.sf.glxdesktop.UtilsException;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.gnu.gdk.Pixbuf;
27 import org.gnu.glib.JGException;
28 import org.gnu.gtk.AboutDialog;
29
30 /***
31 * @author fons
32 *
33 */
34 public abstract class AboutCommonsDialog implements AboutProperties {
35
36 private static final Log LOG = LogFactory.getLog(AboutCommonsDialog.class);
37
38 public AboutCommonsDialog() {
39 initGui();
40 }
41
42 private String appName = null, appIcon = null, appVersion = null,
43 appDescription = null, appCopyright = null, appWebsite = null;
44
45 public void initGui() {
46 appName = getApplicationNameString();
47 appVersion = getApplicationVersionString();
48 appDescription = getApplicationDescritionString();
49 appWebsite = getWebsiteString();
50 appCopyright = getCopyrightString();
51
52 try {
53
54
55 appIcon = ClassLoader.getSystemClassLoader().getResource(getApplicationImagePath()).getFile();
56 } catch (Exception exception) {
57 appIcon = null;
58 }
59
60 AboutDialog about = new AboutDialog();
61 if (appName != null)
62 about.setName(appName);
63 if (appIcon != null) {
64 try {
65 Pixbuf appPixBuffer= new Pixbuf(appIcon);
66 about.setLogo(appPixBuffer);
67 about.setIcon(appPixBuffer);
68 } catch (FileNotFoundException e) {
69 if (!LOG.isDebugEnabled()) {
70 LOG.warn(e.getMessage());
71 } else {
72 LOG.warn(e.getMessage(), e);
73 }
74 } catch (JGException e) {
75 if (!LOG.isDebugEnabled()) {
76 LOG.warn(e.getMessage());
77 } else {
78 LOG.warn(e.getMessage(), e);
79 }
80 }
81 }
82 try {
83 if (getFileLicensePath() != null)
84 about.setLicense(Utils.fileToString(getFileLicensePath()));
85
86 if (getFileAuthorsPath() != null)
87 about.setAuthors(Utils.fileToString(getFileAuthorsPath()).split("\n"));
88 if (getFileDocumentorPath() != null)
89 about.setDocumenters(Utils.fileToString(getFileDocumentorPath()).split(
90 "\n"));
91 if (getFileTranslatorsPath() != null)
92 about.setTranslatorCredits(Utils.fileToString(getFileTranslatorsPath()));
93 } catch (UtilsException e1) {
94 LOG.warn(e1);
95 }
96
97 if (appVersion != null)
98 about.setVersion(appVersion);
99 if (appDescription != null)
100 about.setComments(appDescription);
101 if (appCopyright != null)
102 about.setCopyright(appCopyright);
103 if (appWebsite != null)
104 about.setWebsite(appWebsite);
105 about.show();
106 }
107 }