Class ContainerTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.ComponentBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.SimpleComponentTag
-
- net.sf.jguiraffe.gui.builder.components.tags.ContainerTag
-
- All Implemented Interfaces:
Composite,ConditionalTag,org.apache.commons.jelly.Tag
- Direct Known Subclasses:
ColumnComponentTag,DesktopPanelTag,PanelTag,SplitterTag,TabTag,WindowBaseTag
public abstract class ContainerTag extends SimpleComponentTag implements Composite
A specific tag handler implementation for creating container tags.
Container tags can contain an arbitrary number of other components, which are defined as child elements of this tag. During the builder process the component tags look for their enclosing container tag and add the newly created component to it. A container can also have a layout object.
This base class already implements the major part of the functionality needed for containers. Concrete sub classes only have to define a method which creates the specific container object.
A container is a usual component, so all component properties like a font or constraints also apply to containers.
- Version:
- $Id: ContainerTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description ContainerTag()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddComponent(Object comp, Object constraints)Adds the specified component to this container using the given constraints.protected voidaddComponents(ComponentManager manager, Object container, Collection<Object[]> comps)Adds the components of this container to the container widget.protected ObjectcreateComponent(ComponentManager manager, boolean create)Creates and initializes the container.protected abstract ObjectcreateContainer(ComponentManager manager, boolean create, Collection<Object[]> components)Creates the container widget.AccessibleCompositegetComposite()Returns theAccessibleCompositeimplementation used by this container tag.ObjectgetContainer()Returns the concrete container component.ObjectgetLayout()Returns the layout for this container.protected voidprocessBeforeBody()Callback before processing of the tag's body.voidsetComposite(AccessibleComposite composite)Sets theAccessibleCompositeimplementation used by this container tag.voidsetLayout(Object layout)Sets the layout object for this container.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.SimpleComponentTag
getComponent, process
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.ComponentBaseTag
getBackColor, getBackgroundColor, getConstraints, getFont, getFontRef, getForeColor, getForegroundColor, getName, getToolTipData, insertComponent, setBackColor, setConstraints, setFont, setFontRef, setForeColor, setName, setTooltip, setTooltipres, setTooltipresgrp
-
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
-
getComposite
public AccessibleComposite getComposite()
Returns theAccessibleCompositeimplementation used by this container tag.- Returns:
- the
AccessibleComposite - Since:
- 1.3
-
setComposite
public void setComposite(AccessibleComposite composite)
Sets theAccessibleCompositeimplementation used by this container tag. Container tags make use of a defaultAccessibleCompositeobject. For special use cases, it is possible to replace this implementation by a special one. This is then used for storing components and layout objects.- Parameters:
composite- theAccessibleCompositeto be used- Since:
- 1.3
-
addComponent
public void addComponent(Object comp, Object constraints)
Adds the specified component to this container using the given constraints. This method will be called by component tags defined in the body of this tag.- Specified by:
addComponentin interfaceComposite- Parameters:
comp- the component to addconstraints- the constraints for this component
-
getLayout
public Object getLayout()
Returns the layout for this container.- Returns:
- the layout
-
setLayout
public void setLayout(Object layout)
Sets the layout object for this container. This method is called by a layout tag in the body of this tag.
-
getContainer
public Object getContainer()
Returns the concrete container component. This is the newly created component.- Specified by:
getContainerin interfaceComposite- Returns:
- the container component
-
processBeforeBody
protected void processBeforeBody() throws org.apache.commons.jelly.JellyTagException, FormBuilderExceptionCallback before processing of the tag's body. Calls#createComponent(ComponentManager)for the first time with thecreateparameter set to true. This implementation obtains theAccessibleCompositefor this tag.- Overrides:
processBeforeBodyin classSimpleComponentTag- Throws:
org.apache.commons.jelly.JellyTagException- if a script related error occursFormBuilderException- if an error occurs
-
createComponent
protected Object createComponent(ComponentManager manager, boolean create) throws org.apache.commons.jelly.JellyTagException, FormBuilderException
Creates and initializes the container. This implementation takes care of adding the components to the container widget and setting the layout. Sub classes only need to ensure that the correct container widget gets created.- Specified by:
createComponentin classSimpleComponentTag- Parameters:
manager- the component managercreate- the create flag- Returns:
- the new container widget
- Throws:
org.apache.commons.jelly.JellyTagException- if the tag is incorrectly usedFormBuilderException- if an error occurs
-
addComponents
protected void addComponents(ComponentManager manager, Object container, Collection<Object[]> comps) throws FormBuilderException
Adds the components of this container to the container widget. This method is called bycreateComponent().- Parameters:
manager- the component managercontainer- the (newly created) container widgetcomps- the collection with the components to add; the elements in this collection are of typeObject[]; each array has two elements: the component at index 0 and the assoziated layout constraint object at index 1- Throws:
FormBuilderException- if an error occurs
-
createContainer
protected abstract Object createContainer(ComponentManager manager, boolean create, Collection<Object[]> components) throws FormBuilderException, org.apache.commons.jelly.JellyTagException
Creates the container widget. This method is called by the implementation ofcreateComponent(ComponentManager, boolean). Concrete sub classes must define it to return the specific GUI container widget. The passed in collection with the child components can be used when needed for initialization. In all cases later theaddComponents()method will be called to add the children automatically (so if the children are already processed, this method should be overwritten with an empty implementation).- Parameters:
manager- the component managercreate- the create flagcomponents- a collection with the container's children- Returns:
- the container widget
- Throws:
FormBuilderException- if an error occursorg.apache.commons.jelly.JellyTagException- if the tag is incorrectly used
-
-