[Japi-cvs] SF.net SVN: japi: [460] libs/swing-about/trunk/src/net/sf/japi/swing/about/ AboutDialog.
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-06-30 07:41:24
|
Revision: 460 http://svn.sourceforge.net/japi/?rev=460&view=rev Author: christianhujer Date: 2007-06-30 00:41:21 -0700 (Sat, 30 Jun 2007) Log Message: ----------- Introduced constants for magic numbers. Added missing @NotNull / @Nullable annotations. Modified Paths: -------------- libs/swing-about/trunk/src/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/net/sf/japi/swing/about/AboutDialog.java 2007-06-29 20:08:21 UTC (rev 459) +++ libs/swing-about/trunk/src/net/sf/japi/swing/about/AboutDialog.java 2007-06-30 07:41:21 UTC (rev 460) @@ -43,6 +43,7 @@ import javax.swing.SwingConstants; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * Class for constructing and showing About dialogs. @@ -100,26 +101,35 @@ public class AboutDialog extends JPanel { /** Action Factory to create Actions. */ - protected static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.about"); + @NotNull protected static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.about"); + /** Default buffer size for I/O, e.g. when reading a license. */ + private static final int BUF_SIZE = 4096; + + /** Default number of rows in a textarea in an AboutDialog. */ + private static final int TEXT_ROWS = 16; + + /** Default number of columns in a textarea in an AboutDialog. */ + private static final int TEXT_COLUMNS = 80; + /** Action Factory to create Actions. */ - private final ActionFactory actionFactory; + @NotNull private final ActionFactory actionFactory; /** * The main tabs. */ - private final JTabbedPane tabs; + @NotNull private final JTabbedPane tabs; /** * The tabs in the license tab. */ - private final JTabbedPane licensePane; + @NotNull private final JTabbedPane licensePane; /** * Create an AboutDialog. * @param actionFactory ActionFactory to use. */ - public AboutDialog(final ActionFactory actionFactory) { + public AboutDialog(@NotNull final ActionFactory actionFactory) { super(new BorderLayout()); this.actionFactory = actionFactory; tabs = new JTabbedPane(); @@ -146,7 +156,7 @@ * Create an AboutDialog. * @param actionFactoryName Name of the ActionFactory to use. */ - public AboutDialog(final String actionFactoryName) { + public AboutDialog(@NotNull final String actionFactoryName) { this(ActionFactory.getFactory(actionFactoryName)); } @@ -154,7 +164,7 @@ * Show about dialog. * @param parent Parent component to show dialog on */ - public void showAboutDialog(final Component parent) { + public void showAboutDialog(@Nullable final Component parent) { tabs.setSelectedIndex(0); if (licensePane.getComponentCount() > 0) { licensePane.setSelectedIndex(0); @@ -166,7 +176,7 @@ * Adds a tab. * @param component Component to add as tab */ - public void addTab(final Component component) { + public void addTab(@NotNull final Component component) { tabs.add(component); } @@ -174,7 +184,7 @@ * Build the license tab. * @return component for license tab */ - private JTabbedPane buildLicenseTab() { + @NotNull private JTabbedPane buildLicenseTab() { final JTabbedPane licensePane = new JTabbedPane(); for (int i = 1; actionFactory.getString("license." + i + ".title") != null; i++) { licensePane.add(buildLicenseSubTab(String.valueOf(i))); @@ -188,13 +198,13 @@ * @param number number of license * @return component for XY license tab */ - private JComponent buildLicenseSubTab(final String number) { + @NotNull private JComponent buildLicenseSubTab(@NotNull final String number) { String licenseText; try { final Reader in = new InputStreamReader(new BufferedInputStream(getClass().getClassLoader().getResource(actionFactory.getString("license." + number + ".file")).openStream())); try { final StringBuilder sb = new StringBuilder(); - final char[] buf = new char[4096]; + final char[] buf = new char[BUF_SIZE]; for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { sb.append(buf, 0, bytesRead); } @@ -207,7 +217,7 @@ } catch (final IOException e) { licenseText = ACTION_FACTORY.getString("license.missing"); } - final JTextArea license = new JTextArea(licenseText, 16, 80); + final JTextArea license = new JTextArea(licenseText, TEXT_ROWS, TEXT_COLUMNS); license.setLineWrap(true); license.setWrapStyleWord(true); license.setEditable(false); @@ -222,7 +232,7 @@ * Build the about tab. * @return component for about tab */ - private JComponent buildAboutTab() { + @NotNull private JComponent buildAboutTab() { String buildNumber = "unknown"; String buildDeveloper = "unknown"; String buildTstamp = "unknown"; @@ -255,7 +265,7 @@ * Build the runtime properties tab. * @return component for runtime properties tab */ - private JComponent buildRuntimePropertiesTab() { + @NotNull private JComponent buildRuntimePropertiesTab() { final StringBuilder propertiesText = new StringBuilder(); final SortedSet<String> keys = new TreeSet<String>(); final Properties props = System.getProperties(); @@ -271,7 +281,7 @@ .append(props.getProperty(key)) .append('\n'); } - final JTextArea properties = new JTextArea(propertiesText.toString(), 16, 77); + final JTextArea properties = new JTextArea(propertiesText.toString(), TEXT_ROWS, TEXT_COLUMNS); properties.setEditable(false); properties.setFont(new Font("Monospaced", Font.PLAIN, properties.getFont().getSize())); final JScrollPane scroller = new JScrollPane(properties); @@ -284,7 +294,7 @@ * Build the build properties tab. * @return component for build properties tab */ - private JComponent buildBuildPropertiesTab() { + @NotNull private JComponent buildBuildPropertiesTab() { final StringBuilder propertiesText = new StringBuilder(); final SortedSet<String> keys = new TreeSet<String>(); try { @@ -302,7 +312,7 @@ } catch (final Exception e) { propertiesText.append(e.toString()); } - final JTextArea properties = new JTextArea(propertiesText.toString(), 16, 77); + final JTextArea properties = new JTextArea(propertiesText.toString(), TEXT_ROWS, TEXT_COLUMNS); properties.setEditable(false); properties.setFont(new Font("Monospaced", Font.PLAIN, properties.getFont().getSize())); final JScrollPane scroller = new JScrollPane(properties); @@ -314,7 +324,7 @@ /** Returns the ActionFactory to create actions. * @return The ActionFactory to create actions. */ - protected ActionFactory getActionFactory() { + @NotNull protected ActionFactory getActionFactory() { return actionFactory; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |