Class TabbedPaneTag
- 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.InputComponentTag
-
- net.sf.jguiraffe.gui.builder.components.tags.TabbedPaneTag
-
- All Implemented Interfaces:
Composite
,ConditionalTag
,org.apache.commons.jelly.Tag
public class TabbedPaneTag extends InputComponentTag implements Composite
A specialized tag handler implementation for creating a tabbed pane.
A tabbed pane provides an arbitrary number of registers, from which the user can select one. The content of this register is then displayed while all others are invisible.
To fully define a tabbed pane in a builder script this tag is used together with the
TabTag
tag: For each register a<register>
tag is to be placed in the body of this tag, in which the properties of the register are set. When the tag is processed the currentComponentManager
implementation will construct proper tab components from this data.Though a tabbed pane itself usually does not contribute to the input data a user can enter in a form, these components are here treated as input components. The reason is that they have a state (the index of the selected register) that can be queried and altered by application code. This can be done through the
ComponentHandler
object that is created for the tabbed pane. This handler can also be used to register a change listener that will be notified when ever the selected tab register changes. However per default for a tabbed pane no form element will be created (i.e. thenoField
property is set to false).The following table lists the attributes that are supported by this tag. Note that some of the properties defined here may not be available in all underlying GUI libraries:
Attribute Description Optional placement With this property the placement of the registers can be specified. It can have one of the values left, right, top, or bottom. The default value is top. Yes name Because tabbed panes are regular input components they can be given a name, under which they can be accessed. However the name is optional. If none is defined, a name of the following form is automatically generated: tabbedPane<n>
with <n> being a serial number starting at 1.Yes - Version:
- $Id: TabbedPaneTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TabbedPaneTag.Placement
An enumeration class that defines the valid values for theplacement
attribute.static class
TabbedPaneTag.TabData
A data class that holds all properties of a register that can be added to a tabbed pane.
-
Field Summary
Fields Modifier and Type Field Description static String
AUTO_NAME_PREFIX
Constant for the prefix for automatically generated tab names.
-
Constructor Summary
Constructors Constructor Description TabbedPaneTag()
Creates a new instance ofTabbedPaneTag
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComponent(Object comp, Object constraints)
Adds a child component to this composite object.protected ComponentHandler<?>
createComponentHandler(ComponentManager manager, boolean create)
Creates the component handler object for the represented component.protected String
generateAutoName()
Generates a name for this tabbed pane.Object
getContainer()
Returns the container object.String
getPlacement()
Returns the string value of the placement attribute.TabbedPaneTag.Placement
getPlacementValue()
Returns the placement of this tabbed pane's registers.Collection<TabbedPaneTag.TabData>
getTabs()
Returns a collection with the tabs of this tabbed pane.protected void
process()
Processes this tag.void
setLayout(Object layout)
Sets a layout for this container.void
setPlacement(String v)
Set method of the placement attribute.void
setPlacementValue(TabbedPaneTag.Placement p)
Allows to directly specify a placement value.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.InputComponentTag
addToGroups, checkName, createFieldHandler, getComponent, getComponentHandler, getComponentType, getDisplayName, getFieldValidator, getFormValidator, getGroups, getPropertyName, getReadTransformer, getTypeName, getWriteTransformer, handleGroups, insertField, isNoField, processBeforeBody, setComponentType, setDisplayName, setDisplayNamegrp, setDisplayNameres, setFieldValidator, setFormValidator, setGroups, setNoField, setPropertyName, setReadTransformer, setTypeName, setWriteTransformer
-
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
-
-
-
-
Field Detail
-
AUTO_NAME_PREFIX
public static final String AUTO_NAME_PREFIX
Constant for the prefix for automatically generated tab names.- See Also:
- Constant Field Values
-
-
Method Detail
-
getPlacement
public String getPlacement()
Returns the string value of the placement attribute.- Returns:
- the placement as string
-
setPlacement
public void setPlacement(String v)
Set method of the placement attribute.- Parameters:
v
- the attribute's value
-
getPlacementValue
public TabbedPaneTag.Placement getPlacementValue()
Returns the placement of this tabbed pane's registers.- Returns:
- the placement of the registers
-
setPlacementValue
public void setPlacementValue(TabbedPaneTag.Placement p)
Allows to directly specify a placement value. (This is used for testing mainly.)- Parameters:
p
- the new placement value
-
addComponent
public void addComponent(Object comp, Object constraints)
Adds a child component to this composite object. This implementation expects that the child component is aTabData
object. Otherwise an exception is thrown. The constraints will be ignored.- Specified by:
addComponent
in interfaceComposite
- Parameters:
comp
- the child component to be addedconstraints
- the layout constraints object- Throws:
FormBuilderRuntimeException
- if the passed in component is not aTabData
object
-
getContainer
public Object getContainer()
Returns the container object. This is not needed for this tag.- Specified by:
getContainer
in interfaceComposite
- Returns:
- the container object
-
setLayout
public void setLayout(Object layout)
Sets a layout for this container. For a tabbed pane layout objects are not supported, so an exception will be thrown.
-
getTabs
public Collection<TabbedPaneTag.TabData> getTabs()
Returns a collection with the tabs of this tabbed pane. This information will be evaluated by the component manager to create the tab pages.- Returns:
- a collection with all defined tabs
-
process
protected void process() throws FormBuilderException, org.apache.commons.jelly.JellyTagException
Processes this tag. This implementation ensures that always a name is specified for this component - either in the script a name was defined or one is generated automatically.- Overrides:
process
in classInputComponentTag
- Throws:
FormBuilderException
- if the tag is incorrectly usedorg.apache.commons.jelly.JellyTagException
- if an error occurs
-
createComponentHandler
protected ComponentHandler<?> createComponentHandler(ComponentManager manager, boolean create) throws FormBuilderException, org.apache.commons.jelly.JellyTagException
Creates the component handler object for the represented component. This implementation will ask the component manager to create a tabbed pane object and its corresponding component handler.- Specified by:
createComponentHandler
in classInputComponentTag
- Parameters:
manager
- the component handlercreate
- the create flag- Returns:
- the component handler for the new component
- Throws:
FormBuilderException
- if the tag is incorrectly usedorg.apache.commons.jelly.JellyTagException
- if the tag is incorrectly used
-
generateAutoName
protected String generateAutoName()
Generates a name for this tabbed pane. This method is called when no name was specified. It must return a unique default name. This implementation uses the prefix defined by theAUTO_NAME_PREFIX
constant and adds a serial number to it.- Returns:
- an auto generated name for this component
-
-