public class ActionContainerFactory
extends java.lang.Object
For a menu or submenu, the first element in the action-list represents a menu and subsequent elements represent menu items or separators (if null).
This class can be used as a general component factory which will construct
components from Actions if the create<comp>(Action,...)
methods are used.
ActionManager
Constructor | Description |
---|---|
ActionContainerFactory() |
Constructs an container factory which uses the default
ActionManager.
|
ActionContainerFactory(ActionManager manager) |
Constructs an container factory which uses managed actions.
|
Modifier and Type | Method | Description |
---|---|---|
void |
configureButton(javax.swing.JToggleButton button,
AbstractActionExt a,
javax.swing.ButtonGroup group) |
|
protected void |
configureButtonFromExtActionProperties(javax.swing.AbstractButton button,
javax.swing.Action action) |
This method will be called after buttons created from an action.
|
protected void |
configureMenuItemFromExtActionProperties(javax.swing.JMenuItem menuItem,
javax.swing.Action action) |
This method will be called after menu items are created.
|
void |
configureSelectableButton(javax.swing.AbstractButton button,
AbstractActionExt a,
javax.swing.ButtonGroup group) |
method to configure a "selectable" button from the given AbstractActionExt.
|
javax.swing.AbstractButton |
createButton(java.lang.Object id,
javax.swing.JComponent container) |
Creates, configures and returns an AbstractButton.
|
javax.swing.AbstractButton |
createButton(javax.swing.Action action) |
Creates a button based on the attributes of the action.
|
javax.swing.AbstractButton |
createButton(javax.swing.Action action,
javax.swing.JComponent container) |
Creates a button based on the attributes of the action.
|
javax.swing.JMenu |
createMenu(java.lang.Object[] actionIds) |
Creates and returns a menu from a List which represents actions, separators
and sub-menus.
|
javax.swing.JMenu |
createMenu(java.util.List list) |
Creates and returns a menu from a List which represents actions, separators
and sub-menus.
|
javax.swing.JMenuBar |
createMenuBar(java.lang.Object[] actionIds) |
Constructs a menu tree from a list of actions or lists of lists or actions.
|
javax.swing.JMenuBar |
createMenuBar(java.util.List list) |
Constructs a menu tree from a list of actions or lists of lists or actions.
|
javax.swing.JMenuItem |
createMenuItem(javax.swing.Action action) |
Creates a menu item based on the attributes of the action.
|
javax.swing.JMenuItem |
createMenuItem(javax.swing.Action action,
javax.swing.JComponent container) |
Creates a menu item based on the attributes of the action element.
|
javax.swing.JPopupMenu |
createPopup(java.lang.Object[] list) |
Constructs a popup menu from an array of action ids.
|
javax.swing.JPopupMenu |
createPopup(java.util.List list) |
Constructs a popup menu from a list of action ids.
|
javax.swing.JToolBar |
createToolBar(java.lang.Object[] list) |
Constructs a toolbar from an action-list id.
|
javax.swing.JToolBar |
createToolBar(java.util.List list) |
Constructs a toolbar from an action-list id.
|
ActionManager |
getActionManager() |
Gets the ActionManager instance.
|
void |
setActionManager(ActionManager manager) |
Sets the ActionManager instance that will be used by this
ActionContainerFactory
|
public ActionContainerFactory()
public ActionContainerFactory(ActionManager manager)
manager
- use the actions managed with this manager for
constructing ui componenents.public ActionManager getActionManager()
setActionManager(org.jdesktop.swingx.action.ActionManager)
public void setActionManager(ActionManager manager)
public javax.swing.JToolBar createToolBar(java.lang.Object[] list)
list
- a list of action ids used to construct the toolbar.public javax.swing.JToolBar createToolBar(java.util.List list)
list
- a list of action ids used to construct the toolbar.public javax.swing.JPopupMenu createPopup(java.lang.Object[] list)
list
- an array of action ids used to construct the popup.public javax.swing.JPopupMenu createPopup(java.util.List list)
list
- a list of action ids used to construct the popup.public javax.swing.JMenuBar createMenuBar(java.lang.Object[] actionIds)
For example, If my list is [action, action, action], then nothing is added to the menu bar. However, if my list is [list[action], action, action, action] then I get a menu and under it the tree actions. This should not be, because if I wanted those actions to be on the sub menu, then they should have been listed within the sub list!
actionIds
- an array which represents the root item.public javax.swing.JMenuBar createMenuBar(java.util.List list)
For example, If my list is [action, action, action], then nothing is added to the menu bar. However, if my list is [list[action], action, action, action] then I get a menu and under it the tree actions. This should not be, because if I wanted those actions to be on the sub menu, then they should have been listed within the sub list!
list
- a list which represents the root item.public javax.swing.JMenu createMenu(java.lang.Object[] actionIds)
actionIds
- an array of action ids used to construct the menu and menu items.
the first element represents the action used for the menu,public javax.swing.JMenu createMenu(java.util.List list)
list
- a list of action ids used to construct the menu and menu items.
the first element represents the action used for the menu,public javax.swing.JMenuItem createMenuItem(javax.swing.Action action, javax.swing.JComponent container)
action
- a mangaged Actioncontainer
- the parent container may be null for non-group actions.public javax.swing.JMenuItem createMenuItem(javax.swing.Action action)
action
- an action used to create the menu itempublic javax.swing.AbstractButton createButton(java.lang.Object id, javax.swing.JComponent container)
id
- the identifercontainer
- the JComponent which parents the group, if any.public javax.swing.AbstractButton createButton(javax.swing.Action action, javax.swing.JComponent container)
action
- an action used to create the buttoncontainer
- the parent container to uniquely identify
grouped components or nullpublic javax.swing.AbstractButton createButton(javax.swing.Action action)
action
- an action used to create the buttonpublic void configureButton(javax.swing.JToggleButton button, AbstractActionExt a, javax.swing.ButtonGroup group)
button
- a
- group
- public void configureSelectableButton(javax.swing.AbstractButton button, AbstractActionExt a, javax.swing.ButtonGroup group)
It's up to the client to only pass in button's where selected and/or the group property makes sense. PENDING: the group properties are yet untested. PENDING: think about automated unconfig.
button
- where selected makes sensea
- group
- the button should be added to.java.lang.IllegalArgumentException
- if the given action doesn't have the state flag set.protected void configureButtonFromExtActionProperties(javax.swing.AbstractButton button, javax.swing.Action action)
button
- the button to be configuredaction
- the action used to construct the menu item.protected void configureMenuItemFromExtActionProperties(javax.swing.JMenuItem menuItem, javax.swing.Action action)
menuItem
- the menu item to be configuredaction
- the action used to construct the menu item.