net.sf.jguiraffe.gui.builder.action.tags
Class ActionControlTag

java.lang.Object
  extended by org.apache.commons.jelly.TagSupport
      extended by net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
          extended by net.sf.jguiraffe.gui.builder.action.tags.ActionDataTag
              extended by 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 ActionDataTag

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:

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 156 2009-03-03 21:04:47Z oheger $
Author:
Oliver Heger

Field Summary
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
ActionControlTag()
           
 
Method Summary
protected abstract  void createActionControl(ActionManager manager, FormAction action, java.lang.Object parent)
          Creates a control and associates it with the given action.
protected abstract  ComponentHandler<?> createElementHandler(ActionManager manager, ActionData data, java.lang.Object parent)
          Creates a control based on the given action data object.
protected  ActionBuilder getActionBuilder()
          Returns a reference to the current ActionBuilder instance.
protected  ActionManager getActionManager()
          Convenience method for obtaining a reference to the current ActionManager.
 java.lang.String getActionName()
          Returns the name of the associated action.
protected abstract  java.lang.Class<?> getContainerClass()
          Returns the class of the nesting container tag.
 java.lang.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(java.lang.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.ActionDataTag
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, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
 

Constructor Detail

ActionControlTag

public ActionControlTag()
Method Detail

getActionName

public java.lang.String getActionName()
Returns the name of the associated action.

Returns:
the action name

setActionName

public void setActionName(java.lang.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 calls createActionControl() or createElementHandler() to create the concrete control.

Specified by:
process in class FormBaseTag
Throws:
org.apache.commons.jelly.JellyTagException - if this tag is used in an invalid way
FormBuilderException - if an error occurs

getTask

public java.lang.Object getTask()
Dummy implementation of this interface method. This implementation always returns null.

Returns:
the task for the action

getContainerClass

protected abstract java.lang.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 the process() 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 ActionContainer interface.

Returns:
the nesting container tag class

createActionControl

protected abstract void createActionControl(ActionManager manager,
                                            FormAction action,
                                            java.lang.Object parent)
                                     throws FormActionException
Creates a control and associates it with the given action. This method is invoked if the actionName 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 manager
action - the action this control should be associated with
parent - 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,
                                                            java.lang.Object parent)
                                                     throws FormActionException
Creates a control based on the given action data object. This method is invoked if the actionName 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 manager
data - the action data object
parent - 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 current ActionBuilder 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 current ActionManager.

Returns:
the current action manager


Copyright © 2009 The JGUIraffe Team. All Rights Reserved.