Class ComponentBaseTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.ComponentBaseTag
-
- All Implemented Interfaces:
ConditionalTag
,org.apache.commons.jelly.Tag
- Direct Known Subclasses:
InputComponentTag
,SimpleComponentTag
public abstract class ComponentBaseTag extends FormBaseTag
An abstract base class for tags that create GUI components.
This class provides a framework for creating a Java (GUI) component, initializing it with a set of standard attributes (like font or color) and adding it to an enclosing container. Derived classes will mainly have to deal with the creation of a concrete component and eventually perform additional tasks.
The sub classes of this class can be divided into two groups: Tag classes for simple GUI components (which only display static content) and tag classes for input components. The latter gather user input and can be added to a
Form
object for easy validation and evaluation of the entered data.The following basic properties are supported by this tag handler base class:
- The component's foreground color using the
foreColor
attribute. - The component's background color using the
backColor
attribute. - A font for the component, which can be either directly set through the
setFont()
method or by specifying the name of a variable that exists in the context in thefontRef
attribute. - An object representing layout constraints can be attached to this
component using the
setConstraints()
method. - With the
name
attribute, the component can be given an optional name. If a name is set, it can be used for accessing this component later. - A component can be assigned a tool tip. This can be done either directly
using the
tooltip
attribute or by specifying a resource ID and an optional resource group using thetooltipres
andtooltipresgrp
attributes.
- Version:
- $Id: ComponentBaseTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ComponentBaseTag()
Creates a new instance ofComponentBaseTag
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
getBackColor()
Returns the background color for this component as a string.Color
getBackgroundColor()
Returns the background color of this component as a color object.abstract Object
getComponent()
Returns the component managed by this tag.Object
getConstraints()
Returns the constraints object for this component.Object
getFont()
Returns the font object for this component.String
getFontRef()
Returns the name of the font to be used by this component.String
getForeColor()
Returns the foreground color of this component as string.Color
getForegroundColor()
Returns the foreground color of this component as a color object.String
getName()
Returns the name of this input component.TextData
getToolTipData()
Returns aTextData
object with information about the tool tip for this component.protected void
insertComponent(String name, Object comp)
Inserts the specified component to the generated GUI.protected void
process()
Performs processing of some default attributes.void
setBackColor(String backColor)
Sets the background color for this component as a string.void
setConstraints(Object constraints)
Sets the constraints object for this component.void
setFont(Object font)
Sets the font object for this component.void
setFontRef(String fontRef)
Sets the name of the font to be used by this component.void
setForeColor(String foreColor)
Sets the foreground color of this component as string.void
setName(String name)
Setter method for the name attribute.void
setTooltip(String s)
Set method of thetooltip
attribute.void
setTooltipres(String s)
Set method of thetooltipres
attribute.void
setTooltipresgrp(String g)
Set method of thetooltipresgrp
attribute.-
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, processBeforeBody, 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
-
getBackColor
public String getBackColor()
Returns the background color for this component as a string.- Returns:
- the background color for this component
-
setBackColor
public void setBackColor(String backColor)
Sets the background color for this component as a string.- Parameters:
backColor
- the background color for this component
-
getConstraints
public Object getConstraints()
Returns the constraints object for this component.- Returns:
- the constraints object for this component
-
setConstraints
public void setConstraints(Object constraints)
Sets the constraints object for this component. This object is used when the component is added to its container.- Parameters:
constraints
- the constraints object
-
getFont
public Object getFont()
Returns the font object for this component.- Returns:
- the font for this component
-
setFont
public void setFont(Object font)
Sets the font object for this component.- Parameters:
font
- the font object for this component
-
getFontRef
public String getFontRef()
Returns the name of the font to be used by this component.- Returns:
- the font reference
-
setFontRef
public void setFontRef(String fontRef)
Sets the name of the font to be used by this component. This font must have been created earlier by a<font>
tag and stored under this name in the jelly context.- Parameters:
fontRef
- the name of the font to set
-
getForeColor
public String getForeColor()
Returns the foreground color of this component as string.- Returns:
- the foreground color of this component
-
setForeColor
public void setForeColor(String foreColor)
Sets the foreground color of this component as string.- Parameters:
foreColor
- the foreground color of this component
-
getBackgroundColor
public Color getBackgroundColor()
Returns the background color of this component as a color object.- Returns:
- the component's background color
-
getForegroundColor
public Color getForegroundColor()
Returns the foreground color of this component as a color object.- Returns:
- the component's foreground color
-
getName
public String getName()
Returns the name of this input component.- Returns:
- the component's name
-
setName
public void setName(String name)
Setter method for the name attribute.- Parameters:
name
- the attribute value
-
setTooltip
public void setTooltip(String s)
Set method of thetooltip
attribute.- Parameters:
s
- the tool tip text
-
setTooltipres
public void setTooltipres(String s)
Set method of thetooltipres
attribute.- Parameters:
s
- the resource ID for the tool tip
-
setTooltipresgrp
public void setTooltipresgrp(String g)
Set method of thetooltipresgrp
attribute.- Parameters:
g
- the resource group for the tool tip
-
getToolTipData
public TextData getToolTipData()
Returns aTextData
object with information about the tool tip for this component.- Returns:
- the
TextData
object for this component's tool tip
-
getComponent
public abstract Object getComponent()
Returns the component managed by this tag. This is the component that was created by the tag and that will be placed in the UI. Note that this object may only be available (and fully initialized) after this tag was completely executed.- Returns:
- the component managed by this tag
-
insertComponent
protected void insertComponent(String name, Object comp)
Inserts the specified component to the generated GUI. This method takes care that the given component is added to the appropriate container (which can be either defined by an enclosing container tag or can be the root container). If the name is defined, the component will also be added to an internal table maintained by theComponentBuilderData
instance so that it can be accessed again later.- Parameters:
name
- the name under which the component is to be storedcomp
- the component itself
-
process
protected void process() throws FormBuilderException, org.apache.commons.jelly.JellyTagException
Performs processing of some default attributes. Should be called by derived classes.- Specified by:
process
in classFormBaseTag
- Throws:
FormBuilderException
- if attributes have invalid namesorg.apache.commons.jelly.JellyTagException
- if a tag related error occurs
-
-