Class 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 Detail

      • ContainerTag

        public ContainerTag()
    • Method Detail

      • getComposite

        public AccessibleComposite getComposite()
        Returns the AccessibleComposite implementation used by this container tag.
        Returns:
        the AccessibleComposite
        Since:
        1.3
      • setComposite

        public void setComposite​(AccessibleComposite composite)
        Sets the AccessibleComposite implementation used by this container tag. Container tags make use of a default AccessibleComposite object. 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 - the AccessibleComposite to 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:
        addComponent in interface Composite
        Parameters:
        comp - the component to add
        constraints - 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.
        Specified by:
        setLayout in interface Composite
        Parameters:
        layout - the layout to set
      • getContainer

        public Object getContainer()
        Returns the concrete container component. This is the newly created component.
        Specified by:
        getContainer in interface Composite
        Returns:
        the container component
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Callback before processing of the tag's body. Calls #createComponent(ComponentManager) for the first time with the create parameter set to true. This implementation obtains the AccessibleComposite for this tag.
        Overrides:
        processBeforeBody in class SimpleComponentTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if a script related error occurs
        FormBuilderException - 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:
        createComponent in class SimpleComponentTag
        Parameters:
        manager - the component manager
        create - the create flag
        Returns:
        the new container widget
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is incorrectly used
        FormBuilderException - 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 by createComponent().
        Parameters:
        manager - the component manager
        container - the (newly created) container widget
        comps - the collection with the components to add; the elements in this collection are of type Object[]; 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 of createComponent(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 the addComponents() 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 manager
        create - the create flag
        components - a collection with the container's children
        Returns:
        the container widget
        Throws:
        FormBuilderException - if an error occurs
        org.apache.commons.jelly.JellyTagException - if the tag is incorrectly used