|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ehsbe.commons.action.ActionContainerFactory
public class ActionContainerFactory
Creates user interface elements based on action and action IDs.
All actions and action IDs must represent actions managed by the passed
ActionManager
. Otherwise no UI element is created.
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 Summary | |
---|---|
ActionContainerFactory()
|
Method Summary | |
---|---|
static void |
configure(AbstractButton button,
Action action,
ActionManager manager)
Configure the given button by the given action using the given action manager ;-) At the moment it configures just the extended properties provided by AbstractActionExt actions. |
static AbstractButton |
createButton(Action action,
ActionManager manager)
Creates a button based on the attributes of the given action. |
static AbstractButton |
createButton(Object id,
ActionManager manager)
Creates a button based on the action with the given ID. |
static AbstractButton |
createButton(Object id,
ActionManager manager,
boolean copy)
Creates a button based on the action with the given ID. |
static AbstractButton[] |
createButtons(List<Action> list,
ActionManager manager)
Creates an array of buttons using the given list. |
static AbstractButton[] |
createButtons(String id,
ActionManager manager)
Creates an array of buttons using the possible nested list of action IDs with the given id. |
static JComponent |
createMenu(List<?> list,
JComponent parent,
ActionManager manager)
Create a menu tree from the given list of action IDs and lists of action IDs. |
static JMenu |
createMenu(Object actionId,
ActionManager manager)
Create a single JMenu from the action with the given id. |
static JMenuBar |
createMenuBar(List<?> list,
ActionManager manager)
Populate a menubar from a action list. |
static JMenuItem |
createMenuItem(Action action,
ActionManager manager)
Creates a menu item based on the attributes of the given action. |
static JMenuItem |
createMenuItem(Object id,
ActionManager manager)
Creates a menu item based on the attributes of the action element. |
static JPopupMenu |
createPopup(List<?> list,
ActionManager manager)
Constructs a popup menu from a list of action ids. |
static JToolBar |
createToolBar(List<?> list,
ActionManager manager)
Constructs a toolbar from an action-list id. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActionContainerFactory()
Method Detail |
---|
public static JToolBar createToolBar(List<?> list, ActionManager manager)
For each ID, which refers to an action managed by the submitted action
manager, a button gets created and append to the toolbar. If a ID is
null
, a JSeparator
will be added instead.
list
- a list of action IDsmanager
- the manager, which contains the actions referenced by the action
IDs
createButton(Action, ActionManager)
public static JPopupMenu createPopup(List<?> list, ActionManager manager)
list
- a possibkly nested list of action IDs to be used to
construct the popup.manager
- the manager, which contains the actions referenced by the action
IDs and action IDS in the action lists
createMenu(List, JComponent, ActionManager)
public static JMenuBar createMenuBar(List<?> list, ActionManager manager)
list
- a possibly nested list of action IDs to used to construct the popup.manager
- the manager, which contains the actions referenced by the action
IDs and action IDs in the action lists
createMenu(List, JComponent, ActionManager)
public static JMenu createMenu(Object actionId, ActionManager manager)
actionId
- ID of the action to be used for JMenu configurationmanager
- the manager, which contains the action with the given ID
null
if the action for the given ID has not been
found, the new JMenu otherwise.public static JComponent createMenu(List<?> list, JComponent parent, ActionManager manager)
If parent is null
, it is tried to
to create a JMenu
from the first entry in the given
list (which should actually represent an ID of an action).
If that fails, null
is returned. Otherwise
the created JMenu is used as parent and returned after the creation of
the menu tree.
For each subsequent entry in the given list a
JMenuItem (for action IDs) or JMenus (for action ID lists) or
JSeparators (for null
) will be created and append to the
parent.
list
- a possibly nested list of action IDsparent
- where to append created JMenus and JMenuItemsmanager
- the manager, which contains the actions referenced by the
action IDs in the given list and its sublists.
null
, the parent itself.
Otherwise the newly created JMenu (which might be null
,
if the given list is empty or its first entry references an unknown
action).createMenu(Object, ActionManager)
,
createMenuItem(Object, ActionManager)
,
ActionManager.getAction(Object)
public static JMenuItem createMenuItem(Object id, ActionManager manager)
id
- action IDmanager
- the manager, which contains the actions referenced the given
action ID
null
if the manager has no action with the given
id or is null
, a JMenuItem or subclass
depending on type otherwise.createMenuItem(Action, ActionManager)
public static JMenuItem createMenuItem(Action action, ActionManager manager)
action
- an action managed by the given action managermanager
- the manager, which contains the given action. If
null
, menu button groups are not initialized (see
configure(AbstractButton, Action, ActionManager)
.
null
if the given action is null
.AbstractButton.setAction(Action)
public static AbstractButton createButton(Object id, ActionManager manager, boolean copy)
id
- the id of the managed action to usemanager
- the manager, which contains the actions with the given IDcopy
- if true
ask the action manager for an action copy and
use the copy to create the button
null
.createButton(Action, ActionManager)
public static AbstractButton createButton(Object id, ActionManager manager)
createButton(id, manager, false);
id
- the id of the managed action to usemanager
- the manager, which contains the actions with the given ID
null
.createButton(Action, ActionManager)
public static AbstractButton createButton(Action action, ActionManager manager)
action
- an action managed by the given action managermanager
- the manager, which contains the given action. If
null
, button groups are not initialized (see
configure(AbstractButton, Action, ActionManager)
.
null
if the given action is null
.AbstractButton.setAction(Action)
public static AbstractButton[] createButtons(List<Action> list, ActionManager manager)
list
- list of actions or action IDsmanager
- manager to use to retrieve related actions
public static AbstractButton[] createButtons(String id, ActionManager manager)
id
- ID of the action ID list to use.manager
- manager to use to retrieve the related action list
public static void configure(AbstractButton button, Action action, ActionManager manager)
At the moment it configures just the extended properties provided by
AbstractActionExt
actions. I.e. will set selection state of the
button, long description as tooltip, large icon as button icon (if
available) and add the action as ItemListener
, if
it is a stateful action (see AbstractActionExt.isStateAction()
).
It does not configure basic properties like name etc., since this is
usually already done, when the button has been created. If you need to
do a basic configuration, AbstractButton.setAction(Action)
might be one easy variant to do that.
button
- button to configureaction
- action to use for configurationmanager
- manager, which manages the given action. If
null
, group buttons are not bound to any
button group.
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |