public class SwingActionManager extends Object implements 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.
Constructor and Description |
---|
SwingActionManager() |
Modifier and Type | Method and Description |
---|---|
void |
addMenuSeparator(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(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.
|
FormAction |
createAction(ActionBuilder actionBuilder,
ActionData actionData)
Creates an action object.
|
Object |
createMenu(ActionBuilder actionBuilder,
Object menu,
TextIconData data,
Object parent)
Creates a menu based on the given data.
|
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 passed in data object.
|
Object |
createMenuItem(ActionBuilder actionBuilder,
FormAction formAction,
boolean checked,
Object parent)
Creates a menu item based on the given action.
|
Object |
createToolbar(ActionBuilder actionBuilder)
Creates a tool bar object.
|
ComponentHandler<?> |
createToolbarButton(ActionBuilder actionBuilder,
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(ActionBuilder actionBuilder,
FormAction formAction,
boolean checked,
Object parent)
Creates a toolbar button based on the given action.
|
void |
registerPopupMenuHandler(Object component,
PopupMenuHandler handler,
ComponentBuilderData compData)
Associates a
PopupMenuHandler with a UI component. |
public FormAction createAction(ActionBuilder actionBuilder, ActionData actionData) throws FormActionException
Action
interface.createAction
in interface ActionManager
actionBuilder
- the action builderactionData
- the properties of the new actionFormActionException
- if an error occurspublic Object createMenuItem(ActionBuilder actionBuilder, FormAction formAction, boolean checked, Object parent) throws FormActionException
checked
argument either a JMenuItem
or a
JCheckBoxMenuItem
object will be returned.createMenuItem
in interface ActionManager
actionBuilder
- the action builderformAction
- the action to associate with the menu item; this object
must implement Swing's Action
interfacechecked
- the checked flagparent
- the parent menu; this must be an instance of
JMenu
FormActionException
- if an error occurspublic ComponentHandler<?> createMenuItem(ActionBuilder actionBuilder, ActionData actionData, boolean checked, Object parent) throws FormActionException
checked
argument either a JMenuItem
or a
JCheckBoxMenuItem
object will be returned.createMenuItem
in interface ActionManager
actionBuilder
- the action builderactionData
- the action data objectchecked
- the checked flagparent
- the parent menu; this must be an instance of
JMenu
FormActionException
- if an error occurspublic Object createMenuBar(ActionBuilder actionBuilder) throws FormActionException
JMenuBar
object.createMenuBar
in interface ActionManager
actionBuilder
- the action builderFormActionException
- if an error occurspublic Object createMenu(ActionBuilder actionBuilder, Object menu, TextIconData data, Object parent) throws FormActionException
JMenu
object.createMenu
in interface ActionManager
actionBuilder
- the action buildermenu
- the menu object (null in the creation phase, a not
null JMenu
instance in the initialization phase)data
- the data for the new menuparent
- the menu's parent (a menu bar or a menu)FormActionException
- if an error occurs, i.e. if the parent is
undefinedpublic Object createToolbar(ActionBuilder actionBuilder) throws FormActionException
JToolBar
object.createToolbar
in interface ActionManager
actionBuilder
- the action builderFormActionException
- if an error occurspublic Object createToolbarButton(ActionBuilder actionBuilder, FormAction formAction, boolean checked, Object parent) throws FormActionException
checked
argument either a JButton
or a
JToggleButton
object will be returned.createToolbarButton
in interface ActionManager
actionBuilder
- the action builderformAction
- the action to associate with the menu item; this object
must implement Swing's Action
interfacechecked
- the checked flagparent
- the parent toolbar; this must be an instance of
JToolBar
FormActionException
- if an error occurspublic ComponentHandler<?> createToolbarButton(ActionBuilder actionBuilder, ActionData data, boolean checked, Object parent) throws FormActionException
checked
argument either a JButton
or a JToggleButton
object will be created.createToolbarButton
in interface ActionManager
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 of
JToolBar
FormActionException
- if an error occurspublic void addMenuSeparator(ActionBuilder actionBuilder, Object menu) throws FormActionException
JMenu
.addMenuSeparator
in interface ActionManager
actionBuilder
- the action buildermenu
- the menuFormActionException
- if an error occurspublic void addToolBarSeparator(ActionBuilder actionBuilder, Object toolBar) throws FormActionException
JToolBar
.addToolBarSeparator
in interface ActionManager
actionBuilder
- the action buildertoolBar
- the tool barFormActionException
- if an error occurspublic void registerPopupMenuHandler(Object component, PopupMenuHandler handler, ComponentBuilderData compData) throws FormActionException
PopupMenuHandler
with a UI component. This
implementation expects that the passed in object is derived from
java.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 the PopupMenuHandler
object is
invoked.registerPopupMenuHandler
in interface ActionManager
component
- the componenthandler
- the handler to registercompData
- the component builder data objectFormActionException
- if an error occursIllegalArgumentException
- if a required parameter is missingprotected void addToMenu(Object parent, JMenuItem item)
JMenu
or JPopupMenu
.parent
- the parent menuitem
- the item to addprotected void addToToolbar(Object parent, AbstractButton button)
JToolBar
.parent
- the parent tool barbutton
- the button to addCopyright © 2016 The JGUIraffe Team. All rights reserved.