[Japi-cvs] SF.net SVN: japi:[729] historic/trunk
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2008-11-30 18:10:09
|
Revision: 729
http://japi.svn.sourceforge.net/japi/?rev=729&view=rev
Author: christianhujer
Date: 2008-11-30 18:10:04 +0000 (Sun, 30 Nov 2008)
Log Message:
-----------
Removed classes from historic that are now in separate modules.
Modified Paths:
--------------
historic/trunk/historic.iml
historic/trunk/src/app/net/sf/japi/io/BCD.java
historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java
historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java
historic/trunk/src/app/net/sf/japi/util/PrintStreamThrowableHandler.java
historic/trunk/src/doc/guide/io/src/CatPlain.java
historic/trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/Editor.java
historic/trunk/src/doc/guide/swing/tod/src/ex/TodExampleApp.java
historic/trunk/src/test/net/sf/japi/io/BCDTest.java
Removed Paths:
-------------
historic/trunk/src/app/net/sf/japi/swing/ColumnLayout.java
historic/trunk/src/app/net/sf/japi/swing/IconManager.java
historic/trunk/src/app/net/sf/japi/swing/JFileChooserButton.java
historic/trunk/src/app/net/sf/japi/swing/JFileField.java
historic/trunk/src/app/net/sf/japi/swing/JSAXErrorHandler.java
historic/trunk/src/app/net/sf/japi/swing/LocaleListCellRenderer.java
historic/trunk/src/app/net/sf/japi/swing/Progress.java
historic/trunk/src/app/net/sf/japi/swing/ProgressDisplay.java
historic/trunk/src/app/net/sf/japi/swing/TipOfTheDayManager.java
historic/trunk/src/app/net/sf/japi/swing/ToolBarLayout.java
historic/trunk/src/app/net/sf/japi/swing/bookmarks/
historic/trunk/src/app/net/sf/japi/swing/font/
historic/trunk/src/app/net/sf/japi/swing/io/
historic/trunk/src/app/net/sf/japi/swing/prefs/
historic/trunk/src/app/net/sf/japi/swing/treetable/
historic/trunk/src/app/net/sf/japi/tools/Tool.java
historic/trunk/src/app/net/sf/japi/util/Arrays2.java
historic/trunk/src/app/net/sf/japi/util/Collections2.java
historic/trunk/src/app/net/sf/japi/util/EmptyEnumeration.java
historic/trunk/src/app/net/sf/japi/util/EmptyIterator.java
historic/trunk/src/app/net/sf/japi/util/EndianConverter.java
historic/trunk/src/app/net/sf/japi/util/EnumerationIterator.java
historic/trunk/src/app/net/sf/japi/util/IteratorEnumeration.java
historic/trunk/src/app/net/sf/japi/util/IteratorIterable.java
historic/trunk/src/app/net/sf/japi/util/NotNullIterator.java
historic/trunk/src/app/net/sf/japi/util/ThrowableHandler.java
historic/trunk/src/app/net/sf/japi/util/filter/
historic/trunk/src/test/net/sf/japi/lang/
historic/trunk/src/test/net/sf/japi/util/EnumerationIteratorTest.java
historic/trunk/src/test/net/sf/japi/util/NodeListIteratorTest.java
historic/trunk/src/test/net/sf/japi/util/UtilTest.java
Modified: historic/trunk/historic.iml
===================================================================
--- historic/trunk/historic.iml 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/historic.iml 2008-11-30 18:10:04 UTC (rev 729)
@@ -9,6 +9,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/doc/guide/swing/action/fromScratch/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/doc/guide/swing/prefs/keys/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/doc/guide/swing/tod/src" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" packagePrefix="test" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -17,6 +18,12 @@
<orderEntry type="module" module-name="libs-swing-action" />
<orderEntry type="module" module-name="libs-swing-keyprefs" />
<orderEntry type="module" module-name="libs-argparser" />
+ <orderEntry type="module" module-name="libs-util" />
+ <orderEntry type="module" module-name="libs-swing-tod" />
+ <orderEntry type="module" module-name="libs-swing-extlib" />
+ <orderEntry type="module" module-name="libs-swing-prefs" />
+ <orderEntry type="library" name="junit" level="project" />
+ <orderEntry type="module" module-name="libs-xml" />
<orderEntryProperties />
</component>
<component name="copyright">
Modified: historic/trunk/src/app/net/sf/japi/io/BCD.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/io/BCD.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/io/BCD.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -59,7 +59,7 @@
return bcd;
}
- /** Check wether a BCD value is correct.
+ /** Check whether a BCD value is correct.
* If the supplied value contains a nibble with a value >= 10, it will throw an IllegalArgumentException.
* Otherwise it will simply return.
* @param bcd number to check
@@ -72,7 +72,7 @@
}
}
- /** Check wether a BCD value is correct.
+ /** Check whether a BCD value is correct.
* @param bcd bcd value to check
* @return <code>true</code> if supplied value is bcd, otherwise <code>false</code>
*/
Modified: historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/sql/ResultSetTableModel.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -23,7 +23,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.table.TableModel;
-import net.sf.japi.util.ThrowableHandler;
+import net.sf.japi.util.ThrowableHandler;import org.jetbrains.annotations.Nullable;
/** Interface for TableModels which handle information from ResultSets.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
@@ -38,7 +38,7 @@
/** Get the ResultSet.
* @return ResultSet or <code>null</code> if there is no current result set
*/
- ResultSet getResultSet();
+ @Nullable ResultSet getResultSet();
/** Adds a ThrowableHandler to this model.
* @param throwableHandler ThrowableHandler to add
Modified: historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/sql/ScrollResultSetTableModel.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -88,7 +88,7 @@
}
/** {@inheritDoc} */
- public void setResultSet(final ResultSet resultSet) {
+ public void setResultSet(@Nullable final ResultSet resultSet) {
this.resultSet = resultSet;
updateResultSetData();
}
@@ -107,7 +107,7 @@
}
/** {@inheritDoc} */
- public ResultSet getResultSet() {
+ @Nullable public ResultSet getResultSet() {
return resultSet;
}
@@ -361,7 +361,7 @@
/** Get the meta data.
* @return meta data
*/
- public ResultSetMetaData getMetaData() {
+ @Nullable public ResultSetMetaData getMetaData() {
return metaData;
}
Deleted: historic/trunk/src/app/net/sf/japi/swing/ColumnLayout.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/ColumnLayout.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/ColumnLayout.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,168 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.awt.LayoutManager;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/** Layout similar to FlowLayout, but using columns (vertical layout) instead of rows (horizontal layout).
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-@SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext", "FieldAccessedSynchronizedAndUnsynchronized"})
-public class ColumnLayout implements LayoutManager {
-
- /** Horizontal Gap. */
- private int hgap = 4;
-
- /** Vertical Gap. */
- private int vgap = 4;
-
- /** Create a ColumnLayout with default gaps (4, 4). */
- public ColumnLayout() {
- }
-
- /** Create a ColumnLayout with defined gaps.
- * @param hgap horizontal gap
- * @param vgap vertical gap
- */
- public ColumnLayout(final int hgap, final int vgap) {
- this.hgap = hgap;
- this.vgap = vgap;
- }
-
- /** Returns horizontal Gap.
- * @return horizontal Gap.
- */
- public int getHgap() {
- return hgap;
- }
-
- /** Sets horizontal Gap.
- * @param hgap horizontal Gap.
- */
- public void setHgap(final int hgap) {
- this.hgap = hgap;
- }
-
- /** Returns vertical Gap.
- * @return vertical Gap.
- */
- public int getVgap() {
- return vgap;
- }
-
- /** Sets vertical Gap.
- * @param vgap vertical Gap.
- */
- public void setVgap(final int vgap) {
- this.vgap = vgap;
- }
-
- /** {@inheritDoc} */
- public void addLayoutComponent(@Nullable final String name, @Nullable final Component comp) {
- // Superfluous
- }
-
- /** {@inheritDoc} */
- public void removeLayoutComponent(@Nullable final Component comp) {
- // Superfluous
- }
-
- /** {@inheritDoc} */
- @NotNull public Dimension preferredLayoutSize(@NotNull final Container parent) {
- synchronized (parent.getTreeLock()) {
- final Dimension preferredLayoutSize = new Dimension();
- final int nmembers = parent.getComponentCount();
- for (int i = 0; i < nmembers; i++) {
- final Component comp = parent.getComponent(i);
- if (comp.isVisible()) {
- final Dimension dim = comp.getPreferredSize();
- preferredLayoutSize.width = Math.max(preferredLayoutSize.width, dim.width);
- if (i > 0) {
- preferredLayoutSize.height += vgap;
- }
- preferredLayoutSize.height += dim.height;
- }
- }
- final Insets insets = parent.getInsets();
- preferredLayoutSize.width += insets.left + insets.right + (hgap << 1);
- preferredLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
- return preferredLayoutSize;
- }
- }
-
- /** {@inheritDoc} */
- @NotNull public Dimension minimumLayoutSize(@NotNull final Container parent) {
- synchronized (parent.getTreeLock()) {
- final Dimension minimumLayoutSize = new Dimension();
- final int nmembers = parent.getComponentCount();
- for (int i = 0; i < nmembers; i++) {
- final Component comp = parent.getComponent(i);
- if (comp.isVisible()) {
- final Dimension dim = comp.getMinimumSize();
- minimumLayoutSize.width = Math.max(minimumLayoutSize.width, dim.width);
- if (i > 0) {
- minimumLayoutSize.height += vgap;
- }
- minimumLayoutSize.height += dim.height;
- }
- }
- final Insets insets = parent.getInsets();
- minimumLayoutSize.width += insets.left + insets.right + (hgap << 1);
- minimumLayoutSize.height += insets.top + insets.bottom + (vgap << 1);
- return minimumLayoutSize;
- }
- }
-
- /** {@inheritDoc} */
- public void layoutContainer(@NotNull final Container parent) {
- synchronized (parent.getTreeLock()) {
- final Insets insets = parent.getInsets();
- final int nmembers = parent.getComponentCount();
- final int maxheight = parent.getHeight() - (insets.left + insets.right + (vgap << 1));
- int maxwidth = 0;
- int y = 0;
- int x = insets.left + hgap;
- for (int i = 0; i < nmembers; i++) {
- final Component comp = parent.getComponent(i);
- if (comp.isVisible()) {
- final Dimension dim = comp.getPreferredSize();
- comp.setSize(dim);
- if (y + vgap + comp.getHeight() > maxheight) {
- y = 0;
- x += maxwidth + hgap;
- maxwidth = 0;
- }
- maxwidth = comp.getWidth() > maxwidth ? comp.getWidth() : maxwidth;
- y += vgap;
- comp.setLocation(x, y);
- y += comp.getHeight();
- }
- }
- }
- }
-
-} // class ColumnLayout
Deleted: historic/trunk/src/app/net/sf/japi/swing/IconManager.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/IconManager.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/IconManager.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,156 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import org.jetbrains.annotations.Nullable;
-
-/** Class to handle icons.
- * Default size is 16.
- * Instances must have an associated ClassLoader, otherwise several methods will not work properly but throw a NullPointerException instead.
- * So if you do not provide a ClassLoader, be sure the class you provide has one, or if you use the no-arg constructor resp. the default instance, be
- * sure the IconManager class itself was loaded with some ClassLoader other than <code>null</code>.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @todo this class should be refactored into a more generic version and accessible through ActionBuilder?
- * @todo it should be possible to initialize the paths through properties
- */
-public final class IconManager {
-
- /** The default IconManager. */
- private static final IconManager DEFAULT_ICON_MANAGER = createDefaultIconManager();
-
- /** Create the default IconManager.
- * @return default IconManager
- */
- private static IconManager createDefaultIconManager() {
- final IconManager defaultIconManager = new IconManager();
- defaultIconManager.iconPaths.add("icons/");
- defaultIconManager.iconPaths.add("toolbarButtonGraphics/");
- return defaultIconManager;
- }
-
- /** ClassLoader to get icons from, must not be null. */
- private final ClassLoader classLoader;
-
- /** The available sizes provided by this IconManager. */
- private final int[] availableSizes = { 16, 24 };
-
- /** The icon cache.
- * Key: short name for icon, which is likely to be used as a relative file name.
- * Value: Icon
- */
- private final Map<String,Icon> smallCache = new WeakHashMap<String,Icon>();
-
- /** The paths to search icons in. */
- private final List<String> iconPaths = new ArrayList<String>();
-
- /** Get the default IconManager.
- * The ClassLoader in use is the classloader IconManager was loaded with, whatever classloader that was.
- * @return default IconManaager
- */
- public static IconManager getDefaultIconManager() {
- return DEFAULT_ICON_MANAGER;
- }
-
- /** Create a IconManager.
- * Uses the IconManager's class loader.
- * Only use this if you want to be independent of the global icon size settings.
- * The recommended way to get a default IconManager instance is {#getDefaultIconManager()}.
- */
- public IconManager() {
- this(getContextClassLoader());
- //this(IconManager.class.getClassLoader());
- }
-
- private static ClassLoader getContextClassLoader() {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- try {
- return Thread.currentThread().getContextClassLoader();
- } catch (final SecurityException e) {
- return getClass().getClassLoader();
- }
- }
- });
- }
-
- /** Create an IconManager.
- * @param clazz Class to get ClassLoader for IconManager
- */
- public IconManager(final Class<?> clazz) {
- classLoader = clazz.getClassLoader();
- }
-
- /** Create an IconManager.
- * @param cl ClassLoader to create IconManager for
- */
- public IconManager(final ClassLoader cl) {
- classLoader = cl;
- }
-
- /** Return the available sizes for icons.
- * @return available icon sizes
- */
- public int[] getAvailableSizes() {
- return availableSizes.clone();
- }
-
- /** Load an icon.
- * @param s icon name, like "general/About" or "navigation/Forward"
- * @return Icon for <var>s</var>
- */
- @Nullable public Icon getIcon(final String s) {
- Icon icon = smallCache.get(s);
- if (icon == null) {
- URL url = null;
- // Search the configured class loader
- for (final Iterator<String> it = iconPaths.iterator(); url == null && it.hasNext();) {
- final String path = it.next();
- final String iconPath = path + (path.endsWith("/") ? "" : "/") + s + ".gif";
- url = classLoader.getResource(iconPath);
- }
- if (url == null) {
- // if searching the configured class loader failed, search the system class loader
- for (final Iterator<String> it = iconPaths.iterator(); url == null && it.hasNext();) {
- final String path = it.next();
- final String iconPath = path + (path.endsWith("/") ? "" : "/") + s + ".gif";
- url = ClassLoader.getSystemResource(iconPath);
- }
- }
- if (url == null) {
- return null;
- }
- icon = new ImageIcon(url);
- smallCache.put(s, icon);
- }
- return icon;
- }
-
-} // class IconManager
Deleted: historic/trunk/src/app/net/sf/japi/swing/JFileChooserButton.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/JFileChooserButton.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/JFileChooserButton.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,159 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.Insets;
-import java.io.File;
-import java.io.IOException;
-import javax.swing.JButton;
-import javax.swing.JFileChooser;
-import javax.swing.JTextField;
-
-/** JButton for choosing a file from hd.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public class JFileChooserButton extends JButton {
-
- /** Action Builder. */
- private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.japi.swing");
-
- /** The JTextField to read/write the file path to.
- * @serial include
- */
- private JTextField textField;
-
- /** The file selection mode.
- * @serial include
- */
- private int fileSelectionMode;
-
- /** The base directory for choosing files.
- * @serial include
- */
- private File base;
-
- /** The JFileChooser to use.
- * @serial include
- */
- private JFileChooser chooser;
-
- /** Create a ChooseButton.
- * A default chooser is used.
- * The current working directory is used as base directory.
- * @param textField JTextField to create button for
- * @param fileSelectionMode see {@link JFileChooser}
- */
- public JFileChooserButton(final JTextField textField, final int fileSelectionMode) {
- this(new File(System.getProperty("user.dir")), null, textField, fileSelectionMode);
- }
-
- /** Create a ChooseButton.
- * A default chooser is used.
- * @param base base directory to use
- * @param textField JTextField to create button for
- * @param fileSelectionMode see {@link JFileChooser}
- */
- public JFileChooserButton(final File base, final JTextField textField, final int fileSelectionMode) {
- this(base, null, textField, fileSelectionMode);
- }
-
- /** Create a ChooseButton.
- * A default chooser is used.
- * The current working directory is used as base directory.
- * @param chooser JFileChooser to associate with
- * @param textField JTextField to create button for
- * @param fileSelectionMode see {@link JFileChooser}
- */
- public JFileChooserButton(final JFileChooser chooser, final JTextField textField, final int fileSelectionMode) {
- this(new File(System.getProperty("user.dir")), chooser, textField, fileSelectionMode);
- }
-
- /** Create a ChooserButton.
- * @param base base directory to use
- * @param chooser JFileChooser to associate with
- * @param textField JTextField to create button for
- * @param fileSelectionMode see {@link JFileChooser}
- */
- public JFileChooserButton(final File base, final JFileChooser chooser, final JTextField textField, final int fileSelectionMode) {
- setAction(ACTION_BUILDER.createAction(false, "optionsChooseFile", this));
- this.textField = textField;
- this.fileSelectionMode = fileSelectionMode;
- setMargin(new Insets(0, 0, 0, 0));
- setChooser(chooser);
- setBase(base);
- }
-
- /** Set the JFileChooser associated with this JFileChooserButton.
- * @param chooser new JFileChooser to associate or <code>null</code> to instruct the button to create its own
- */
- public void setChooser(final JFileChooser chooser) {
- this.chooser = chooser != null ? chooser : new JFileChooser();
- }
-
- /** Set the base directory to choose files from.
- * This method always tries to convert the base file to canonical form.
- * If that fails, the base file is converted to absolute form instead.
- * @param base directory to choose files from
- */
- public void setBase(final File base) {
- try {
- this.base = base.getCanonicalFile();
- } catch (final IOException e) {
- this.base = base.getAbsoluteFile();
- }
- }
-
- /** Get the base directory to choose files from.
- * @return base directrory to which chosen files are resolved
- */
- public File getBase() {
- return base;
- }
-
- /** Get the JFileChooser associated with this JFileChooserButton.
- * @return associated JFileChooser
- */
- public JFileChooser getChooser() {
- return chooser;
- }
-
- /** Action method.
- * @used
- */
- public void optionsChooseFile() {
- final String oldFilename = textField.getText();
- final File oldFile = new File(base, oldFilename);
- chooser.setFileSelectionMode(fileSelectionMode);
- chooser.setMultiSelectionEnabled(false);
- if (oldFilename.length() > 0) {
- chooser.setCurrentDirectory(oldFile.getParentFile());
- chooser.setSelectedFile(oldFile);
- } else {
- chooser.setCurrentDirectory(base);
- chooser.setSelectedFile(null);
- }
- final int returnVal = chooser.showOpenDialog(this);
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- textField.setText(base.toURI().relativize(chooser.getSelectedFile().toURI()).toString());
- }
- }
-
-} // class JFileChooserButton
Deleted: historic/trunk/src/app/net/sf/japi/swing/JFileField.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/JFileField.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/JFileField.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,75 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.BorderLayout;
-import java.io.File;
-import javax.swing.JComponent;
-import javax.swing.JFileChooser;
-import javax.swing.JTextField;
-
-/** A class that displays a textfield for a file and a button for choosing the file.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public final class JFileField extends JComponent {
-
- /** The JTextField used to display the filename.
- * @serial include
- */
- private final JTextField textField;
-
- /** Create a FileField.
- * @param size Number of columns for the textfield part.
- */
- public JFileField(final int size) {
- textField = new JTextField(size);
- final JFileChooserButton button = new JFileChooserButton(textField, JFileChooser.FILES_ONLY);
- setLayout(new BorderLayout());
- add(textField, BorderLayout.CENTER);
- add(button, BorderLayout.LINE_END);
- }
-
- /** Create a FileField.
- * @param size Number of columns for the textfield part.
- */
- public JFileField(final JFileChooser fileChooser, final int size) {
- textField = new JTextField(size);
- final JFileChooserButton button = new JFileChooserButton(fileChooser, textField, JFileChooser.FILES_ONLY);
- setLayout(new BorderLayout());
- add(textField, BorderLayout.CENTER);
- add(button, BorderLayout.LINE_END);
- }
-
- /** Return the selected file.
- * @return selected file
- */
- public File getSelectedFile() {
- return new File(textField.getText());
- }
-
- /** Return the selected filename.
- * @return selected filename
- */
- public String getSelectedFilename() {
- return textField.getText();
- }
-
-} // class FileField
Deleted: historic/trunk/src/app/net/sf/japi/swing/JSAXErrorHandler.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/JSAXErrorHandler.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/JSAXErrorHandler.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,146 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.Component;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/** Implementation of {@link ErrorHandler} for displaying XML parser errors on the screen.
- * @warning DO NOT RELY ON THE INHERITANCE!
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public final class JSAXErrorHandler extends JOptionPane implements ErrorHandler {
-
- /** Action Builder. */
- private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.japi.swing");
-
- /** The JTextArea which displays the errors.
- * @serial include
- */
- private JTextArea errorPane = new JTextArea();
-
- /** The Dialog.
- * @serial include
- */
- private JDialog dialog;
-
- /** Parent component.
- * @serial include
- */
- private final Component parent;
-
- /** Button for closing.
- * @serial include
- */
- private JButton closeButton;
-
- /** Create a JSAXErrorHandler.
- * @param parent
- */
- public JSAXErrorHandler(final Component parent) {
- errorPane.setEditable(false);
- setMessage(new JScrollPane(errorPane));
- final JButton clearButton = new JButton(ACTION_BUILDER.createAction(false, "saxErrorClear", this));
- closeButton = new JButton(ACTION_BUILDER.createAction(false, "saxErrorClose", this));
- this.parent = parent;
- setOptions(new Object[] { closeButton, clearButton });
- }
-
- /** {@inheritDoc} */
- public void warning(final SAXParseException exception) throws SAXException {
- add("warning", exception);
- }
-
- /** {@inheritDoc} */
- public void error(final SAXParseException exception) throws SAXException {
- add("error", exception);
- }
-
- /** {@inheritDoc} */
- public void fatalError(final SAXParseException exception) throws SAXException {
- add("fatal", exception);
- }
-
- /** Add an exception.
- * @param level Error level
- * @param exception Exception
- */
- private void add(final String level, final SAXParseException exception) {
- final StringBuilder errorMsg = new StringBuilder();
- final int lineNumber = exception.getLineNumber();
- final int columnNumber = exception.getColumnNumber();
- errorMsg.append(exception.getSystemId());
- errorMsg.append(':');
- if (lineNumber != 0) {
- errorMsg.append(lineNumber);
- errorMsg.append(':');
- if (columnNumber != 0) {
- errorMsg.append(columnNumber);
- errorMsg.append(':');
- }
- }
- errorMsg.append(' ');
- errorMsg.append(level);
- errorMsg.append(": ");
- errorMsg.append(exception.getMessage());
- if (exception.getException() != null) {
- errorMsg.append(" (Cause: ");
- errorMsg.append(exception.getException().toString());
- errorMsg.append(')');
- }
- errorMsg.append('\n');
- errorPane.append(errorMsg.toString());
- showDialog();
- }
-
- /** Show the dialog. */
- private void showDialog() {
- if (dialog == null) {
- dialog = createDialog(parent, ACTION_BUILDER.getString("saxError_title"));
- closeButton.requestFocusInWindow();
- dialog.getRootPane().setDefaultButton(closeButton);
- dialog.setModal(false);
- dialog.setResizable(true);
- dialog.setVisible(true);
- }
- }
-
- /** Action method for clearing. */
- public void saxErrorClear() {
- errorPane.setText("");
- }
-
- /** Action method for closing. */
- public void saxErrorClose() {
- setValue(closeButton);
- dialog.setVisible(false);
- dialog.dispose();
- dialog = null;
- }
-
-} // class JSAXErrorHandler
Deleted: historic/trunk/src/app/net/sf/japi/swing/LocaleListCellRenderer.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/LocaleListCellRenderer.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/LocaleListCellRenderer.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,44 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.Component;
-import java.util.Locale;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-
-/** Implementation of a ListCellRenderer that renders lists of {@link Locale} instances according to their names in the current default locale.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public final class LocaleListCellRenderer extends DefaultListCellRenderer {
-
- /** Serial Version UID. */
- private static final long serialVersionUID = 1L;
-
- /** {@inheritDoc} */
- @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) {
- final JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- label.setText(value == null ? "Default" : ((Locale) value).getDisplayName());
- return label;
- }
-
-} // class LocaleRenderer
Deleted: historic/trunk/src/app/net/sf/japi/swing/Progress.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/Progress.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/Progress.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,50 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.Component;
-
-/** Interface for classes that are able to display progress.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public interface Progress {
-
- /** Progress has finished. */
- void finished();
-
- /** Get the Component that is responsible for rendering the progress.
- * This is useful if it is neccessary to open dialogs during the progress.
- * @return Component responsible for rendering the progress
- */
- Component getParentComponent();
-
- /** Set progress information text.
- * @param msg progress information text
- * @param max maximum progress value
- */
- void setLabel(String msg, int max);
-
- /** Set progress value.
- * @param value progress value
- */
- void setValue(int value);
-
-} // interface Progress
Deleted: historic/trunk/src/app/net/sf/japi/swing/ProgressDisplay.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/ProgressDisplay.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/ProgressDisplay.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,109 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.BorderLayout;
-import static java.awt.Color.BLACK;
-import java.awt.Component;
-import java.awt.GridLayout;
-import static javax.swing.BorderFactory.createEmptyBorder;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JProgressBar;
-import static javax.swing.SwingConstants.CENTER;
-
-/** ProgressDisplay handles a popup dialog for the mainview
- * which displays a process progressBar.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- */
-public final class ProgressDisplay extends JDialog implements Progress {
-
- /** Serial Version UID. */
- private static final long serialVersionUID = 1L;
-
- /** The progress progressBar.
- * @serial include
- */
- private final JProgressBar progressBar; // the progress progressBar
-
- /** The text label.
- * @serial include
- */
- private final JLabel label;
-
- /** Create a ProgressDisplay.
- * @param parent Frame to display dialog on
- * @param title Title string for progress dialog
- * @param max initial maximum of progress points
- * @param text the initial label text
- */
- public ProgressDisplay(final JFrame parent, final String title, final int max, final String text) {
- super(parent, title, false);
- setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // can't close
-
- final JPanel panel = new JPanel(new GridLayout(2, 1));
- panel.setBorder(createEmptyBorder(20, 15, 30, 15));
- label = new JLabel(text);
- label.setForeground(BLACK);
- panel.add(label);
-
- progressBar = new JProgressBar(0, max);
- progressBar.setValue(0);
- progressBar.setStringPainted(true);
- progressBar.setAlignmentY(CENTER);
- panel.add(progressBar);
-
- getContentPane().setLayout(new BorderLayout());
- getContentPane().add(panel);
- setSize(300, 140);
- setLocationRelativeTo(parent);
-
- setVisible(true);
- }
-
- /** {@inheritDoc} */
- public void finished() {
- setVisible(false);
- removeAll();
- dispose();
- }
-
- /** {@inheritDoc} */
- public void setValue(final int value) {
- final int max = progressBar.getMaximum();
- progressBar.setValue(value > max ? max : value);
- }
-
- /** {@inheritDoc} */
- public void setLabel(final String msg, final int max) {
- label.setText(msg);
- progressBar.setMaximum(max);
- progressBar.setValue(0);
- }
-
- /** {@inheritDoc} */
- public Component getParentComponent() {
- return this;
- }
-
-} // class ProgressDisplay
Deleted: historic/trunk/src/app/net/sf/japi/swing/TipOfTheDayManager.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/TipOfTheDayManager.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/TipOfTheDayManager.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,331 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.MissingResourceException;
-import java.util.Random;
-import java.util.ResourceBundle;
-import static java.util.ResourceBundle.getBundle;
-import java.util.prefs.Preferences;
-import static java.util.prefs.Preferences.userNodeForPackage;
-import javax.swing.Action;
-import static javax.swing.Action.ACCELERATOR_KEY;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JDialog;
-import javax.swing.JEditorPane;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JScrollPane;
-import javax.swing.KeyStroke;
-import static javax.swing.SwingConstants.TRAILING;
-import static net.sf.japi.swing.ActionBuilder.ACCELERATOR_KEY_2;
-import static net.sf.japi.swing.IconManager.getDefaultIconManager;
-import org.jetbrains.annotations.Nullable;
-
-/** Class that manages tips of the day.
- * The tips of the day are read from a property file.
- * The name of the property file is tried to retrieve in exactly the following order:
- * <ol>
- * <li>The System Property <code>net.sf.japi.swing.tod</code> is queried and taken as a ResourceBundle base name.</li>
- * <li>The Service file <code>META-INF/services/net.sf.japi.swing.tod</code> is read and its first line taken as a ResourceBundle base name.</li>
- * </ol>
- * If both fails, the behaviour is undefined.
- * <p/>
- * Setting the ResourceBundle for the TipOfTheDayManager via services is the preferred way, because you do not need any additional coding apart from
- * invoking the TipOfTheDayManager somewhere at startup.
- * <p />
- * The format of that property file follows the normal Java Properties convention, with the property keys being numbered, starting at "tod.text.1".
- * Example:
- * <pre># Tip Of The Days, English Version
- * tod.text.1=<html>For analysis with other tools you can export the symbol map to XML, MS-Excel and CSV.
- * tod.text.2=<html>For analysis with other tools you can export the mapping map to XML, MS-Excel and CSV.
- * tod.text.3=<html>The supported map file formats are: Intel, GCC and MSVC.
- * </pre>
- * @fixme The preferences properties lastTipOfTheDayNumber and showTipOfTheDayAtStartup are stored in the wrong package, they must be stored in the client package instead of this package
- * @todo Allow parametrization of properties, e.g. via a String sequence like <code>${property.name}</code>, which should then be looked up using
- * a defined scheme from one or perhaps more definable {@link ActionBuilder ActionBuilders}.
- * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
- * @serial exclude
- */
-public final class TipOfTheDayManager extends JOptionPane {
-
- /** Action Builder. */
- private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.japi.swing");
-
- /** Random number generator for random tods. */
- private static final Random RND = new Random();
-
- /** Preferences. */
- private static final Preferences PREFS = userNodeForPackage(TipOfTheDayManager.class);
-
- /** The Action keys used for accelerators. */
- private static final String[] ACCELERATOR_KEYS = new String[] { ACCELERATOR_KEY, ACCELERATOR_KEY_2 };
-
- /** The static instance. */
- private static final TipOfTheDayManager INSTANCE = new TipOfTheDayManager();
-
- /** JButton for close. */
- private JButton closeButton;
-
- /** JDialog. */
- private JDialog dialog;
-
- /** JCheckBox for showing at startup. */
- private JCheckBox showAtStartup = new JCheckBox(ACTION_BUILDER.createAction(false, "todShowAtStartup", null));
-
- /** The JLabel showing the current number of the tod. */
- private JLabel currentTodIndex = new JLabel();
-
- /** The JEditorPane displaying the tod text. */
- private JEditorPane todText = new JEditorPane("text/html", "");
-
- /** List with tod texts. */
- private List<String> todTexts = new ArrayList<String>();
-
- /** Number of current Tip of the day.
- * In visible state, the index must range between 0 and the number of tods available - 1, inclusive.
- */
- private int todIndex;
-
- /** Show Tip Of The Day at startup.
- * This method is only a proxy for show(Component) but looks at user preferences.
- * If the user chose not to see TipOfTheDays this method simply returns.
- * @param parentComponent the parent component of this dialog.
- */
- public static void showAtStartup(final Component parentComponent) {
- if (PREFS.getBoolean("showTipOfTheDayAtStartup", true)) {
- show(parentComponent);
- }
- }
-
- /** Show a Tip Of The Day.
- * @param parentComponent the parent component of this dialog.
- */
- public static void show(final Component parentComponent) {
- if (INSTANCE.dialog == null) {
- INSTANCE.dialog = INSTANCE.createDialog(parentComponent, ACTION_BUILDER.getString("tipOfTheDay.windowTitle"));
- }
- INSTANCE.dialog.getRootPane().setDefaultButton(INSTANCE.closeButton);
- INSTANCE.dialog.setModal(false);
- INSTANCE.dialog.setResizable(true);
- INSTANCE.dialog.setVisible(true);
- INSTANCE.closeButton.requestFocusInWindow();
- }
-
- /** Finds the bundle name.
- * @return bundle name
- */
- private static String getBundleName() {
- String bundleName = System.getProperty("net.sf.japi.swing.tod");
- if (bundleName == null) {
- bundleName = getServiceValue(getClassLoader());
- }
- return bundleName;
- }
-
- /** This method attempts to return the first line of the resource META_INF/services/net.sf.japi.swing.tod from the provided ClassLoader.
- * @param classLoader ClassLoader, may not be <code>null</code>.
- * @return first line of resource, or <code>null</code>
- */
- @Nullable private static String getServiceValue(final ClassLoader classLoader) {
- BufferedReader rd = null;
- try {
- final String serviceId = "META-INF/services/net.sf.japi.swing.tod";
- final InputStream in = getResourceAsStream(classLoader, serviceId);
- if (in != null) {
- try {
- rd = new BufferedReader(new InputStreamReader(in, "UTF-8"));
- } catch (final UnsupportedEncodingException e) {
- rd = new BufferedReader(new InputStreamReader(in));
- }
- return rd.readLine();
- }
- } catch (final Exception e) {
- /* ignore. */
- } finally {
- try { rd.close(); } catch (final Exception e) { /* ignore */ } finally { rd = null; }
- }
- return null;
- }
-
- /** Get a resource from a classloader as stream.
- * @param classLoader ClassLoader to get resource from
- * @param serviceId service file to get stream from
- * @return stream for resource <var>serviceId</var> in <var>classLoader</var>
- */
- private static InputStream getResourceAsStream(final ClassLoader classLoader, final String serviceId) {
- return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
-
- /** {@inheritDoc} */
- public InputStream run() {
- return classLoader == null ?
- ClassLoader.getSystemResourceAsStream(serviceId) :
- classLoader.getResourceAsStream(serviceId);
- }
-
- });
- }
-
- /** Get the ClassLoader.
- * @return ClassLoader
- */
- private static ClassLoader getClassLoader() {
- try {
- final ClassLoader contextClassLoader = getContextClassLoader();
- if (contextClassLoader != null) {
- return contextClassLoader;
- }
- } catch (final Exception e) {
- /* ignore */
- }
- return TipOfTheDayManager.class.getClassLoader();
- }
-
- /** Get the context ClassLoader.
- * @return context ClassLoader
- */
- private static ClassLoader getContextClassLoader() {
- return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
-
- /** {@inheritDoc} */
- @Nullable public ClassLoader run() {
- try {
- return Thread.currentThread().getContextClassLoader();
- } catch (final SecurityException ex) {
- return null;
- }
- }
-
- });
- }
-
- /** Constructor. */
- private TipOfTheDayManager() {
- final String[] keys = { "todPrev", "todRand", "todNext", "todClose" };
- final Action[] actions = new Action[keys.length];
- final Object[] newOptions = new Object[keys.length];
- for (int i = 0; i < keys.length; i++) {
- actions[i] = ACTION_BUILDER.createAction(false, keys[i], this);
- newOptions[i] = new JButton(actions[i]);
- if ("todClose".equals(keys[i])) {
- closeButton = (JButton) newOptions[i];
- }
- for (final String key : ACCELERATOR_KEYS) {
- final KeyStroke ks = (KeyStroke) actions[i].getValue(key);
- if (ks != null) {
- getInputMap(WHEN_IN_FOCUSED_WINDOW).put(ks, keys[i]);
- getActionMap().put(keys[i], actions[i]);
- }
- }
- }
- final Dimension size = new Dimension(512, 128);
- showAtStartup.setSelected(PREFS.getBoolean("showTipOfTheDayAtStartup", true));
- final JScrollPane todTextScroller = new JScrollPane(todText);
- todTextScroller.setMinimumSize(size);
- todTextScroller.setPreferredSize(size);
- todTextScroller.setFocusable(true);
- todTextScroller.setAutoscrolls(true);
- todText.setEditable(false);
- todText.setRequestFocusEnabled(false);
- currentTodIndex.setHorizontalAlignment(TRAILING);
- loadTodTexts();
- setTodIndex(PREFS.getInt("lastTipOfTheDayNumber", -1) + 1);
- setIcon(getDefaultIconManager().getIcon(ACTION_BUILDER.getString("tipOfTheDay.icon")));
- final JLabel heading = new JLabel(ACTION_BUILDER.getString("todHeading"));
- final Font oldFont = heading.getFont();
- heading.setFont(oldFont.deriveFont((float) (oldFont.getSize2D() * 1.5)));
- setMessage(new Object[] { heading, todTextScroller, currentTodIndex, showAtStartup });
- setMessageType(INFORMATION_MESSAGE);
- setOptions(newOptions);
- }
-
- /** Loads the Tip of the day texts. */
- private void loadTodTexts() {
- final ResourceBundle todBundle = getBundle(getBundleName());
- for (int i = 1;; i++) {
- try {
- todTexts.add(todBundle.getString(new StringBuilder().append("tod.text.").append(i).toString()));
- } catch (final MissingResourceException e) {
- break;
- }
- }
- }
-
- /** Sets the tod index.
- * @param todIndex new todIndex
- */
- private void setTodIndex(final int todIndex) {
- try {
- this.todIndex = (todIndex + todTexts.size()) % todTexts.size();
- todText.setText(todTexts.get(this.todIndex));
- currentTodIndex.setText(ACTION_BUILDER.format("todIndex", this.todIndex + 1, todTexts.size()));
- } catch (final ArithmeticException e) {
- todText.setText(ACTION_BUILDER.getString("todsUnavailable"));
- currentTodIndex.setText("");
- }
- }
-
- /** Returns number of current Tip of the day.
- * In visible state, the index must range between 0 and the number of tods available - 1, inclusive.
- * @return number of current Tip of the day.
- */
- public int getTodIndex() {
- return todIndex;
- }
-
- /** Action method for close. */
- public void todClose() {
- setValue(closeButton);
- PREFS.putBoolean("showTipOfTheDayAtStartup", showAtStartup.isSelected());
- PREFS.putInt("lastTipOfTheDayNumber", todIndex);
- dialog.setVisible(false);
- dialog.dispose();
- dialog = null;
- }
-
- /** Action method for next. */
- public void todNext() {
- setTodIndex(todIndex + 1);
- }
-
- /** Action method for previous. */
- public void todPrev() {
- setTodIndex(todIndex - 1);
- }
-
- /** Action method for random. */
- public void todRand() {
- setTodIndex(RND.nextInt(todTexts.size()));
- }
-
-} // class TipOfTheDayManager
Deleted: historic/trunk/src/app/net/sf/japi/swing/ToolBarLayout.java
===================================================================
--- historic/trunk/src/app/net/sf/japi/swing/ToolBarLayout.java 2008-11-30 18:04:35 UTC (rev 728)
+++ historic/trunk/src/app/net/sf/japi/swing/ToolBarLayout.java 2008-11-30 18:10:04 UTC (rev 729)
@@ -1,423 +0,0 @@
-/* JAPI - (Yet another (hopefully) useful) Java API
- *
- * Copyright (C) 2004-2006 Christian Hujer
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-package net.sf.japi.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Insets;
-import java.io.Serializable;
-import static java.lang.Math.max;
-import java.util.ArrayList;
-import java.util.List;
-import javax.swing.JToolBar;
-
-/** A LayoutManager that manages a layout of a {@link Container} similar to {@link BorderLayout} but with an important difference, it is possible to
- * add as many components to a side layout region as you want. The desired purpose is to serve as LayoutManager for containers that shall contain
- * toolbars. So this is a LayoutManager you always were looking for.
- * <p />
- * Technically, this class is not a 100% replacement for {@link BorderLayout}. {@link JToolBar}'s UI ({@link
- * javax.swing.plaf.basic.BasicToolBarUI}) directly looks for some features of the class {@link BorderLayout}, and if it is not {@link BorderLayout},
- * it uses some defaults.
- * This class has been developed to make these defaults work as good as possible.
- * Though this class doesn't technically replace {@link BorderLayout} - neither is this class a subclass of {@link BorderLayout} nor does it provide
- * <em>all</em> methods {@link BorderLayout} does - it still does practically.
- * <p />
- * The constant values {@link #NORTH}, {@link #SOUTH}, {@link #EAST}, {@link #WEST} and {@link #CENTER} are references to those of {@link
- * BorderLayout}.
- * The behaviour of {@link #CENTER} is that of {@link BorderLayout}: only one component can be added, subsequently added components overried all
- * previously added.
- * <p />
- * The behaviour of {@link #NORTH}, {@link #SOUTH}, {@link #EAST} and {@link #WEST} differs from {@link BorderLayout}. The position and layout
- * behaviour is the same, with the slight difference that this LayoutManager is able to manage more than on single component in these four regions.
- * Subsequently added components are placed from the outer to the inner. The first added component is the outmost component of that region, the last
- * added component is the innermost component of that region. To place a component to the innermost level, simply add it to the same region again.
- * <p />
- * Placing a component another level than the innermost of its destination region i...
[truncated message content] |