Thread: [Japi-cvs] SF.net SVN: japi: [251] libs/swing-action/trunk/src
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-12-03 23:57:13
|
Revision: 251 http://svn.sourceforge.net/japi/?rev=251&view=rev Author: christianhujer Date: 2006-12-03 15:57:11 -0800 (Sun, 03 Dec 2006) Log Message: ----------- Added unit test for ReflectionAction. Added Paths: ----------- libs/swing-action/trunk/src/test/ libs/swing-action/trunk/src/test/net/ libs/swing-action/trunk/src/test/net/sf/ libs/swing-action/trunk/src/test/net/sf/japi/ libs/swing-action/trunk/src/test/net/sf/japi/swing/ libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java Added: libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java =================================================================== --- libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java (rev 0) +++ libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java 2006-12-03 23:57:11 UTC (rev 251) @@ -0,0 +1,164 @@ +package test.net.sf.japi.swing; + +import java.awt.event.ActionEvent; +import java.lang.reflect.Method; +import net.sf.japi.swing.ActionMethod; +import net.sf.japi.swing.ReflectionAction; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Test for {@link ReflectionAction}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ReflectionActionTest { + + /** The testling: A ReflectionAction. */ + private ReflectionAction testling; + + /** Create the testling. */ + @Before + public void setUpTestling() { + testling = new ReflectionAction(); + } + + /** Remove the testling. */ + @After + public void tearDown() { + testling = null; + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test(expected = IllegalArgumentException.class) + public void testPutValueMethodNameThrows() throws Exception { + testling.putValue(ReflectionAction.REFLECTION_METHOD_NAME, new Object()); + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test + public void testPutValueMethodNameNull() throws Exception { + testling.putValue(ReflectionAction.REFLECTION_METHOD_NAME, null); + Assert.assertNull("After setting the method name to null method name must be null.", testling.getValue(ReflectionAction.REFLECTION_METHOD_NAME)); + Assert.assertNull("After setting the method name to null method must be null.", testling.getValue(ReflectionAction.REFLECTION_METHOD)); + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test + public void testPutValueMethodName() throws Exception { + testling.putValue(ReflectionAction.REFLECTION_METHOD_NAME, "foo"); + Assert.assertEquals("After setting the method name method name must be stored.", testling.getValue(ReflectionAction.REFLECTION_METHOD_NAME), "foo"); + Assert.assertNull("After setting the method name method must be null.", testling.getValue(ReflectionAction.REFLECTION_METHOD)); + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test(expected = IllegalArgumentException.class) + public void testPutValueMethodThrowsString() throws Exception { + testling.putValue(ReflectionAction.REFLECTION_METHOD, "foo"); + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test(expected = IllegalArgumentException.class) + public void testPutValueMethodThrowsOther() throws Exception { + testling.putValue(ReflectionAction.REFLECTION_METHOD, new Object()); + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test + public void testPutValueMethod() throws Exception { + final ActionMock actionDummy = new ActionMock(); + testling.putValue(ReflectionAction.REFLECTION_METHOD, actionDummy.getMethod()); + Assert.assertEquals(actionDummy.getMethod(), testling.getValue(ReflectionAction.REFLECTION_METHOD)); + } + + /** + * Tests whether {@link ReflectionAction#putValue(String, Object)} works. + * @throws Exception (unexpected) + */ + @Test + public void testPutValueTarget() throws Exception { + final ActionMock actionDummy = new ActionMock(); + testling.putValue(ReflectionAction.REFLECTION_METHOD_NAME, "foo"); + testling.putValue(ReflectionAction.REFLECTION_METHOD, actionDummy.getMethod()); + testling.putValue(ReflectionAction.REFLECTION_TARGET, null); + Assert.assertNull("After setting REFLECTION_TARGET to null, REFLECTION_METHOD must be reset to null.", testling.getValue(ReflectionAction.REFLECTION_METHOD)); + Assert.assertEquals("After setting REFLECTION_TARGET to null, REFLECTION_METHOD_NAME must be unchanged.", testling.getValue(ReflectionAction.REFLECTION_METHOD_NAME), "foo"); + } + + /** + * Tests whether {@link ReflectionAction#actionPerformed(ActionEvent)} works. + * @throws Exception (unexpected) + */ + @Test + public void testActionPerformed() throws Exception { + final ActionMock mock = new ActionMock(); + testling.putValue(ReflectionAction.REFLECTION_TARGET, mock); + testling.putValue(ReflectionAction.REFLECTION_METHOD_NAME, "someAction"); + testling.actionPerformed(new ActionEvent(this, 0, null)); + Assert.assertEquals("actionPerformed() must lead to the target method being invoked exactly once.", mock.getInvocationCount(), 1); + } + + /** + * ActionMock. + * Provides a counter that counts how often the action was invoked. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ + public static class ActionMock { + + /** + * Counter for counting the number of invocations of {@link #someAction()}. + */ + private int invocationCount; + + /** + * The ActionMethod. + * Increments the invocation counter. + */ + @ActionMethod + public void someAction() { + invocationCount++; + } + + /** + * Returns the invocation counter. + * @return The invocation counter. + */ + public int getInvocationCount() { + return invocationCount; + } + + /** + * Returns the Action method. + * @return The Action method. + */ + public Method getMethod() { + try { + return getClass().getMethod("someAction"); + } catch (final NoSuchMethodException e) { + throw new Error(e); + } + } + + } // class ActionMock + +} // class ReflectionActionTest Property changes on: libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.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. |
From: <chr...@us...> - 2006-12-17 15:02:34
|
Revision: 268 http://svn.sourceforge.net/japi/?rev=268&view=rev Author: christianhujer Date: 2006-12-17 07:02:29 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Improved tests and documentation. Modified Paths: -------------- libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java Added Paths: ----------- libs/swing-action/trunk/src/net/sf/japi/swing/action.properties libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties libs/swing-action/trunk/src/net/sf/japi/swing/package.html libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java libs/swing-action/trunk/src/test/net/sf/japi/swing/action.properties Modified: libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java 2006-12-17 14:48:01 UTC (rev 267) +++ libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java 2006-12-17 15:02:29 UTC (rev 268) @@ -52,6 +52,7 @@ import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JToolBar; +import javax.swing.KeyStroke; import static javax.swing.KeyStroke.getKeyStroke; import static net.sf.japi.swing.IconManager.getDefaultIconManager; import static net.sf.japi.swing.ReflectionAction.REFLECTION_MESSAGE_PROVIDER; @@ -272,6 +273,14 @@ * @throws NullPointerException if <var>menu</var> or <var>action</var> is <code>null</code> */ @Nullable public static JMenuItem find(@NotNull final JMenu menu, @NotNull final Action action) { + //noinspection ConstantConditions + if (menu == null) { + throw new NullPointerException("null JMenuBar not allowed"); + } + //noinspection ConstantConditions + if (action == null) { + throw new NullPointerException("null Action not allowed"); + } for (int i = 0; i < menu.getItemCount(); i++) { final JMenuItem item = menu.getItem(i); if (item == null) { @@ -288,11 +297,14 @@ return null; } - /** Create an ActionFactory. - * This constructor is private to force users to use the method {@link #getFactory(String)} for recycling ActionFactories and profit of easy + /** + * Create an ActionFactory. + * Usually you wouldn't create an ActionFactory yourself but use {@link #getFactory(String)} for recycling ActionFactories and profit of easy * access to the same ActionFactory from within the whole application without passing around ActionFactory references. + * Don't use this constructor without knowing what you're doing. + * It's mainly there for testing purposes. */ - private ActionFactory() { + public ActionFactory() { } /** Get the ActionMap. @@ -403,19 +415,34 @@ * @throws NullPointerException in case <var>key</var> was <code>null</code> */ @SuppressWarnings({"NestedAssignment"}) - public Action initAction(final boolean store, @NotNull final Action action, @NotNull final String key) throws NullPointerException { + @NotNull public Action initAction(final boolean store, @NotNull final Action action, @NotNull final String key) throws NullPointerException { if (key == null) { throw new NullPointerException("null key for Action initialization not allowed."); } action.putValue(ACTION_ID, key); String value; - if ((value = getString(key + ".text" )) != null) { action.putValue(NAME, value); } + final String text = getString(key + ".text"); + if ((value = text) != null) { action.putValue(NAME, value); } if ((value = getString(key + ".shortdescription")) != null) { action.putValue(SHORT_DESCRIPTION, value); } if ((value = getString(key + ".longdescription" )) != null) { action.putValue(LONG_DESCRIPTION, value); } if ((value = getString(key + ".accel" )) != null) { action.putValue(ACCELERATOR_KEY, getKeyStroke(value)); } if ((value = getString(key + ".accel2" )) != null) { action.putValue(ACCELERATOR_KEY_2, getKeyStroke(value)); } - if ((value = getString(key + ".mnemonic" )) != null) { action.putValue(MNEMONIC_KEY, getKeyStroke(value).getKeyCode()); } + if ((value = getString(key + ".mnemonic" )) != null) { + final KeyStroke keyStroke = getKeyStroke(value); + if (keyStroke != null) { + action.putValue(MNEMONIC_KEY, keyStroke.getKeyCode()); + } else { + System.err.println("Warning: Action key " + key + " has " + key + ".mnemonic value " + value + " which is a null KeyStroke."); + } + if (text == null) { + System.err.println("Warning: Action key " + key + " has " + key + ".mnemonic value " + value + " but no text. Either define " + key + ".text or remove " + key + ".mnemonic."); + } + } if ((value = getString(key + ".icon" )) != null) { final Icon image = getDefaultIconManager().getIcon(value); - if (image != null) { action.putValue(SMALL_ICON, image); } + if (image != null) { + action.putValue(SMALL_ICON, image); + } else { + System.err.println("Warning: Action key " + key + " has " + key + ".icon value " + value + " but no corresponding icon was found."); + } } action.putValue(REFLECTION_MESSAGE_PROVIDER, this); if (store) { Copied: libs/swing-action/trunk/src/net/sf/japi/swing/action.properties (from rev 245, historic/trunk/src/app/net/sf/japi/swing/action.properties) =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/action.properties (rev 0) +++ libs/swing-action/trunk/src/net/sf/japi/swing/action.properties 2006-12-17 15:02:29 UTC (rev 268) @@ -0,0 +1,23 @@ +# 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. +# + + +dialogDontShowAgain=Show this dialog again next time. +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 Copied: libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties (from rev 245, historic/trunk/src/app/net/sf/japi/swing/action_de.properties) =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties (rev 0) +++ libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties 2006-12-17 15:02:29 UTC (rev 268) @@ -0,0 +1,22 @@ +# 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. +# + + +dialogDontShowAgain=Show this dialog again next time. Copied: libs/swing-action/trunk/src/net/sf/japi/swing/package.html (from rev 245, historic/trunk/src/app/net/sf/japi/swing/package.html) =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/package.html (rev 0) +++ libs/swing-action/trunk/src/net/sf/japi/swing/package.html 2006-12-17 15:02:29 UTC (rev 268) @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- 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. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date: 2006-04-03 23:00:14 +0200 (Mon, 03 Apr 2006) $" /> + <title>net.sf.japi.swing</title> + </head> + <body> + <p> + This package contains classes for supporting creation and use of Swing Actions. + </p> + </body> +</html> Added: libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java =================================================================== --- libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java (rev 0) +++ libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java 2006-12-17 15:02:29 UTC (rev 268) @@ -0,0 +1,99 @@ +package test.net.sf.japi.swing; + +import javax.swing.Action; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.DummyAction; +import org.junit.Before; +import org.junit.Test; +import org.junit.Assert; + +/** + * Test for {@link ActionFactory}. + * + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ActionFactoryTest { + + private ActionFactory actionFactory; + + /** + * Creates an ActionFactory. + * @throws Exception (unexpected) + */ + @Before + public void setUp() throws Exception { + actionFactory = new ActionFactory(); + } + + /** + * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. + * @throws Exception (unexpected) + */ + @Test(expected=NullPointerException.class) + public void testFindNullBar() throws Exception { + //noinspection ConstantConditions + ActionFactory.find((JMenuBar) null, createSimple("item")); + } + + /** + * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. + * @throws Exception (unexpected) + */ + @Test(expected=NullPointerException.class) + public void testFindNullActionInMenuBar() throws Exception { + //noinspection ConstantConditions + ActionFactory.find(new JMenuBar(), (Action) null); + } + + /** + * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. + * @throws Exception (unexpected) + */ + @Test(expected=NullPointerException.class) + public void testFindNullMenu() throws Exception { + //noinspection ConstantConditions + ActionFactory.find((JMenu) null, createSimple("item")); + } + + /** + * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. + * @throws Exception (expected) + */ + @Test(expected=NullPointerException.class) + public void testFindNullActionInMenu() throws Exception { + //noinspection ConstantConditions + ActionFactory.find(new JMenu(), null); + } + /** + * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. + * @throws Exception (unexpected) + */ + @Test + public void testFind() throws Exception { + final JMenuBar menuBar = new JMenuBar(); + final JMenu menu = new JMenu(createSimple("menu")); + final Action action1 = createSimple("item1"); + final Action action2 = createSimple("item2"); + final JMenuItem item1 = new JMenu(action1); + final JMenuItem item2 = new JMenu(action2); + menuBar.add(menu); + menu.add(item1); + menu.add(item2); + Assert.assertSame(item1, ActionFactory.find(menuBar, action1)); + Assert.assertSame(item2, ActionFactory.find(menuBar, action2)); + } + + /** + * Creates a simple action that performs nothing. + * @param key Key for the action + * @return A simple action that performs nothing. + */ + private Action createSimple(final String key) { + final Action action = new DummyAction(); + action.putValue(Action.ACTION_COMMAND_KEY, key); + return action; + } +} // class ActionFactoryTest \ No newline at end of file Property changes on: libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java =================================================================== --- libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java 2006-12-17 14:48:01 UTC (rev 267) +++ libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java 2006-12-17 15:02:29 UTC (rev 268) @@ -2,9 +2,9 @@ import java.awt.event.ActionEvent; import java.lang.reflect.Method; +import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import net.sf.japi.swing.ReflectionAction; -import net.sf.japi.swing.ActionFactory; import org.junit.After; import org.junit.Assert; import org.junit.Before; Added: libs/swing-action/trunk/src/test/net/sf/japi/swing/action.properties =================================================================== Property changes on: libs/swing-action/trunk/src/test/net/sf/japi/swing/action.properties ___________________________________________________________________ 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. |
From: <chr...@us...> - 2007-06-25 20:06:55
|
Revision: 446 http://svn.sourceforge.net/japi/?rev=446&view=rev Author: christianhujer Date: 2007-06-25 13:06:53 -0700 (Mon, 25 Jun 2007) Log Message: ----------- Fixed checkstyle issues. Modified Paths: -------------- libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java libs/swing-action/trunk/src/net/sf/japi/swing/IconManager.java libs/swing-action/trunk/src/net/sf/japi/swing/action.properties libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java Modified: libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java 2007-06-25 20:00:34 UTC (rev 445) +++ libs/swing-action/trunk/src/net/sf/japi/swing/ActionFactory.java 2007-06-25 20:06:53 UTC (rev 446) @@ -190,6 +190,7 @@ /** The ActionMap to which created Actions are automatically added. */ @NotNull private final ActionMap actionMap = new NamedActionMap(); + /** The action providers that were registered and will be queried when an action should be created / retrieved. */ private List<ActionProvider> actionProviders = new ArrayList<ActionProvider>(); /** Get an ActionFactory. @@ -430,10 +431,10 @@ final String text = getString(key + ".text"); if ((value = text) != null) { action.putValue(NAME, value); } if ((value = getString(key + ".shortdescription")) != null) { action.putValue(SHORT_DESCRIPTION, value); } - if ((value = getString(key + ".longdescription" )) != null) { action.putValue(LONG_DESCRIPTION, value); } - if ((value = getString(key + ".accel" )) != null) { action.putValue(ACCELERATOR_KEY, getKeyStroke(value)); } - if ((value = getString(key + ".accel2" )) != null) { action.putValue(ACCELERATOR_KEY_2, getKeyStroke(value)); } - if ((value = getString(key + ".mnemonic" )) != null) { + if ((value = getString(key + ".longdescription")) != null) { action.putValue(LONG_DESCRIPTION, value); } + if ((value = getString(key + ".accel")) != null) { action.putValue(ACCELERATOR_KEY, getKeyStroke(value)); } + if ((value = getString(key + ".accel2")) != null) { action.putValue(ACCELERATOR_KEY_2, getKeyStroke(value)); } + if ((value = getString(key + ".mnemonic")) != null) { final KeyStroke keyStroke = getKeyStroke(value); if (keyStroke != null) { action.putValue(MNEMONIC_KEY, keyStroke.getKeyCode()); @@ -444,7 +445,7 @@ System.err.println("Warning: Action key " + key + " has " + key + ".mnemonic value " + value + " but no text. Either define " + key + ".text or remove " + key + ".mnemonic."); } } - if ((value = getString(key + ".icon" )) != null) { + if ((value = getString(key + ".icon")) != null) { final Icon image = getDefaultIconManager().getIcon(value); if (image != null) { action.putValue(SMALL_ICON, image); Modified: libs/swing-action/trunk/src/net/sf/japi/swing/IconManager.java =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/IconManager.java 2007-06-25 20:00:34 UTC (rev 445) +++ libs/swing-action/trunk/src/net/sf/japi/swing/IconManager.java 2007-06-25 20:06:53 UTC (rev 446) @@ -65,7 +65,7 @@ * 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>(); + private final Map<String, Icon> smallCache = new WeakHashMap<String, Icon>(); /** The paths to search icons in. */ private final List<String> iconPaths = new ArrayList<String>(); Modified: libs/swing-action/trunk/src/net/sf/japi/swing/action.properties =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/action.properties 2007-06-25 20:00:34 UTC (rev 445) +++ libs/swing-action/trunk/src/net/sf/japi/swing/action.properties 2007-06-25 20:06:53 UTC (rev 446) @@ -19,4 +19,4 @@ dialogDontShowAgain=Show this dialog again next time. -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 +ReflectionAction.nonPublicMethod=Action Methods must be accessible public. That means the declaring class as well as the method must be public.\n{0} Modified: libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties =================================================================== --- libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties 2007-06-25 20:00:34 UTC (rev 445) +++ libs/swing-action/trunk/src/net/sf/japi/swing/action_de.properties 2007-06-25 20:06:53 UTC (rev 446) @@ -19,3 +19,4 @@ dialogDontShowAgain=Show this dialog again next time. +ReflectionAction.nonPublicMethod=Action Methoden m\xFCssen public zugreifbar sein. Das hei\xDFt, die deklarierende Klasse muss auch public sein.\n{0} Modified: libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java =================================================================== --- libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java 2007-06-25 20:00:34 UTC (rev 445) +++ libs/swing-action/trunk/src/test/net/sf/japi/swing/ActionFactoryTest.java 2007-06-25 20:06:53 UTC (rev 446) @@ -25,9 +25,8 @@ import javax.swing.JMenuItem; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.DummyAction; -import org.junit.Before; -import org.junit.Test; import org.junit.Assert; +import org.junit.Test; /** * Test for {@link ActionFactory}. @@ -36,22 +35,11 @@ */ public class ActionFactoryTest { - private ActionFactory actionFactory; - /** - * Creates an ActionFactory. - * @throws Exception (unexpected) - */ - @Before - public void setUp() throws Exception { - actionFactory = new ActionFactory(); - } - - /** * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. * @throws Exception (unexpected) */ - @Test(expected=NullPointerException.class) + @Test(expected = NullPointerException.class) public void testFindNullBar() throws Exception { //noinspection ConstantConditions ActionFactory.find((JMenuBar) null, createSimple("item")); @@ -61,7 +49,7 @@ * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. * @throws Exception (unexpected) */ - @Test(expected=NullPointerException.class) + @Test(expected = NullPointerException.class) public void testFindNullActionInMenuBar() throws Exception { //noinspection ConstantConditions ActionFactory.find(new JMenuBar(), (Action) null); @@ -71,7 +59,7 @@ * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. * @throws Exception (unexpected) */ - @Test(expected=NullPointerException.class) + @Test(expected = NullPointerException.class) public void testFindNullMenu() throws Exception { //noinspection ConstantConditions ActionFactory.find((JMenu) null, createSimple("item")); @@ -81,7 +69,7 @@ * Tests whether {@link ActionFactory#find(JMenuBar, Action)} works. * @throws Exception (expected) */ - @Test(expected=NullPointerException.class) + @Test(expected = NullPointerException.class) public void testFindNullActionInMenu() throws Exception { //noinspection ConstantConditions ActionFactory.find(new JMenu(), null); @@ -115,4 +103,5 @@ action.putValue(Action.ACTION_COMMAND_KEY, key); return action; } -} // class ActionFactoryTest \ No newline at end of file + +} // class ActionFactoryTest Modified: libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java =================================================================== --- libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java 2007-06-25 20:00:34 UTC (rev 445) +++ libs/swing-action/trunk/src/test/net/sf/japi/swing/ReflectionActionTest.java 2007-06-25 20:06:53 UTC (rev 446) @@ -146,7 +146,7 @@ * Tests whether {@link ReflectionAction#actionPerformed(ActionEvent)} works. * @throws Exception (unexpected) */ - @Test(expected=Exception.class) + @Test(expected = Exception.class) public void testActionPerformedException() throws Exception { actionMock.setThrowException(true); testling.putValue(ReflectionAction.REFLECTION_TARGET, actionMock); @@ -217,7 +217,7 @@ * Sets whether an exception should be thrown when executing {@link #someAction()}. * @param throwException <code>true</code> for throwing an exception, otherwise <code>false</code>. */ - public void setThrowException(boolean throwException) { + public void setThrowException(final boolean throwException) { this.throwException = throwException; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2008-03-01 08:45:00
|
Revision: 636 http://japi.svn.sourceforge.net/japi/?rev=636&view=rev Author: christianhujer Date: 2008-03-01 00:44:56 -0800 (Sat, 01 Mar 2008) Log Message: ----------- Fixed violations against checkstyle. Modified Paths: -------------- libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java libs/swing-action/trunk/src/prj/net/sf/japi/swing/DummyActionBuilder.java Added Paths: ----------- libs/swing-action/trunk/src/doc/ Modified: libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java =================================================================== --- libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java 2008-01-15 00:03:52 UTC (rev 635) +++ libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java 2008-03-01 08:44:56 UTC (rev 636) @@ -27,8 +27,12 @@ /** The ComponentFactory provides some convenience methods for creating Swing Components. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class ComponentFactory { +public final class ComponentFactory { + /** Utility class - do not instanciate. */ + private ComponentFactory() { + } + /** Creates a JToolBar from Actions. * @param name Name of the JToolBar, which is used as title for the undocked JToolBar. * @param actions Actions to create JToolBar for. Modified: libs/swing-action/trunk/src/prj/net/sf/japi/swing/DummyActionBuilder.java =================================================================== --- libs/swing-action/trunk/src/prj/net/sf/japi/swing/DummyActionBuilder.java 2008-01-15 00:03:52 UTC (rev 635) +++ libs/swing-action/trunk/src/prj/net/sf/japi/swing/DummyActionBuilder.java 2008-03-01 08:44:56 UTC (rev 636) @@ -74,7 +74,7 @@ /** {@inheritDoc} */ public Action[] createActions(final boolean store, @NotNull final String... keys) throws NullPointerException { - return new Action[0];//To change body of implemented methods use File | Settings | File Templates. + return new Action[0]; } /** {@inheritDoc} */ @@ -105,7 +105,7 @@ /** {@inheritDoc} */ public Action[] createActions(final boolean store, final Object target, final String... keys) throws NullPointerException { - return new Action[0];//To change body of implemented methods use File | Settings | File Templates. + return new Action[0]; } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |