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
Formobject 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
foreColorattribute. - The component's background color using the
backColorattribute. - 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 thefontRefattribute. - An object representing layout constraints can be attached to this
component using the
setConstraints()method. - With the
nameattribute, 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
tooltipattribute or by specifying a resource ID and an optional resource group using thetooltipresandtooltipresgrpattributes.
- Version:
- $Id: ComponentBaseTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedComponentBaseTag()Creates a new instance ofComponentBaseTag.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringgetBackColor()Returns the background color for this component as a string.ColorgetBackgroundColor()Returns the background color of this component as a color object.abstract ObjectgetComponent()Returns the component managed by this tag.ObjectgetConstraints()Returns the constraints object for this component.ObjectgetFont()Returns the font object for this component.StringgetFontRef()Returns the name of the font to be used by this component.StringgetForeColor()Returns the foreground color of this component as string.ColorgetForegroundColor()Returns the foreground color of this component as a color object.StringgetName()Returns the name of this input component.TextDatagetToolTipData()Returns aTextDataobject with information about the tool tip for this component.protected voidinsertComponent(String name, Object comp)Inserts the specified component to the generated GUI.protected voidprocess()Performs processing of some default attributes.voidsetBackColor(String backColor)Sets the background color for this component as a string.voidsetConstraints(Object constraints)Sets the constraints object for this component.voidsetFont(Object font)Sets the font object for this component.voidsetFontRef(String fontRef)Sets the name of the font to be used by this component.voidsetForeColor(String foreColor)Sets the foreground color of this component as string.voidsetName(String name)Setter method for the name attribute.voidsetTooltip(String s)Set method of thetooltipattribute.voidsetTooltipres(String s)Set method of thetooltipresattribute.voidsetTooltipresgrp(String g)Set method of thetooltipresgrpattribute.-
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 thetooltipattribute.- Parameters:
s- the tool tip text
-
setTooltipres
public void setTooltipres(String s)
Set method of thetooltipresattribute.- Parameters:
s- the resource ID for the tool tip
-
setTooltipresgrp
public void setTooltipresgrp(String g)
Set method of thetooltipresgrpattribute.- Parameters:
g- the resource group for the tool tip
-
getToolTipData
public TextData getToolTipData()
Returns aTextDataobject with information about the tool tip for this component.- Returns:
- the
TextDataobject 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 theComponentBuilderDatainstance 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.JellyTagExceptionPerforms processing of some default attributes. Should be called by derived classes.- Specified by:
processin classFormBaseTag- Throws:
FormBuilderException- if attributes have invalid namesorg.apache.commons.jelly.JellyTagException- if a tag related error occurs
-
-