Class ActionManagerWrapper
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.action.ActionManagerWrapper
-
- All Implemented Interfaces:
ActionManager
public abstract class ActionManagerWrapper extends Object implements ActionManager
A base class for wrapper implementations of the
ActionManager
interface.An instance of this class is initialized with a reference to an
ActionManager
object. All methods simply delegate to this object.This class is especially useful if a custom implementation of
ActionManager
is to be created based on an existing implementation. Then only the methods to be customized have to be implemented. All other methods can still delegate to the existing implementation.- Version:
- $Id: ActionManagerWrapper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ActionManagerWrapper(ActionManager wrapped)
Creates a new instance ofActionManagerWrapper
and initializes it with the wrappedActionManager
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMenuSeparator(ActionBuilder actionBuilder, Object menu)
Adds a separator to the specified menu.void
addToolBarSeparator(ActionBuilder actionBuilder, Object toolBar)
Adds a separator to the specified tool bar.FormAction
createAction(ActionBuilder actionBuilder, ActionData actionData)
Creates an action object based on the provided information.Object
createMenu(ActionBuilder actionBuilder, Object menu, TextIconData data, Object parent)
Creates a (sub) menu.Object
createMenuBar(ActionBuilder actionBuilder)
Creates a menu bar.ComponentHandler<?>
createMenuItem(ActionBuilder actionBuilder, ActionData actionData, boolean checked, Object parent)
Creates a menu item based on the specified action data object and returns a component handler for it.Object
createMenuItem(ActionBuilder actionBuilder, FormAction action, boolean checked, Object parent)
Creates a menu item based on the specified action object.Object
createToolbar(ActionBuilder actionBuilder)
Creates a toolbar object.ComponentHandler<?>
createToolbarButton(ActionBuilder actionBuilder, ActionData data, boolean checked, Object parent)
Creates a toolbar button based on the given action data object and returns a component handler for it.Object
createToolbarButton(ActionBuilder actionBuilder, FormAction action, boolean checked, Object parent)
Creates a toolbar button based on the specified action object.ActionManager
getWrappedActionManager()
Returns a reference to the wrappedActionManager
object.void
registerPopupMenuHandler(Object component, PopupMenuHandler handler, ComponentBuilderData compData)
Registers the specifiedPopupMenuHandler
at the given UI component.
-
-
-
Constructor Detail
-
ActionManagerWrapper
protected ActionManagerWrapper(ActionManager wrapped)
Creates a new instance ofActionManagerWrapper
and initializes it with the wrappedActionManager
. Note: This method does not check whether the passed inActionManager
object is null because we do not want to enforce this restriction on all subclasses. The passed in wrapped action manager is stored in an internal field and can be accessed using thegetWrappedActionManager()
method. If a subclass needs another mechanism to access the wrapped manager, it has to override thegetWrappedActionManager()
method.- Parameters:
wrapped
- the wrappedActionManager
-
-
Method Detail
-
getWrappedActionManager
public ActionManager getWrappedActionManager()
Returns a reference to the wrappedActionManager
object.- Returns:
- the wrapped
ActionManager
-
createAction
public FormAction createAction(ActionBuilder actionBuilder, ActionData actionData) throws FormActionException
Creates an action object based on the provided information. Just delegates to the wrappedActionManager
object.- Specified by:
createAction
in interfaceActionManager
- Parameters:
actionBuilder
- the central builder data objectactionData
- an object with all information about the action to create- Returns:
- the new action object
- Throws:
FormActionException
- if an error occurs
-
createMenuItem
public Object createMenuItem(ActionBuilder actionBuilder, FormAction action, boolean checked, Object parent) throws FormActionException
Creates a menu item based on the specified action object. The menu item will be associated with the given action. Its properties (e.g. text and icon) will be obtained from the action, too. Just delegates to the wrappedActionManager
object.- Specified by:
createMenuItem
in interfaceActionManager
- Parameters:
actionBuilder
- the action builderaction
- the actionchecked
- a flag if a checked menu item should be createdparent
- the parent menu to which the new item should be added- Returns:
- the new menu item
- Throws:
FormActionException
- if an error occurs
-
createMenuItem
public ComponentHandler<?> createMenuItem(ActionBuilder actionBuilder, ActionData actionData, boolean checked, Object parent) throws FormActionException
Creates a menu item based on the specified action data object and returns a component handler for it. The data of this component handler will be a boolean value representing the checked state for checked menu items. For other menu items it is undefined. Just delegates to the wrappedActionManager
object.- Specified by:
createMenuItem
in interfaceActionManager
- Parameters:
actionBuilder
- the action builderactionData
- an object with all information about the menu itemchecked
- a flag if a checked menu item should be createdparent
- the parent menu to which the new item should be added- Returns:
- a component handler for the new menu item
- Throws:
FormActionException
- if an error occurs
-
createMenuBar
public Object createMenuBar(ActionBuilder actionBuilder) throws FormActionException
Creates a menu bar. Later defined (sub) menus will be added to this bar. Just delegates to the wrappedActionManager
object.- Specified by:
createMenuBar
in interfaceActionManager
- Parameters:
actionBuilder
- the action builder- Returns:
- the new menu bar
- Throws:
FormActionException
- if an error occurs
-
createMenu
public Object createMenu(ActionBuilder actionBuilder, Object menu, TextIconData data, Object parent) throws FormActionException
Creates a (sub) menu. The new menu will be added to the specified parent menu, which can be either a menu bar or another menu. This method will be called twice for each menu to be created. In the first call not all initialization properties might be available (e.g. the icon), but the menu must be created nevertheless (to allow for the menu items being added). In the second call missing initialization can be performed. An implementation should only create an uninitialized menu on the first call. On the second call it should initialize the menu's properties. Just delegates to the wrappedActionManager
object.- Specified by:
createMenu
in interfaceActionManager
- Parameters:
actionBuilder
- the action buildermenu
- the menu object; this will be null on the first call; on the second call the object returned by the first call will be passeddata
- data defining the new menuparent
- the parent menu- Returns:
- the new menu
- Throws:
FormActionException
- if an error occurs
-
createToolbar
public Object createToolbar(ActionBuilder actionBuilder) throws FormActionException
Creates a toolbar object. Later defined toolbar buttons will be added to this bar. Just delegates to the wrappedActionManager
object.- Specified by:
createToolbar
in interfaceActionManager
- Parameters:
actionBuilder
- the action builder- Returns:
- the new toolbar object
- Throws:
FormActionException
- if an error occurs
-
createToolbarButton
public Object createToolbarButton(ActionBuilder actionBuilder, FormAction action, boolean checked, Object parent) throws FormActionException
Creates a toolbar button based on the specified action object. The button will be associated with this action and obtain its properties from there. Just delegates to the wrappedActionManager
object.- Specified by:
createToolbarButton
in interfaceActionManager
- Parameters:
actionBuilder
- the action builderaction
- the actionchecked
- a flag if a checked (toggle) button should be createdparent
- the parent component (a toolbar) to which the new button should be added- Returns:
- the new button
- Throws:
FormActionException
- if an error occurs
-
createToolbarButton
public ComponentHandler<?> createToolbarButton(ActionBuilder actionBuilder, ActionData data, boolean checked, Object parent) throws FormActionException
Creates a toolbar button based on the given action data object and returns a component handler for it. The data of this component handler will be a boolean value representing the checked state for checked toolbar buttons. For other toolbar buttons it is undefined. Just delegates to the wrappedActionManager
object.- Specified by:
createToolbarButton
in interfaceActionManager
- Parameters:
actionBuilder
- the action builderdata
- a data object defining all properties of the buttonchecked
- a flag if a checked (toggle) button should be createdparent
- the parent component (a toolbar) to which the new button should be added- Returns:
- a component handler for the new button
- Throws:
FormActionException
- if an error occurs
-
addMenuSeparator
public void addMenuSeparator(ActionBuilder actionBuilder, Object menu) throws FormActionException
Adds a separator to the specified menu. The passed in menu object must have been created using thecreateMenu()
method. Just delegates to the wrappedActionManager
object.- Specified by:
addMenuSeparator
in interfaceActionManager
- Parameters:
actionBuilder
- the action buildermenu
- the menu to which the separator should be added- Throws:
FormActionException
- if an error occurs
-
addToolBarSeparator
public void addToolBarSeparator(ActionBuilder actionBuilder, Object toolBar) throws FormActionException
Adds a separator to the specified tool bar. The passed in tool bar object must have been created using thecreateToolBar()
method. Just delegates to the wrappedActionManager
object.- Specified by:
addToolBarSeparator
in interfaceActionManager
- Parameters:
actionBuilder
- the action buildertoolBar
- the tool bar to which the separator should be added- Throws:
FormActionException
- if an error occurs
-
registerPopupMenuHandler
public void registerPopupMenuHandler(Object component, PopupMenuHandler handler, ComponentBuilderData compData) throws FormActionException
Registers the specifiedPopupMenuHandler
at the given UI component. This will cause the handler to be invoked whenever the user triggers the context menu for this component (e.g. by right clicking it with the mouse). A concrete implementation has to install a proper event listener at the component that takes care of calling the handler when it detects a gesture that should bring up the context menu. Just delegates to the wrappedActionManager
object.- Specified by:
registerPopupMenuHandler
in interfaceActionManager
- Parameters:
component
- the componenthandler
- the handler for creating the menucompData
- theComponentBuilderData
object- Throws:
FormActionException
- if an error occurs
-
-