Class SwingActionManager
- java.lang.Object
-
- net.sf.jguiraffe.gui.platform.swing.builder.action.SwingActionManager
-
- All Implemented Interfaces:
net.sf.jguiraffe.gui.builder.action.ActionManager
public class SwingActionManager extends Object implements net.sf.jguiraffe.gui.builder.action.ActionManager
The Swing specific implementation of the
ActionManager
interface.This class implements the
ActionManager
methods in a way that correctly initialized Swing objects (like Actions and JMenus) are created.- Version:
- $Id: SwingActionManager.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description SwingActionManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMenuSeparator(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object menu)
Adds a separator to the given menu.protected void
addToMenu(Object parent, JMenuItem item)
Adds a menu item to a parent menu.void
addToolBarSeparator(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object toolBar)
Adds a separator to the given tool bar.protected void
addToToolbar(Object parent, AbstractButton button)
Adds a tool button to the parent bar.net.sf.jguiraffe.gui.builder.action.FormAction
createAction(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData actionData)
Creates an action object.Object
createMenu(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object menu, net.sf.jguiraffe.gui.builder.components.tags.TextIconData data, Object parent)
Creates a menu based on the given data.Object
createMenuBar(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder)
Creates a menu bar.net.sf.jguiraffe.gui.forms.ComponentHandler<?>
createMenuItem(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData actionData, boolean checked, Object parent)
Creates a menu item based on the passed in data object.Object
createMenuItem(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.FormAction formAction, boolean checked, Object parent)
Creates a menu item based on the given action.Object
createToolbar(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder)
Creates a tool bar object.net.sf.jguiraffe.gui.forms.ComponentHandler<?>
createToolbarButton(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData data, boolean checked, Object parent)
Creates a toolbar button based on the passed in action data object and returns a component handler for it.Object
createToolbarButton(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.FormAction formAction, boolean checked, Object parent)
Creates a toolbar button based on the given action.void
registerPopupMenuHandler(Object component, net.sf.jguiraffe.gui.builder.action.PopupMenuHandler handler, net.sf.jguiraffe.gui.builder.components.ComponentBuilderData compData)
Associates aPopupMenuHandler
with a UI component.
-
-
-
Method Detail
-
createAction
public net.sf.jguiraffe.gui.builder.action.FormAction createAction(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData actionData) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates an action object. The returned object will also implement Swing'sAction
interface.- Specified by:
createAction
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builderactionData
- the properties of the new action- Returns:
- the newly created action
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
createMenuItem
public Object createMenuItem(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.FormAction formAction, boolean checked, Object parent) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a menu item based on the given action. Depending on thechecked
argument either aJMenuItem
or aJCheckBoxMenuItem
object will be returned.- Specified by:
createMenuItem
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builderformAction
- the action to associate with the menu item; this object must implement Swing'sAction
interfacechecked
- the checked flagparent
- the parent menu; this must be an instance ofJMenu
- Returns:
- the new menu item
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
createMenuItem
public net.sf.jguiraffe.gui.forms.ComponentHandler<?> createMenuItem(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData actionData, boolean checked, Object parent) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a menu item based on the passed in data object. Depending on thechecked
argument either aJMenuItem
or aJCheckBoxMenuItem
object will be returned.- Specified by:
createMenuItem
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builderactionData
- the action data objectchecked
- the checked flagparent
- the parent menu; this must be an instance ofJMenu
- Returns:
- the new menu item
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
createMenuBar
public Object createMenuBar(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a menu bar. This implementation will return a newJMenuBar
object.- Specified by:
createMenuBar
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builder- Returns:
- the new menu bar
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
createMenu
public Object createMenu(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object menu, net.sf.jguiraffe.gui.builder.components.tags.TextIconData data, Object parent) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a menu based on the given data. The return value will be aJMenu
object.- Specified by:
createMenu
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action buildermenu
- the menu object (null in the creation phase, a not nullJMenu
instance in the initialization phase)data
- the data for the new menuparent
- the menu's parent (a menu bar or a menu)- Returns:
- the new menu
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs, i.e. if the parent is undefined
-
createToolbar
public Object createToolbar(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a tool bar object. This implementation returns aJToolBar
object.- Specified by:
createToolbar
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builder- Returns:
- the new tool bar
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
createToolbarButton
public Object createToolbarButton(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.FormAction formAction, boolean checked, Object parent) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a toolbar button based on the given action. Depending on thechecked
argument either aJButton
or aJToggleButton
object will be returned.- Specified by:
createToolbarButton
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builderformAction
- the action to associate with the menu item; this object must implement Swing'sAction
interfacechecked
- the checked flagparent
- the parent toolbar; this must be an instance ofJToolBar
- Returns:
- the new tool button
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
createToolbarButton
public net.sf.jguiraffe.gui.forms.ComponentHandler<?> createToolbarButton(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData data, boolean checked, Object parent) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Creates a toolbar button based on the passed in action data object and returns a component handler for it. Depending on thechecked
argument either aJButton
or aJToggleButton
object will be created.- Specified by:
createToolbarButton
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action builderdata
- the action data object with the properties for the tool buttonchecked
- the checked flagparent
- the parent toolbar; this must be an instance ofJToolBar
- Returns:
- a component handler for the new tool button
- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
addMenuSeparator
public void addMenuSeparator(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object menu) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Adds a separator to the given menu. The passed in menu must be an instance ofJMenu
.- Specified by:
addMenuSeparator
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action buildermenu
- the menu- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
addToolBarSeparator
public void addToolBarSeparator(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object toolBar) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Adds a separator to the given tool bar. The passed in object must be an instance ofJToolBar
.- Specified by:
addToolBarSeparator
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
actionBuilder
- the action buildertoolBar
- the tool bar- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occurs
-
registerPopupMenuHandler
public void registerPopupMenuHandler(Object component, net.sf.jguiraffe.gui.builder.action.PopupMenuHandler handler, net.sf.jguiraffe.gui.builder.components.ComponentBuilderData compData) throws net.sf.jguiraffe.gui.builder.action.FormActionException
Associates aPopupMenuHandler
with a UI component. This implementation expects that the passed in object is derived fromjava.awt.Component
. It registers a special mouse listener at this component that is looking for gestures triggering a popup menu. When such a gesture is detected thePopupMenuHandler
object is invoked.- Specified by:
registerPopupMenuHandler
in interfacenet.sf.jguiraffe.gui.builder.action.ActionManager
- Parameters:
component
- the componenthandler
- the handler to registercompData
- the component builder data object- Throws:
net.sf.jguiraffe.gui.builder.action.FormActionException
- if an error occursIllegalArgumentException
- if a required parameter is missing
-
addToMenu
protected void addToMenu(Object parent, JMenuItem item)
Adds a menu item to a parent menu. The menu must be an instance ofJMenu
orJPopupMenu
.- Parameters:
parent
- the parent menuitem
- the item to add
-
addToToolbar
protected void addToToolbar(Object parent, AbstractButton button)
Adds a tool button to the parent bar. The bar must be an instance ofJToolBar
.- Parameters:
parent
- the parent tool barbutton
- the button to add
-
-