Class ActionControlTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.action.tags.AbstractActionDataTag
-
- net.sf.jguiraffe.gui.builder.action.tags.ActionControlTag
-
- All Implemented Interfaces:
ActionData
,ConditionalTag
,IconSupport
,org.apache.commons.jelly.Tag
- Direct Known Subclasses:
MenuItemTag
,ToolButtonTag
public abstract class ActionControlTag extends AbstractActionDataTag
Definition of an abstract base class for tag handler classes that create controls, which can be associated with actions.
This class provides basic functionality for defining an action aware control. Concrete sub classes will deal with specific controls like menu items or toolbar buttons.
This tag handler class supports two different ways of defining a control:
- All action related properties (like a text, an icon, a tool tip etc.)
can be directly set using the same properties as supported by the base class
.AbstractActionDataTag
- A reference to an action can be specified. Then the newly created control will be associated with this action and obtain its properties from there.
In addition of the attributes defined by the base class the following attributes are supported by this tag handler class:
Attribute Description Optional actionName If this attribute is set, an action with this name will be looked up, and this control will be associated with this action. In this case the values of other attributes defining action related properties will be ignored because these properties are directly obtained from the specified action. depends checked A boolean flag that determines whether the control to create should have checked semantics. This will be evaluated by concrete sub classes, which can then create specific control instances, e.g. checkbox menu items or toggle buttons. yes - Version:
- $Id: ActionControlTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description ActionControlTag()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
createActionControl(ActionManager manager, FormAction action, Object parent)
Creates a control and associates it with the given action.protected abstract ComponentHandler<?>
createElementHandler(ActionManager manager, ActionData data, Object parent)
Creates a control based on the given action data object.protected ActionBuilder
getActionBuilder()
Returns a reference to the currentActionBuilder
instance.protected ActionManager
getActionManager()
Convenience method for obtaining a reference to the currentActionManager
.String
getActionName()
Returns the name of the associated action.protected abstract Class<?>
getContainerClass()
Returns the class of the nesting container tag.Object
getTask()
Dummy implementation of this interface method.boolean
isChecked()
Returns the value of the checked flag.protected void
process()
Executes this tag.void
setActionName(String actionName)
Setter method for the actionName attribute.void
setChecked(boolean checked)
Setter method for the checked attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.action.tags.AbstractActionDataTag
checkAttributes, getAccelerator, getAcceleratorDef, getAcceleratorRef, getIcon, getMnemonicKey, getName, getText, getToolTip, processBeforeBody, setAccelerator, setAcceleratorDef, setAcceleratorRef, setIcon, setMnemonic, setMnemonicres, setName, setResgrp, setText, setTextres, setTooltip, setTooltipres
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
canProcess, canProcess, convertToClass, convertToNumberWithUnit, convertToNumberWithUnit, doTag, findContainer, getBuilderData, getBuilderData, getIfName, getResourceText, getResourceText, getUnlessName, setIfName, setUnlessName
-
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
-
-
-
-
Method Detail
-
getActionName
public String getActionName()
Returns the name of the associated action.- Returns:
- the action name
-
setActionName
public void setActionName(String actionName)
Setter method for the actionName attribute.- Parameters:
actionName
- the attribute value
-
isChecked
public boolean isChecked()
Returns the value of the checked flag.- Returns:
- the checked flag
-
setChecked
public void setChecked(boolean checked)
Setter method for the checked attribute.- Parameters:
checked
- the attribute value
-
process
protected void process() throws org.apache.commons.jelly.JellyTagException, FormBuilderException
Executes this tag. This implementation checks the provided attributes and either callscreateActionControl()
orcreateElementHandler()
to create the concrete control.- Specified by:
process
in classFormBaseTag
- Throws:
org.apache.commons.jelly.JellyTagException
- if this tag is used in an invalid wayFormBuilderException
- if an error occurs
-
getTask
public Object getTask()
Dummy implementation of this interface method. This implementation always returns null.- Returns:
- the task for the action
-
getContainerClass
protected abstract Class<?> getContainerClass()
Returns the class of the nesting container tag. This method must be defined in concrete sub classes. It is invoked by the implementation of theprocess()
method to find the tag handler class this tag must be nested inside (e.g. a menu item tag must be placed in the body of a menu tag). The class returned here must also implement the
interface.ActionContainer
- Returns:
- the nesting container tag class
-
createActionControl
protected abstract void createActionControl(ActionManager manager, FormAction action, Object parent) throws FormActionException
Creates a control and associates it with the given action. This method is invoked if theactionName
attribute is defined. It must be implemented in a concrete sub class to perform the necessary steps to create the control based on the properties of the given action.- Parameters:
manager
- the action manageraction
- the action this control should be associated withparent
- the parent container to which the new control should be added- Throws:
FormActionException
- if an error occurs
-
createElementHandler
protected abstract ComponentHandler<?> createElementHandler(ActionManager manager, ActionData data, Object parent) throws FormActionException
Creates a control based on the given action data object. This method is invoked if theactionName
attribute is not defined. A concrete sub class must implement it to perform all necessary steps for creating the control based on the given properties. The return value is a component handler instance that will be stored in the current builder data object. From there it can be accessed, e.g. for registering event handlers.- Parameters:
manager
- the action managerdata
- the action data objectparent
- the parent container to which the new control should be added- Returns:
- a component handler representing the newly created control
- Throws:
FormActionException
- if an error occurs
-
getActionBuilder
protected ActionBuilder getActionBuilder()
Returns a reference to the currentActionBuilder
instance. This instance is expected to be placed in the Jelly context.- Returns:
- the current action builder
-
getActionManager
protected ActionManager getActionManager()
Convenience method for obtaining a reference to the currentActionManager
.- Returns:
- the current action manager
-
-