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
ActionManagerinterface.This class implements the
ActionManagermethods 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 voidaddMenuSeparator(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object menu)Adds a separator to the given menu.protected voidaddToMenu(Object parent, JMenuItem item)Adds a menu item to a parent menu.voidaddToolBarSeparator(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, Object toolBar)Adds a separator to the given tool bar.protected voidaddToToolbar(Object parent, AbstractButton button)Adds a tool button to the parent bar.net.sf.jguiraffe.gui.builder.action.FormActioncreateAction(net.sf.jguiraffe.gui.builder.action.ActionBuilder actionBuilder, net.sf.jguiraffe.gui.builder.action.ActionData actionData)Creates an action object.ObjectcreateMenu(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.ObjectcreateMenuBar(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.ObjectcreateMenuItem(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.ObjectcreateToolbar(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.ObjectcreateToolbarButton(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.voidregisterPopupMenuHandler(Object component, net.sf.jguiraffe.gui.builder.action.PopupMenuHandler handler, net.sf.jguiraffe.gui.builder.components.ComponentBuilderData compData)Associates aPopupMenuHandlerwith 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.FormActionExceptionCreates an action object. The returned object will also implement Swing'sActioninterface.- Specified by:
createActionin 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 thecheckedargument either aJMenuItemor aJCheckBoxMenuItemobject will be returned.- Specified by:
createMenuItemin 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'sActioninterfacechecked- 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.FormActionExceptionCreates a menu item based on the passed in data object. Depending on thecheckedargument either aJMenuItemor aJCheckBoxMenuItemobject will be returned.- Specified by:
createMenuItemin 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 newJMenuBarobject.- Specified by:
createMenuBarin 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 aJMenuobject.- Specified by:
createMenuin interfacenet.sf.jguiraffe.gui.builder.action.ActionManager- Parameters:
actionBuilder- the action buildermenu- the menu object (null in the creation phase, a not nullJMenuinstance 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 aJToolBarobject.- Specified by:
createToolbarin 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 thecheckedargument either aJButtonor aJToggleButtonobject will be returned.- Specified by:
createToolbarButtonin 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'sActioninterfacechecked- 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.FormActionExceptionCreates a toolbar button based on the passed in action data object and returns a component handler for it. Depending on thecheckedargument either aJButtonor aJToggleButtonobject will be created.- Specified by:
createToolbarButtonin 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.FormActionExceptionAdds a separator to the given menu. The passed in menu must be an instance ofJMenu.- Specified by:
addMenuSeparatorin 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.FormActionExceptionAdds a separator to the given tool bar. The passed in object must be an instance ofJToolBar.- Specified by:
addToolBarSeparatorin 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 aPopupMenuHandlerwith 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 thePopupMenuHandlerobject is invoked.- Specified by:
registerPopupMenuHandlerin 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 ofJMenuorJPopupMenu.- 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
-
-