Thread: [Japi-cvs] SF.net SVN: japi:[657] libs/swing-about/trunk/src/prj/net/sf/japi/swing/ about/AboutDial
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2008-10-07 18:20:15
|
Revision: 657 http://japi.svn.sourceforge.net/japi/?rev=657&view=rev Author: christianhujer Date: 2008-10-07 18:20:09 +0000 (Tue, 07 Oct 2008) Log Message: ----------- Improvements regarding exception handling and reuse. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2008-10-07 18:18:30 UTC (rev 656) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2008-10-07 18:20:09 UTC (rev 657) @@ -27,13 +27,13 @@ import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; +import java.util.Collection; import java.util.Enumeration; +import java.util.MissingResourceException; import java.util.Properties; import java.util.ResourceBundle; -import java.util.SortedSet; import java.util.TreeSet; import javax.swing.ImageIcon; -import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -180,7 +180,7 @@ * Adds a tab. * @param component Component to add as tab */ - public void addTab(@NotNull final Component component) { + public final void addTab(@NotNull final Component component) { tabs.add(component); } @@ -202,7 +202,7 @@ * @param number number of license * @return component for XY license tab */ - @NotNull private JComponent buildLicenseSubTab(@NotNull final String number) { + @NotNull private Component buildLicenseSubTab(@NotNull final String number) { String licenseText; try { final Reader in = new InputStreamReader(new BufferedInputStream(getClass().getClassLoader().getResource(actionBuilder.getString("license." + number + ".file")).openStream())); @@ -226,41 +226,45 @@ license.setWrapStyleWord(true); license.setEditable(false); license.setFont(new Font("Monospaced", Font.PLAIN, license.getFont().getSize())); - final JScrollPane scroller = new JScrollPane(license); + final Component scroller = new JScrollPane(license); scroller.setFocusable(true); scroller.setName(actionBuilder.getString("license." + number + ".title")); return scroller; } + /** Gets a String from a bundle. + * @param bundle Bundle to get String from. + * @param key Key for which to get the String. + * @return String from the bundle or <code>null</code> if not available. + */ + @Nullable private String getStringFromBundle(@NotNull final ResourceBundle bundle, @NotNull final String key) { + try { + return bundle.getString(key); + } catch (final MissingResourceException e) { + /* ignore */ + } catch (final ClassCastException e) { + System.err.println("Internal error: value type for key " + key + " in " + bundle + " must be String."); + } + return null; + } + /** * Build the about tab. * @return component for about tab */ - @NotNull private JComponent buildAboutTab() { + @NotNull private Component buildAboutTab() { String buildNumber = ACTION_BUILDER.getString("unknown"); String buildDeveloper = ACTION_BUILDER.getString("unknown"); String buildTstamp = ACTION_BUILDER.getString("unknown"); try { final ResourceBundle bundle = ResourceBundle.getBundle("build"); - try { - buildDeveloper = bundle.getString("build.developer"); - } catch (final Exception e) { - /* ignore */ - } - try { - buildNumber = bundle.getString("build.number"); - } catch (final Exception e) { - /* ignore */ - } - try { - buildTstamp = bundle.getString("build.tstamp"); - } catch (final Exception e) { - /* ignore */ - } - } catch (final Exception e) { + buildDeveloper = getStringFromBundle(bundle, "build.developer"); + buildNumber = getStringFromBundle(bundle, "build.number"); + buildTstamp = getStringFromBundle(bundle, "build.tstamp"); + } catch (final MissingResourceException e) { /* ignore */ } - final JLabel aboutTab = new JLabel(actionBuilder.format("about", System.getProperty("java.version"), buildNumber, buildDeveloper, buildTstamp), SwingConstants.CENTER); + final Component aboutTab = new JLabel(actionBuilder.format("about", System.getProperty("java.version"), buildNumber, buildDeveloper, buildTstamp), SwingConstants.CENTER); aboutTab.setName(ACTION_BUILDER.getString("aboutTab.title")); return aboutTab; } @@ -269,9 +273,9 @@ * Build the runtime properties tab. * @return component for runtime properties tab */ - @NotNull private JComponent buildRuntimePropertiesTab() { + @NotNull private Component buildRuntimePropertiesTab() { final StringBuilder propertiesText = new StringBuilder(); - final SortedSet<String> keys = new TreeSet<String>(); + final Collection<String> keys = new TreeSet<String>(); final Properties props = System.getProperties(); for (final Object key : props.keySet()) { if (key instanceof String) { @@ -288,7 +292,7 @@ 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); + final Component scroller = new JScrollPane(properties); scroller.setName(ACTION_BUILDER.getString("aboutRuntimeProperties.title")); scroller.setFocusable(true); return scroller; @@ -298,28 +302,32 @@ * Build the build properties tab. * @return component for build properties tab */ - @NotNull private JComponent buildBuildPropertiesTab() { + @NotNull private Component buildBuildPropertiesTab() { final StringBuilder propertiesText = new StringBuilder(); - final SortedSet<String> keys = new TreeSet<String>(); + final Collection<String> keys = new TreeSet<String>(); try { final ResourceBundle bundle = ResourceBundle.getBundle("build"); for (final Enumeration<String> uKeys = bundle.getKeys(); uKeys.hasMoreElements();) { keys.add(uKeys.nextElement()); } for (final String key : keys) { - propertiesText - .append(key) - .append('=') - .append(bundle.getString(key)) - .append('\n'); + try { + propertiesText + .append(key) + .append('=') + .append(bundle.getString(key)) + .append('\n'); + } catch (final ClassCastException e) { + System.err.println("Internal error: expecting build properties to be Strings, but property for key " + key + " was not a String."); + } } - } catch (final Exception e) { + } catch (final MissingResourceException e) { propertiesText.append(e.toString()); } 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); + final Component scroller = new JScrollPane(properties); scroller.setName(ACTION_BUILDER.getString("aboutBuildProperties.title")); scroller.setFocusable(true); return scroller; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-01-09 20:33:10
|
Revision: 774 http://japi.svn.sourceforge.net/japi/?rev=774&view=rev Author: akirschbaum Date: 2009-01-09 20:33:00 +0000 (Fri, 09 Jan 2009) Log Message: ----------- Allow copying text from about tab. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2008-12-30 04:38:38 UTC (rev 773) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-01-09 20:33:00 UTC (rev 774) @@ -22,6 +22,8 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStreamReader; @@ -34,6 +36,7 @@ import java.util.ResourceBundle; import java.util.TreeSet; import javax.swing.ImageIcon; +import javax.swing.JEditorPane; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -41,6 +44,7 @@ import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.SwingConstants; +import javax.swing.UIManager; import net.sf.japi.swing.ActionBuilder; import net.sf.japi.swing.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -264,7 +268,16 @@ } catch (final MissingResourceException ignore) { /* ignore */ } - final Component aboutTab = new JLabel(actionBuilder.format("about", System.getProperty("java.version"), buildNumber, buildDeveloper, buildTstamp), SwingConstants.CENTER); + // use a JEditorPane which looks like a JLabel to allow copying its content + final JEditorPane editorPane = new JEditorPane("text/html", actionBuilder.format("about", System.getProperty("java.version"), buildNumber, buildDeveloper, buildTstamp)); + editorPane.setEditable(false); + editorPane.setBorder(null); + editorPane.setForeground(UIManager.getColor("Label.foreground")); + editorPane.setFont(UIManager.getFont("Label.font")); + editorPane.setOpaque(false); + final JPanel aboutTab = new JPanel(new GridBagLayout()); + final GridBagConstraints gbc = new GridBagConstraints(); + aboutTab.add(editorPane, gbc); aboutTab.setName(ACTION_BUILDER.getString("aboutTab.title")); return aboutTab; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-17 19:54:31
|
Revision: 930 http://japi.svn.sourceforge.net/japi/?rev=930&view=rev Author: christianhujer Date: 2009-02-17 19:54:27 +0000 (Tue, 17 Feb 2009) Log Message: ----------- Removed trailing empty line. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-02-17 11:54:05 UTC (rev 929) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-02-17 19:54:27 UTC (rev 930) @@ -352,4 +352,3 @@ } } // class AboutDialog - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-03-01 21:04:59
|
Revision: 1209 http://japi.svn.sourceforge.net/japi/?rev=1209&view=rev Author: christianhujer Date: 2009-03-01 21:04:50 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Fix IntelliJ IDEA warnings. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-03-01 20:54:33 UTC (rev 1208) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-03-01 21:04:50 UTC (rev 1209) @@ -206,11 +206,13 @@ */ @NotNull private Component buildLicenseSubTab(@NotNull final String number) { String licenseText; + //noinspection ProhibitedExceptionCaught try { final Reader in = new InputStreamReader(new BufferedInputStream(getClass().getClassLoader().getResource(actionBuilder.getString("license." + number + ".file")).openStream())); try { final StringBuilder sb = new StringBuilder(); final char[] buf = new char[BUF_SIZE]; + //noinspection NestedAssignment for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { sb.append(buf, 0, bytesRead); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-03-02 01:19:18
|
Revision: 1223 http://japi.svn.sourceforge.net/japi/?rev=1223&view=rev Author: christianhujer Date: 2009-03-02 01:19:17 +0000 (Mon, 02 Mar 2009) Log Message: ----------- Add @since information for classes and packages. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-03-02 01:19:01 UTC (rev 1222) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-03-02 01:19:17 UTC (rev 1223) @@ -97,6 +97,7 @@ * </ul> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum + * @since 0.1 * @todo Allow configuring the build information * @todo Allow reading the information from a specified bundle instead of an ActionBuilder. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-05-23 14:32:41
|
Revision: 1322 http://japi.svn.sourceforge.net/japi/?rev=1322&view=rev Author: christianhujer Date: 2009-05-23 14:32:28 +0000 (Sat, 23 May 2009) Log Message: ----------- Fix PMD issues. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-05-23 14:23:00 UTC (rev 1321) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2009-05-23 14:32:28 UTC (rev 1322) @@ -141,9 +141,9 @@ this.actionBuilder = actionBuilder; tabs = new JTabbedPane(); licensePane = buildLicenseTab(); - @Nullable final String logoURLString = actionBuilder.getString("about.logo"); + final String logoURLString = actionBuilder.getString("about.logo"); if (logoURLString != null) { - @Nullable final URL logoURL = getClass().getClassLoader().getResource(logoURLString); + final URL logoURL = getClass().getClassLoader().getResource(logoURLString); if (logoURL != null) { add(new JLabel(new ImageIcon(logoURL)), BorderLayout.NORTH); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2010-05-16 11:43:55
|
Revision: 1406 http://japi.svn.sourceforge.net/japi/?rev=1406&view=rev Author: christianhujer Date: 2010-05-16 11:43:49 +0000 (Sun, 16 May 2010) Log Message: ----------- Improve documentation. Modified Paths: -------------- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java Modified: libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java =================================================================== --- libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2010-04-11 11:06:48 UTC (rev 1405) +++ libs/swing-about/trunk/src/prj/net/sf/japi/swing/about/AboutDialog.java 2010-05-16 11:43:49 UTC (rev 1406) @@ -50,6 +50,7 @@ /** * Class for constructing and showing About dialogs. + * * It features: * <ul> * <li>logo</li> @@ -58,6 +59,7 @@ * <li>All runtime properties</li> * <li>All licenses the software uses</li> * </ul> + * * It requires the following properties to be available in the named ActionBuilder: * <ul> * <li><code>about.logo</code> specifies the logo to display (optional)</li> @@ -66,12 +68,13 @@ * <code>about</code> specifies the format string for the about text in the about tab. * It takes the following parameters: * <ol> - * <li>The runtime's Java Version</li> - * <li>The build number</li> - * <li>The build developer</li> - * <li>The build timestamp</li> + * <li><code>{0}</code>: The runtime's Java Version</li> + * <li><code>{1}</code>: The build number (see build resource bundle below)</li> + * <li><code>{2}</code>: The build developer (see build resource bundle below)</li> + * <li><code>{3}</code>: The build timestamp (see build resource bundle below)</li> * </ol> * (See information on the build for how to specify the build information) + * Hint: Use Swing HTML 3.2 if you want formatted text (tables etc.). * </li> * <li> * Licenses: @@ -84,12 +87,20 @@ * <li><code>aboutBuildProperties.title</code> specifies the title for the build properties tab (optional - only required if the build properties tab is used)</li> * <li><code>aboutRuntimeProperties.title</code> specifies the title for the runtime properties tab (required)</li> * </ul> + * + * <h2>build resource bundle</h2> * The information on the build is specified by: * <ul> * <li> - * A ResourceBundle <code>build</code> (optional, e.g. <code>build.properties</code> toplevel on classpath) + * A ResourceBundle <code>build</code> (optional, e.g. <code>build.properties</code> toplevel on classpath). + * All properties in that bundle are going to be displayed on the build tab. + * The following properties have special meaning and are message format parameters to about (see above): * <ul> - * <li><code>build.developer</code> The developer that made the build (optional)</li> + * <li> + * <code>build.developer</code> The developer that made the build (optional). + * Note: This is meant to be the developer that performed the build, not the developers that developed the software. + * Use the <code>about</code> property described above to specify copyright / authors / contributors / developers. + * </li> * <li><code>build.number</code> The build number, e.g. incremented by Ant or the Subversion revision (optional)</li> * <li><code>build.tstamp</code> The timestamp when the build was made (optional)</li> * </ul> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |