X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fgui%2FAboutDialog.java;h=8f79a52a68cafd163304bc6d5ea31b7cfcf9ebd8;hb=c63257e8cc0ba1a5aca9364b22171abe7279d479;hp=3601733113f4cda0d71152a06055b5774508f79c;hpb=d45a9a5114035cf83c2d24c5f584e38db76cd804;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/gui/AboutDialog.java b/src/net/pterodactylus/jsite/gui/AboutDialog.java index 3601733..8f79a52 100644 --- a/src/net/pterodactylus/jsite/gui/AboutDialog.java +++ b/src/net/pterodactylus/jsite/gui/AboutDialog.java @@ -53,17 +53,20 @@ import net.pterodactylus.util.swing.SwingUtils; /** * An “about” dialog. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ public class AboutDialog extends JDialog implements I18nable { /** A list of all contributors. */ private static final List CONTRIBUTORS = new ArrayList(); + /** A list of all code usages. */ + private static final List CODE_USAGES = new ArrayList(); + static { CONTRIBUTORS.add(new Contributor("David ‘Bombe’ Roden", "bombe@freenetproject.org", "Main code")); + CODE_USAGES.add(new CodeUsage("Tango Desktop Project", "http://tango.freedesktop.org/", "Creative Commons Attribution-Share Alike 2.5", "Icons")); } /** The “okay” button action. */ @@ -78,12 +81,18 @@ public class AboutDialog extends JDialog implements I18nable { /** The i18n maintainer’s name label. */ private JLabel i18nMaintainerNameLabel; + /** The “other people’s code used” label. */ + private I18nLabel codeUsageLabel; + /** The license header. */ private I18nLabel licenseHeaderLabel; + /** The tabbed pane with all the pages. */ + private JTabbedPane pagesPane; + /** * Creates a new “about” dialog. - * + * * @param swingInterface * The Swing interface */ @@ -105,6 +114,7 @@ public class AboutDialog extends JDialog implements I18nable { */ private void initActions() { okayAction = new I18nAction("general.button.okay") { + /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ @@ -123,13 +133,13 @@ public class AboutDialog extends JDialog implements I18nable { getContentPane().add(contentPane, BorderLayout.CENTER); contentPane.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); - JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); - contentPane.add(tabbedPane, BorderLayout.CENTER); + pagesPane = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); + contentPane.add(pagesPane, BorderLayout.CENTER); - tabbedPane.addTab(I18n.get("aboutDialog.page.about.title"), createAboutPage()); - tabbedPane.setToolTipTextAt(0, I18n.get("aboutDialog.page.about.shortDescription")); - tabbedPane.addTab(I18n.get("aboutDialog.page.license.title"), createLicensePage()); - tabbedPane.setToolTipTextAt(1, I18n.get("aboutDialog.page.license.shortDescription")); + pagesPane.addTab(I18n.get("aboutDialog.page.about.title"), createAboutPage()); + pagesPane.setToolTipTextAt(0, I18n.get("aboutDialog.page.about.shortDescription")); + pagesPane.addTab(I18n.get("aboutDialog.page.license.title"), createLicensePage()); + pagesPane.setToolTipTextAt(1, I18n.get("aboutDialog.page.license.shortDescription")); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); contentPane.add(buttonPanel, BorderLayout.PAGE_END); @@ -138,7 +148,7 @@ public class AboutDialog extends JDialog implements I18nable { /** * Creates the “about” page. - * + * * @return The “about” page */ private JComponent createAboutPage() { @@ -160,7 +170,7 @@ public class AboutDialog extends JDialog implements I18nable { textPanel.add(Box.createVerticalStrut(12)); contributorsLabel.setFont(contributorsLabel.getFont().deriveFont(Font.BOLD)); - for (Contributor contributor: CONTRIBUTORS) { + for (Contributor contributor : CONTRIBUTORS) { JLabel contributorLabel = new JLabel(contributor.getName() + " <" + contributor.getEmail() + "> (" + contributor.getPart() + ")"); textPanel.add(contributorLabel); } @@ -173,21 +183,35 @@ public class AboutDialog extends JDialog implements I18nable { i18nMaintainerNameLabel = new JLabel(I18n.get("i18n.maintainer.name") + " <" + I18n.get("i18n.maintainer.email") + ">"); textPanel.add(i18nMaintainerNameLabel); + textPanel.add(Box.createVerticalStrut(24)); + + codeUsageLabel = new I18nLabel("aboutDialog.page.about.label.codeUsage"); + codeUsageLabel.setFont(codeUsageLabel.getFont().deriveFont(Font.BOLD)); + textPanel.add(codeUsageLabel); + textPanel.add(Box.createVerticalStrut(12)); + + for (CodeUsage codeUsage : CODE_USAGES) { + JLabel usageLabel = new JLabel(codeUsage.getName() + " (" + codeUsage.getURL() + ", " + codeUsage.getLicense() + ")"); + textPanel.add(usageLabel); + } return aboutPanel; } /** * Creates the “license” page. - * + * * @return The “license” page */ private JComponent createLicensePage() { JPanel licensePanel = new JPanel(new BorderLayout(12, 12)); licensePanel.setBorder(BorderFactory.createEmptyBorder(12, 12, 12, 12)); + JPanel licenseHeaderPanel = new JPanel(new FlowLayout()); + licensePanel.add(licenseHeaderPanel, BorderLayout.PAGE_START); + licenseHeaderLabel = new I18nLabel("aboutDialog.page.license.header", Version.getVersion()); - licensePanel.add(licenseHeaderLabel, BorderLayout.PAGE_START); + licenseHeaderPanel.add(licenseHeaderLabel); licenseHeaderLabel.setAlignmentX(0.5f); String licenseText = loadLicenseText(); @@ -201,7 +225,7 @@ public class AboutDialog extends JDialog implements I18nable { /** * Loads the license text. - * + * * @return The license text */ private String loadLicenseText() { @@ -246,17 +270,21 @@ public class AboutDialog extends JDialog implements I18nable { contributorsLabel.updateI18n(); licenseHeaderLabel.updateI18n(); i18nMaintainerLabel.updateI18n(); + codeUsageLabel.updateI18n(); i18nMaintainerNameLabel.setText(I18n.get("i18n.maintainer.name") + " <" + I18n.get("i18n.maintainer.email") + ">"); okayAction.updateI18n(); setTitle(I18n.get("aboutDialog.title")); + pagesPane.setTitleAt(0, I18n.get("aboutDialog.page.about.title")); + pagesPane.setToolTipTextAt(0, I18n.get("aboutDialog.page.about.shortDescription")); + pagesPane.setTitleAt(1, I18n.get("aboutDialog.page.license.title")); + pagesPane.setToolTipTextAt(1, I18n.get("aboutDialog.page.license.shortDescription")); SwingUtils.repackCentered(this); } /** * Container for a contributor. - * + * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ private static class Contributor { @@ -271,7 +299,7 @@ public class AboutDialog extends JDialog implements I18nable { /** * Creates a new contributor. - * + * * @param name * The name of the contributor * @param email @@ -287,7 +315,7 @@ public class AboutDialog extends JDialog implements I18nable { /** * Returns the name of the contributor. - * + * * @return The name of the contributor */ String getName() { @@ -296,7 +324,7 @@ public class AboutDialog extends JDialog implements I18nable { /** * Returns the email address of the contributor. - * + * * @return The email address of the contributor */ String getEmail() { @@ -305,7 +333,7 @@ public class AboutDialog extends JDialog implements I18nable { /** * Returns the parts where the contributor helped. - * + * * @return The parts where the contributor helped */ String getPart() { @@ -314,4 +342,81 @@ public class AboutDialog extends JDialog implements I18nable { } + /** + * A code usage object describes code or other resources that have been + * taken from other projects. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + */ + private static class CodeUsage { + + /** The name of the project. */ + private final String name; + + /** The URL of the project. */ + private final String url; + + /** The license of the project. */ + private final String license; + + /** The part that is used. */ + private final String part; + + /** + * Creates a new code usage object. + * + * @param name + * The name of the project + * @param url + * The URL of the project + * @param license + * The license of the used code + * @param part + * The part that is used + */ + public CodeUsage(String name, String url, String license, String part) { + this.name = name; + this.url = url; + this.license = license; + this.part = part; + } + + /** + * Returns the name of the project. + * + * @return The name of the project + */ + public String getName() { + return name; + } + + /** + * Returns the URL of the project. + * + * @return The URL of the project + */ + public String getURL() { + return url; + } + + /** + * Returns the license of the used part. + * + * @return The license of the used part + */ + public String getLicense() { + return license; + } + + /** + * Returns the used part. + * + * @return The used part + */ + public String getPart() { + return part; + } + + } + }