Thread: [Japi-cvs] SF.net SVN: japi: [14] trunk/src/app/net/sf/japi/swing
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-04-05 21:30:15
|
Revision: 14 Author: christianhujer Date: 2006-04-05 14:29:55 -0700 (Wed, 05 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=14&view=rev Log Message: ----------- Improved ActionFactory to allow additional bundles specified in a bundle. Modified Paths: -------------- trunk/src/app/net/sf/japi/swing/ActionFactory.java trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties trunk/src/doc/guide/swing/action/fromScratch/start.xhtml Added Paths: ----------- trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties Modified: trunk/src/app/net/sf/japi/swing/ActionFactory.java =================================================================== --- trunk/src/app/net/sf/japi/swing/ActionFactory.java 2006-04-05 20:13:38 UTC (rev 13) +++ trunk/src/app/net/sf/japi/swing/ActionFactory.java 2006-04-05 21:29:55 UTC (rev 14) @@ -22,8 +22,9 @@ import java.awt.Component; import java.awt.event.ActionEvent; +import java.lang.reflect.Field; import java.text.MessageFormat; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.MissingResourceException; @@ -32,7 +33,7 @@ import java.util.WeakHashMap; import java.util.prefs.Preferences; import static java.util.prefs.Preferences.userNodeForPackage; -import java.lang.reflect.Field; +import javax.swing.AbstractAction; import javax.swing.Action; import static javax.swing.Action.ACCELERATOR_KEY; import static javax.swing.Action.LONG_DESCRIPTION; @@ -43,17 +44,16 @@ import javax.swing.ActionMap; import javax.swing.Icon; import javax.swing.JCheckBox; +import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JToolBar; -import javax.swing.AbstractAction; -import javax.swing.JLabel; import static javax.swing.KeyStroke.getKeyStroke; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.NonNls; import static net.sf.japi.swing.IconManager.getDefaultIconManager; import static net.sf.japi.swing.ReflectionAction.REFLECTION_MESSAGE_PROVIDER; import static net.sf.japi.swing.ReflectionAction.REFLECTION_TARGET; @@ -172,17 +172,17 @@ @NotNull private static final Map<String, ActionFactory> FACTORIES = new WeakHashMap<String, ActionFactory>(); /** The parent ActionFactories. */ - @NotNull private final List<ActionFactory> parents = new ArrayList<ActionFactory>(); + @NotNull private final List<ActionFactory> parents = new LinkedList<ActionFactory>(); /** The ResourceBundles to look for. * Type: ResourceBundle */ - @NotNull private final List<ResourceBundle> bundles = new ArrayList<ResourceBundle>(); + @NotNull private final List<ResourceBundle> bundles = new LinkedList<ResourceBundle>(); /** The Preferences to look for. * Type: Preferences */ - @NotNull private final List<Preferences> prefs = new ArrayList<Preferences>(); + @NotNull private final List<Preferences> prefs = new LinkedList<Preferences>(); /** The ActionMap to which created Actions are automatically added. */ @NotNull private final ActionMap actionMap = new NamedActionMap(); @@ -221,7 +221,14 @@ if (baseName == null) { throw new NullPointerException("null bundle name not allowed"); } - addBundle(getBundle(baseName)); + @NotNull final ResourceBundle newBundle = getBundle(baseName); + addBundle(newBundle); + @Nullable final String additionalBundles = newBundle.getString("ActionFactory.additionalBundles"); + if (additionalBundles != null) { + for (final String additionalBundle : additionalBundles.split("\\s+")) { + addBundle(additionalBundle); + } + } } /** Method to find the JMenuItem for a specific Action. @@ -300,7 +307,8 @@ throw new NullPointerException("null ResourceBundle not allowed"); } if (!bundles.contains(bundle)) { - bundles.add(bundle); + // insert first because new bundles override old bundles + bundles.add(0, bundle); } } Modified: trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties =================================================================== --- trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties 2006-04-05 20:13:38 UTC (rev 13) +++ trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties 2006-04-05 21:29:55 UTC (rev 14) @@ -1,51 +1,6 @@ -frame.title=Text Editor (JAPI usage example) +ActionFactory.additionalBundles=net.sf.japi.examples.editor.messages editor.menubar=file editor.toolbar=fileNew fileOpen fileSave fileSaveAs file.menu=fileNew fileOpen fileSave fileSaveAs fileQuit -file.text=File -file.mnemonic=F - -fileNew.text=New -fileNew.mnemonic=N -fileNew.accel=ctrl pressed N -fileNew.shortdescription=Creates a new empty text document. -fileNew.icon=general/New16 - -fileOpen.text=Open... -fileOpen.mnemonic=O -fileOpen.accel=ctrl pressed O -fileOpen.shortdescription=Opens an existing text document. -fileOpen.icon=general/Open16 -fileOpen.exception.java.io.FileNotFoundException.title=File not found -fileOpen.exception.java.io.FileNotFoundException.message=<html>The file couldn''t be opened. Reason:<br>{0} -fileOpen.exception.java.io.FileNotFoundException.messagetype=ERROR_MESSAGE -fileOpen.exception.java.io.IOException.title=I/O error -fileOpen.exception.java.io.IOException.message=<html>I/O error while reading. Reason:<br>{0} -fileOpen.exception.java.io.IOException.messagetype=ERROR_MESSAGE - - -fileSave.text=Save -fileSave.mnemonic=S -fileSave.accel=ctrl pressed S -fileSave.shortdescription=Saves the current document. -fileSave.icon=general/Save16 -fileSave.exception.java.io.IOException.title=I/O error -fileSave.exception.java.io.IOException.message=<html>I/O error while writing. Reason:<br>{0} - -fileSaveAs.text=Save As... -fileSaveAs.mnemonic=A -fileSaveAs.accel=ctrl shift pressed S -fileSaveAs.shortdescription=Saves the current document in a new filename. -fileSaveAs.icon=general/SaveAs16 -fileSaveAs.exception.java.io.IOException.title=I/O error -fileSaveAs.exception.java.io.IOException.message=<html>I/O error while writing. Reason:<br>{0} - -fileQuit.text=Quit -fileQuit.mnemonic=Q -fileQuit.accel=ctrl pressed Q -fileQuit.shortdescription=Quits the text editor. - -reallyQuit.title=Really Quit? -reallyQuit=Do you really want to quit the editor? Added: trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties =================================================================== --- trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties (rev 0) +++ trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties 2006-04-05 21:29:55 UTC (rev 14) @@ -0,0 +1,48 @@ +frame.title=Text Editor (JAPI usage example) + +file.text=File +file.mnemonic=F + +fileNew.text=New +fileNew.mnemonic=N +fileNew.accel=ctrl pressed N +fileNew.shortdescription=Creates a new empty text document. +fileNew.icon=general/New16 + +fileOpen.text=Open... +fileOpen.mnemonic=O +fileOpen.accel=ctrl pressed O +fileOpen.shortdescription=Opens an existing text document. +fileOpen.icon=general/Open16 +fileOpen.exception.java.io.FileNotFoundException.title=File not found +fileOpen.exception.java.io.FileNotFoundException.message=<html>The file couldn''t be opened. Reason:<br>{0} +fileOpen.exception.java.io.FileNotFoundException.messagetype=ERROR_MESSAGE +fileOpen.exception.java.io.IOException.title=I/O error +fileOpen.exception.java.io.IOException.message=<html>I/O error while reading. Reason:<br>{0} +fileOpen.exception.java.io.IOException.messagetype=ERROR_MESSAGE + + +fileSave.text=Save +fileSave.mnemonic=S +fileSave.accel=ctrl pressed S +fileSave.shortdescription=Saves the current document. +fileSave.icon=general/Save16 +fileSave.exception.java.io.IOException.title=I/O error +fileSave.exception.java.io.IOException.message=<html>I/O error while writing. Reason:<br>{0} + +fileSaveAs.text=Save As... +fileSaveAs.mnemonic=A +fileSaveAs.accel=ctrl shift pressed S +fileSaveAs.shortdescription=Saves the current document in a new filename. +fileSaveAs.icon=general/SaveAs16 +fileSaveAs.exception.java.io.IOException.title=I/O error +fileSaveAs.exception.java.io.IOException.message=<html>I/O error while writing. Reason:<br>{0} + +fileQuit.text=Quit +fileQuit.mnemonic=Q +fileQuit.accel=ctrl pressed Q +fileQuit.shortdescription=Quits the text editor. + +reallyQuit.title=Really Quit? +reallyQuit=Do you really want to quit the editor? + Property changes on: trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/doc/guide/swing/action/fromScratch/start.xhtml =================================================================== --- trunk/src/doc/guide/swing/action/fromScratch/start.xhtml 2006-04-05 20:13:38 UTC (rev 13) +++ trunk/src/doc/guide/swing/action/fromScratch/start.xhtml 2006-04-05 21:29:55 UTC (rev 14) @@ -214,7 +214,11 @@ } }</pre> <h2>Complete source</h2> + <h3>Java Source: <code>net/sf/japi/examples/editor/Editor.java</code></h3> <pre class="listing"><xi:include href="src/net/sf/japi/examples/editor/Editor.java.xhtml" xpointer="/1/2/1/1" /></pre> + <h3>Action Properties: <code>net/sf/japi/examples/editor/action.properties</code></h3> <pre class="listing"><xi:include href="src/net/sf/japi/examples/editor/action.properties" parse="text" /></pre> + <h3>Message Properties: <code>net/sf/japi/examples/editor/message.properties</code></h3> + <pre class="listing"><xi:include href="src/net/sf/japi/examples/editor/message.properties" parse="text" /></pre> </body> </html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-04-05 23:39:29
|
Revision: 16 Author: christianhujer Date: 2006-04-05 16:39:02 -0700 (Wed, 05 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=16&view=rev Log Message: ----------- Added automatic handling of custom Action types to ActionFactory. Improved Editor example to use editorkit actions and provide an edit menu. Modified Paths: -------------- trunk/src/app/net/sf/japi/swing/ActionFactory.java trunk/src/app/net/sf/japi/swing/ReflectionAction.java trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/Editor.java trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties Added Paths: ----------- trunk/src/app/net/sf/japi/swing/ActionProvider.java Modified: trunk/src/app/net/sf/japi/swing/ActionFactory.java =================================================================== --- trunk/src/app/net/sf/japi/swing/ActionFactory.java 2006-04-05 21:53:34 UTC (rev 15) +++ trunk/src/app/net/sf/japi/swing/ActionFactory.java 2006-04-05 23:39:02 UTC (rev 16) @@ -31,6 +31,7 @@ import java.util.ResourceBundle; import static java.util.ResourceBundle.getBundle; import java.util.WeakHashMap; +import java.util.ArrayList; import java.util.prefs.Preferences; import static java.util.prefs.Preferences.userNodeForPackage; import javax.swing.AbstractAction; @@ -187,6 +188,8 @@ /** The ActionMap to which created Actions are automatically added. */ @NotNull private final ActionMap actionMap = new NamedActionMap(); + private List<ActionProvider> actionProviders = new ArrayList<ActionProvider>(); + /** Get an ActionFactory. * If there is no ActionFactory with name <var>key</var>, a new ActionFactory is created and stored. * Future invocations of this method will constantly return that ActionFactory unless the key is garbage collected. @@ -536,7 +539,17 @@ * This method does the same as <code>getActionMap().get(key)</code>. */ public Action getAction(final String key) { - return actionMap.get(key); + Action action = actionMap.get(key); + if (action == null) { + for (final ActionProvider actionProvider : actionProviders) { + action = actionProvider.getAction(key); + if (action != null) { + actionMap.put(key, action); + break; + } + } + } + return action; } /** Method for creating a menubar. @@ -723,7 +736,11 @@ if (key == null || "-".equals(key)) { toolBar.addSeparator(); } else { - toolBar.add(createAction(false, key, object)); + Action action = getAction(key); + if (action == null) { + action = createAction(false, key, object); + } + toolBar.add(action); } } return toolBar; @@ -949,4 +966,11 @@ return label; } + /** Registers an ActionProvider with this ActionFactory. + * @param actionProvider ActionProvider to register + */ + public void addActionProvider(final ActionProvider actionProvider) { + actionProviders.add(actionProvider); + } + } // class ActionFactory Added: trunk/src/app/net/sf/japi/swing/ActionProvider.java =================================================================== --- trunk/src/app/net/sf/japi/swing/ActionProvider.java (rev 0) +++ trunk/src/app/net/sf/japi/swing/ActionProvider.java 2006-04-05 23:39:02 UTC (rev 16) @@ -0,0 +1,38 @@ +/* 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 javax.swing.Action; +import org.jetbrains.annotations.Nullable; + +/** Interface for classes that provide actions. + * @author <a href="mailto:ch...@it...">Christian Hujer</a> + */ +public interface ActionProvider { + + /** Get an action that matches a specific key or <code>null</code> if no such action was found. + * @param key Key to find + * @return Action for <var>key</var> or <code>null</code> + */ + @Nullable Action getAction(final String key); + +} // interface ActionProvider Property changes on: trunk/src/app/net/sf/japi/swing/ActionProvider.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/japi/swing/ReflectionAction.java =================================================================== --- trunk/src/app/net/sf/japi/swing/ReflectionAction.java 2006-04-05 21:53:34 UTC (rev 15) +++ trunk/src/app/net/sf/japi/swing/ReflectionAction.java 2006-04-05 23:39:02 UTC (rev 16) @@ -48,6 +48,7 @@ * Note that because of Reflection this Action is slightly slower than implementing your own Action instance, but in most cases this really does not matter at all. * Usually you won't use ReflectionAction yourself. Instead you'll let {@link ActionFactory} create an instance for you. * @author <a href="mailto:Chr...@it...">Christian Hujer</a> + * @todo ReflectionAction should be able to invoke methods with parameters, three variants: Object..., ActionEvent or void */ public final class ReflectionAction extends AbstractAction { @@ -181,7 +182,8 @@ return null; } try { - method = instance.getClass().getMethod(methodName); + final Class<? extends Object> clazz = instance.getClass(); + method = clazz.getMethod(methodName); putValue(REFLECTION_METHOD, method); } catch (final NoSuchMethodException ex) { assert false : "Action Method not found: " + ex; Modified: trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/Editor.java =================================================================== --- trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/Editor.java 2006-04-05 21:53:34 UTC (rev 15) +++ trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/Editor.java 2006-04-05 23:39:02 UTC (rev 16) @@ -6,21 +6,37 @@ import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; +import java.util.Map; +import java.util.HashMap; +import javax.swing.Action; import javax.swing.JFileChooser; import static javax.swing.JFileChooser.APPROVE_OPTION; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextPane; import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; +import javax.swing.text.DefaultEditorKit; +import org.jetbrains.annotations.Nullable; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.ActionMethod; +import net.sf.japi.swing.ActionProvider; -public class Editor { +public class Editor implements ActionProvider { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("net.sf.japi.examples.editor"); + /** The supported editor action names and their corresponding kit action names. */ + private static final Map<String, String> editorActionNames = new HashMap<String, String>(); + static { + + editorActionNames.put("editCut", DefaultEditorKit.cutAction); + editorActionNames.put("editCopy", DefaultEditorKit.copyAction); + editorActionNames.put("editPaste", DefaultEditorKit.pasteAction); + editorActionNames.put("editSelectAll", DefaultEditorKit.selectAllAction); + }; + /** Application frame. */ private JFrame frame = new JFrame(ACTION_FACTORY.getString("frame.title")); @@ -37,14 +53,27 @@ /** Create the Editor. */ public Editor() { + ACTION_FACTORY.addActionProvider(this); frame.setJMenuBar(ACTION_FACTORY.createMenuBar(true, "editor", this)); frame.add(ACTION_FACTORY.createToolBar(this, "editor"), NORTH); frame.add(new JScrollPane(textPane)); + frame.pack(); frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - frame.pack(); frame.setVisible(true); } + /** {@inheritDoc} */ + @Nullable public Action getAction(final String key) { + for (final Action action : textPane.getActions()) { + final String realKey = editorActionNames.get(key); + if (realKey != null && realKey.equals(action.getValue(Action.NAME))) { + ACTION_FACTORY.initAction(true, action, key); + return action; + } + } + return null; + } + /** Action method. * @used */ Modified: trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties =================================================================== --- trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties 2006-04-05 21:53:34 UTC (rev 15) +++ trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/action.properties 2006-04-05 23:39:02 UTC (rev 16) @@ -1,6 +1,19 @@ ActionFactory.additionalBundles=net.sf.japi.examples.editor.messages -editor.menubar=file -editor.toolbar=fileNew fileOpen fileSave fileSaveAs +editor.menubar=file edit +editor.toolbar=fileNew fileOpen fileSave fileSaveAs - editCut editCopy editPaste file.menu=fileNew fileOpen fileSave fileSaveAs fileQuit +edit.menu=editCut editCopy editPaste + +fileNew.icon=general/New16 +fileOpen.icon=general/Open16 +fileOpen.exception.java.io.FileNotFoundException.messagetype=ERROR_MESSAGE +fileOpen.exception.java.io.IOException.messagetype=ERROR_MESSAGE +fileSave.icon=general/Save16 +fileSave.exception.java.io.IOException.messagetype=ERROR_MESSAGE +fileSaveAs.icon=general/SaveAs16 +fileSaveAs.exception.java.io.IOException.messagetype=ERROR_MESSAGE +editCut.icon=general/Cut16 +editCopy.icon=general/Copy16 +editPaste.icon=general/Paste16 Modified: trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties =================================================================== --- trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties 2006-04-05 21:53:34 UTC (rev 15) +++ trunk/src/doc/guide/swing/action/fromScratch/src/net/sf/japi/examples/editor/messages.properties 2006-04-05 23:39:02 UTC (rev 16) @@ -7,26 +7,21 @@ fileNew.mnemonic=N fileNew.accel=ctrl pressed N fileNew.shortdescription=Creates a new empty text document. -fileNew.icon=general/New16 fileOpen.text=Open... fileOpen.mnemonic=O fileOpen.accel=ctrl pressed O fileOpen.shortdescription=Opens an existing text document. -fileOpen.icon=general/Open16 fileOpen.exception.java.io.FileNotFoundException.title=File not found fileOpen.exception.java.io.FileNotFoundException.message=<html>The file couldn''t be opened. Reason:<br>{0} -fileOpen.exception.java.io.FileNotFoundException.messagetype=ERROR_MESSAGE fileOpen.exception.java.io.IOException.title=I/O error fileOpen.exception.java.io.IOException.message=<html>I/O error while reading. Reason:<br>{0} -fileOpen.exception.java.io.IOException.messagetype=ERROR_MESSAGE fileSave.text=Save fileSave.mnemonic=S fileSave.accel=ctrl pressed S fileSave.shortdescription=Saves the current document. -fileSave.icon=general/Save16 fileSave.exception.java.io.IOException.title=I/O error fileSave.exception.java.io.IOException.message=<html>I/O error while writing. Reason:<br>{0} @@ -34,7 +29,6 @@ fileSaveAs.mnemonic=A fileSaveAs.accel=ctrl shift pressed S fileSaveAs.shortdescription=Saves the current document in a new filename. -fileSaveAs.icon=general/SaveAs16 fileSaveAs.exception.java.io.IOException.title=I/O error fileSaveAs.exception.java.io.IOException.message=<html>I/O error while writing. Reason:<br>{0} @@ -43,6 +37,29 @@ fileQuit.accel=ctrl pressed Q fileQuit.shortdescription=Quits the text editor. +edit.text=Edit +edit.mnemonic=E + +editCut.text=Cut +editCut.mnemonic=C +editCut.accel=ctrl pressed X +editCut.shortdescription=Cuts the current selection to the clipboard + +editCopy.text=Copy +editCopy.mnemonic=O +editCopy.accel=ctrl pressed C +editCopy.shortdescription=Copies the current selection to the clipboard + +editPaste.text=Paste +editPaste.mnemonic=P +editPaste.accel=ctrl pressed V +editPaste.shortdescription=Pastes over the current selection from the clipboard + +editSelectAll.text=Select All +editSelectAll.mnemonic=A +editSelectAll.accel=ctrl pressed A +editSelectAll.shortdescription=Selects the entire editor content + reallyQuit.title=Really Quit? reallyQuit=Do you really want to quit the editor? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-04-14 16:35:46
|
Revision: 55 Author: christianhujer Date: 2006-04-14 09:35:28 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=55&view=rev Log Message: ----------- Internationalized assertion message. Modified Paths: -------------- trunk/src/app/net/sf/japi/swing/ReflectionAction.java trunk/src/app/net/sf/japi/swing/action.properties Modified: trunk/src/app/net/sf/japi/swing/ReflectionAction.java =================================================================== --- trunk/src/app/net/sf/japi/swing/ReflectionAction.java 2006-04-14 15:36:34 UTC (rev 54) +++ trunk/src/app/net/sf/japi/swing/ReflectionAction.java 2006-04-14 16:35:28 UTC (rev 55) @@ -52,6 +52,9 @@ */ public final class ReflectionAction extends AbstractAction { + /** Action Factory for reading strings. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing"); + /** The key used for storing the target object to invoke the method on. * Value Type: {@link Object}. */ @@ -143,8 +146,7 @@ try { getMethod(instance).invoke(instance); } catch (final IllegalAccessException ex) { - // TODO: i18n/l10n - assert false : "Action Methods must be accessible public. That means the declaring class as well as the method must be public.\n" + ex; + assert false : ACTION_FACTORY.format("ReflectionAction.nonPublicMethod", ex); } catch (final InvocationTargetException ex) { final ActionFactory actionFactory = (ActionFactory) getValue(REFLECTION_MESSAGE_PROVIDER); final Throwable cause = ex.getCause(); Modified: trunk/src/app/net/sf/japi/swing/action.properties =================================================================== --- trunk/src/app/net/sf/japi/swing/action.properties 2006-04-14 15:36:34 UTC (rev 54) +++ trunk/src/app/net/sf/japi/swing/action.properties 2006-04-14 16:35:28 UTC (rev 55) @@ -52,4 +52,5 @@ saxErrorClose.text=Close saxError.title=XML Errors dialogDontShowAgain=Show this dialog again next time. -laf=Look and Feel \ No newline at end of file +laf=Look and Feel +ReflectionAction.nonPublicMethod=Action Methods must be accessible public. That means the declaring class as well as the method must be public.\n{0} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-04-14 16:49:31
|
Revision: 56 Author: christianhujer Date: 2006-04-14 09:49:22 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=56&view=rev Log Message: ----------- Renamed FileField to JFileField Added Paths: ----------- trunk/src/app/net/sf/japi/swing/JFileField.java Removed Paths: ------------- trunk/src/app/net/sf/japi/swing/FileField.java Deleted: trunk/src/app/net/sf/japi/swing/FileField.java =================================================================== --- trunk/src/app/net/sf/japi/swing/FileField.java 2006-04-14 16:35:28 UTC (rev 55) +++ trunk/src/app/net/sf/japi/swing/FileField.java 2006-04-14 16:49:22 UTC (rev 56) @@ -1,76 +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.JTextField; -import javax.swing.JFileChooser; - -/** A class that displays a textfield for a file and a button for choosing the file. - * TODO - * @author <a href="mailto:Chr...@it...">Christian Hujer</a> - */ -public final class FileField 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 FileField(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 FileField(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 Copied: trunk/src/app/net/sf/japi/swing/JFileField.java (from rev 54, trunk/src/app/net/sf/japi/swing/FileField.java) =================================================================== --- trunk/src/app/net/sf/japi/swing/JFileField.java (rev 0) +++ trunk/src/app/net/sf/japi/swing/JFileField.java 2006-04-14 16:49:22 UTC (rev 56) @@ -0,0 +1,75 @@ +/* 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.JTextField; +import javax.swing.JFileChooser; + +/** A class that displays a textfield for a file and a button for choosing the file. + * @author <a href="mailto:Chr...@it...">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 Property changes on: trunk/src/app/net/sf/japi/swing/JFileField.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |