[Japi-cvs] SF.net SVN: japi: [630] progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca /swing
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2007-10-21 12:01:52
|
Revision: 630 http://japi.svn.sourceforge.net/japi/?rev=630&view=rev Author: christianhujer Date: 2007-10-21 05:01:49 -0700 (Sun, 21 Oct 2007) Log Message: ----------- Created ComponentFactory, moved factory methods from ISwingUtilities to ComponentFactory. Modified Paths: -------------- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java Added Paths: ----------- libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java Added: libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java =================================================================== --- libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java (rev 0) +++ libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java 2007-10-21 12:01:49 UTC (rev 630) @@ -0,0 +1,58 @@ +/* + * JAPI libs-swing-action is a library for creating and managing javax.swing.Action objects. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.swing; + +import javax.swing.Action; +import javax.swing.JToolBar; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** The ComponentFactory provides some convenience methods for creating Swing Components. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class 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. + * @return JToolBar with all supplied actions. + */ + public static JToolBar createJToolBar(@Nullable final String name, @NotNull final Action... actions) { + final JToolBar toolBar = name != null ? new JToolBar(name) : new JToolBar(); + for (final Action action : actions) { + toolBar.add(action); + } + return toolBar; + } + + /** 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. + * @return JToolBar with all supplied actions. + */ + public static JToolBar createJToolBar(@Nullable final String name, @NotNull final Iterable<Action> actions) { + final JToolBar toolBar = name != null ? new JToolBar(name) : new JToolBar(); + for (final Action action : actions) { + toolBar.add(action); + } + return toolBar; + } + +} // class ComponentFactory Property changes on: libs/swing-action/trunk/src/prj/net/sf/japi/swing/ComponentFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java =================================================================== --- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java 2007-10-12 19:27:40 UTC (rev 629) +++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/ProgramFrame.java 2007-10-21 12:01:49 UTC (rev 630) @@ -44,7 +44,6 @@ import javax.swing.JToolBar; import net.sf.japi.progs.jeduca.jtest.Program; import net.sf.japi.progs.jeduca.jtest.Settings; -import net.sf.japi.progs.jeduca.swing.ISwingUtilities; import net.sf.japi.progs.jeduca.swing.InternalFrameManager; import net.sf.japi.progs.jeduca.swing.MenuManager; import net.sf.japi.progs.jeduca.swing.OpenURLPane; @@ -55,6 +54,7 @@ import net.sf.japi.progs.jeduca.swing.settings.SettingsPane; import net.sf.japi.swing.ActionBuilder; import net.sf.japi.swing.ActionBuilderFactory; +import net.sf.japi.swing.ComponentFactory; import net.sf.japi.swing.LookAndFeelManager; import net.sf.japi.swing.ToolBarLayout; import net.sf.japi.swing.about.AboutDialog; @@ -339,7 +339,7 @@ * @return Toolbar with essential program actions */ public JToolBar createProgramToolBar() { - return ISwingUtilities.createToolBar(RES.getString("programToolBar.name"), open, save, print); + return ComponentFactory.createJToolBar(RES.getString("programToolBar.name"), open, save, print); } /** Create Menu with essential program actions. Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java =================================================================== --- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java 2007-10-12 19:27:40 UTC (rev 629) +++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/jtest/gui/QuestionCollectionGUI.java 2007-10-21 12:01:49 UTC (rev 630) @@ -34,9 +34,9 @@ import net.sf.japi.progs.jeduca.jtest.QuestionCollection; import net.sf.japi.progs.jeduca.jtest.QuestionText; import net.sf.japi.progs.jeduca.jtest.Settings; -import net.sf.japi.progs.jeduca.swing.ISwingUtilities; import net.sf.japi.swing.ActionBuilder; import net.sf.japi.swing.ActionBuilderFactory; +import net.sf.japi.swing.ComponentFactory; /** User Interface for a Collection of Questions. * @author $Author: chris $ @@ -330,7 +330,7 @@ * @return Navigation Toolbar */ public JToolBar createNavigationToolBar() { - return ISwingUtilities.createToolBar(res.getString("navigationToolBar.name"), navigationActions); + return ComponentFactory.createJToolBar(res.getString("navigationToolBar.name"), navigationActions); } /** Get the index of the question currently being displayed. Modified: progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java =================================================================== --- progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java 2007-10-12 19:27:40 UTC (rev 629) +++ progs/jeduca/trunk/src/prj/net/sf/japi/progs/jeduca/swing/ISwingUtilities.java 2007-10-21 12:01:49 UTC (rev 630) @@ -29,40 +29,9 @@ import javax.swing.JToolBar; /** JAPI Swing Utilities. - * @todo provide methods which create toolbars that get information from preferences and resource bundles */ public class ISwingUtilities { - /** Create a toolbar. - * @param name Name for toolbar - * @param actions Actions to create toolbar from - * @return ToolBar for the specified actions. - */ - public static JToolBar createToolBar(final String name, final Action... actions) { - final JToolBar toolBar = new JToolBar(name); - for (final Action action : actions) { - final JButton button = new JButton(action); - button.setText(null); - toolBar.add(button); - } - return toolBar; - } - - /** Create a toolbar. - * @param name Name for toolbar - * @param actions Actions to create toolbar from - * @return ToolBar for the specified actions. - */ - public static JToolBar createToolBar(final String name, final Iterable<Action> actions) { - final JToolBar toolBar = new JToolBar(name); - for (final Action action : actions) { - final JButton button = new JButton(action); - button.setText(null); - toolBar.add(button); - } - return toolBar; - } - /** Find the Window for a Component. * Searches for a Frame or a Dialog which is the parent component of the supplied argument. * Windows are treated like normal Components since in Java Windows can't stand for themselves but must have another Window as a parent. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |