Class ComponentManagerWrapper
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.components.ComponentManagerWrapper
-
- All Implemented Interfaces:
ComponentManager
public abstract class ComponentManagerWrapper extends Object implements ComponentManager
A base class for wrapper implementations of the
ComponentManager
interface.An instance of this class is initialized with a reference to a
ComponentManager
object. All methods simply delegate to this object.This class is especially useful if a custom implementation of
ComponentManager
is to be created based on an existing implementation. Then only the methods to be customized have to be implemented. All other methods can still delegate to the existing implementation.- Version:
- $Id: ComponentManagerWrapper.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ComponentManagerWrapper(ComponentManager wrapped)
Creates a new instance ofComponentManagerWrapper
and initializes it with the wrappedComponentManager
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContainerComponent(Object container, Object component, Object constraints)
Adds a component to a container using the specified constraints.Object
createBorderLayout(BorderLayoutTag tag)
Creates a border layout object whose parameters are obtained form the specified tag.ComponentHandler<Boolean>
createButton(ButtonTag tag, boolean create)
Creates a button component.Object
createButtonLayout(ButtonLayoutTag tag)
Creates a button layout object whose parameters are obtained from the specified tag.ComponentHandler<Boolean>
createCheckbox(CheckboxTag tag, boolean create)
Creates a component handler that wraps a checkbox.ComponentHandler<Object>
createComboBox(ComboBoxTag tag, boolean create)
Creates a component handler that wraps a combo box.Object
createDesktopPanel(DesktopPanelTag tag, boolean create)
Creates a desktop panel whose parameters are obtained from the specified tag.PlatformEventManager
createEventManager()
Returns a concrete implementation of thePlatformEventManager
interface for dealing with event notifications.Object
createFont(FontTag tag)
Creates a font object from the data specified by the givenFontTag
.Object
createIcon(Locator locator)
Creates an icon object with the data obtained from the specifiedLocator
Object
createLabel(LabelTag tag, boolean create)
Creates a label object.ComponentHandler<Object>
createListBox(ListBoxTag tag, boolean create)
Creates a component handler that wraps a list box.Object
createPanel(PanelTag tag, boolean create)
Creates a panel whose parameters are obtained from the specified tag.ComponentHandler<String>
createPasswordField(PasswordFieldTag tag, boolean create)
Creates aComponentHandler
that wraps a password text field.Object
createPercentLayout(PercentLayoutTag tag)
Creates a percent layout object whose parameters are obtained from the specified tag.ComponentHandler<Integer>
createProgressBar(ProgressBarTag tag, boolean create)
Creates a component handler that wraps a progress bar element.ComponentHandler<Boolean>
createRadioButton(RadioButtonTag tag, boolean create)
Creates a component handler that wraps a radio button.Object
createRadioGroup(Map<String,Object> radioButtons)
Creates a radio group which contains the radio buttons stored in the passed in map.ComponentHandler<Integer>
createSlider(SliderTag tag, boolean create)
Creates a component handler that wraps a slider component.Object
createSplitter(SplitterTag tag, boolean create)
Creates a splitter whose parameters are obtained from the specified tag.ComponentHandler<StaticTextData>
createStaticText(StaticTextTag tag, boolean create)
Creates a component handler that wraps a static text element.ComponentHandler<Integer>
createTabbedPane(TabbedPaneTag tag, boolean create)
Creates a component handler that wraps a tabbed pane.ComponentHandler<Object>
createTable(TableTag tag, boolean create)
Creates a table based on the information stored in the passed in table tag.ComponentHandler<String>
createTextArea(TextAreaTag tag, boolean create)
Creates a component handler that wraps a text area.ComponentHandler<String>
createTextField(TextFieldTag tag, boolean create)
Creates a component handler that wraps a text field.ComponentHandler<Boolean>
createToggleButton(ToggleButtonTag tag, boolean create)
Creates a toggle button component.ComponentHandler<Object>
createTree(TreeTag tag, boolean create)
Creates a tree component based on the information stored in the passed in tree tag.WidgetHandler
getWidgetHandlerFor(Object component)
Returns aWidgetHandler
for the specified component.ComponentManager
getWrappedComponentManager()
Returns a reference to the wrappedComponentManager
object.void
linkLabel(Object label, Object component, String text)
Associates a link with another component.void
setContainerLayout(Object container, Object layout)
Defines the layout manager for a container.
-
-
-
Constructor Detail
-
ComponentManagerWrapper
protected ComponentManagerWrapper(ComponentManager wrapped)
Creates a new instance ofComponentManagerWrapper
and initializes it with the wrappedComponentManager
. Note: This method does not check whether the passed inComponentManager
object is null because we do not want to enforce this restriction on all subclasses. The passed in wrapped component manager is stored in an internal field and can be accessed using thegetWrappedComponentManager()
method. If a subclass needs another mechanism to access the wrapped manager, it has to override thegetWrappedComponentManager()
method.- Parameters:
wrapped
- the wrappedComponentManager
-
-
Method Detail
-
getWrappedComponentManager
public ComponentManager getWrappedComponentManager()
Returns a reference to the wrappedComponentManager
object.- Returns:
- the wrapped
ComponentManager
object
-
addContainerComponent
public void addContainerComponent(Object container, Object component, Object constraints)
Adds a component to a container using the specified constraints. This method is called to populate container objects. Just delegates to the wrappedComponentManager
object.- Specified by:
addContainerComponent
in interfaceComponentManager
- Parameters:
container
- the containercomponent
- the component which is to be added to the containerconstraints
- a generic constraints object; this object must be compatible with the layout manager set for the container; it may be null
-
setContainerLayout
public void setContainerLayout(Object container, Object layout)
Defines the layout manager for a container. Just delegates to the wrappedComponentManager
object.- Specified by:
setContainerLayout
in interfaceComponentManager
- Parameters:
container
- the containerlayout
- the new layout manager
-
createEventManager
public PlatformEventManager createEventManager()
Returns a concrete implementation of thePlatformEventManager
interface for dealing with event notifications. This method is called once when the event handling features are used for the first time. Just delegates to the wrappedComponentManager
object.- Specified by:
createEventManager
in interfaceComponentManager
- Returns:
- the platform specific event manager
-
getWidgetHandlerFor
public WidgetHandler getWidgetHandlerFor(Object component)
Returns aWidgetHandler
for the specified component. This method is called byComponentBuilderData
when the user asks for a handler to a certain component. The passed in object is one of the components that was created during the last builder operation. An implementation may throw a runtime exception if a widget handler for the passed in component cannot be obtained. Just delegates to the wrappedComponentManager
object.- Specified by:
getWidgetHandlerFor
in interfaceComponentManager
- Parameters:
component
- the component- Returns:
- a
WidgetHandler
wrapping the specified component
-
createLabel
public Object createLabel(LabelTag tag, boolean create) throws FormBuilderException
Creates a label object. All needed properties are extracted from the passed in tag. Just delegates to the wrappedComponentManager
object.- Specified by:
createLabel
in interfaceComponentManager
- Parameters:
tag
- the label tagcreate
- the create flag- Returns:
- the new label
- Throws:
FormBuilderException
- if an error occurs
-
linkLabel
public void linkLabel(Object label, Object component, String text) throws FormBuilderException
Associates a link with another component. This method will be called if thecomponentref
attribute of aLabelTag
was used to define a link between a lable and another component. An implementation will have to use library specific methods to establish such a connection. Eventually the label's text has to be set to the given text (this is the case if the label is undefined; its text is then obtained from the component's display name). Just delegates to the wrappedComponentManager
object.- Specified by:
linkLabel
in interfaceComponentManager
- Parameters:
label
- the label (as returned by thecreateLabel()
methodcomponent
- the component to be linked to the labeltext
- an optional text to be set for the label; can be null, then no text has to be set- Throws:
FormBuilderException
- if an error occurs
-
createIcon
public Object createIcon(Locator locator) throws FormBuilderException
Creates an icon object with the data obtained from the specifiedLocator
Just delegates to the wrappedComponentManager
object.- Specified by:
createIcon
in interfaceComponentManager
- Parameters:
locator
- theLocator
pointing to the data- Returns:
- the new icon object
- Throws:
FormBuilderException
- if an error occurs
-
createFont
public Object createFont(FontTag tag) throws FormBuilderException
Creates a font object from the data specified by the givenFontTag
. Just delegates to the wrappedComponentManager
object.- Specified by:
createFont
in interfaceComponentManager
- Parameters:
tag
- theFontTag
- Returns:
- the newly created font
- Throws:
FormBuilderException
- if an error occurs
-
createPercentLayout
public Object createPercentLayout(PercentLayoutTag tag) throws FormBuilderException
Creates a percent layout object whose parameters are obtained from the specified tag. Just delegates to the wrappedComponentManager
object.- Specified by:
createPercentLayout
in interfaceComponentManager
- Parameters:
tag
- the percent layout tag- Returns:
- the new layout object
- Throws:
FormBuilderException
- if an error occurs
-
createButtonLayout
public Object createButtonLayout(ButtonLayoutTag tag) throws FormBuilderException
Creates a button layout object whose parameters are obtained from the specified tag. Just delegates to the wrappedComponentManager
object.- Specified by:
createButtonLayout
in interfaceComponentManager
- Parameters:
tag
- the button layout tag- Returns:
- the new layout object
- Throws:
FormBuilderException
- if an error occurs
-
createBorderLayout
public Object createBorderLayout(BorderLayoutTag tag) throws FormBuilderException
Creates a border layout object whose parameters are obtained form the specified tag. Just delegates to the wrappedComponentManager
object.- Specified by:
createBorderLayout
in interfaceComponentManager
- Parameters:
tag
- the border layout tag- Returns:
- the new layout object
- Throws:
FormBuilderException
- if an error occurs
-
createPanel
public Object createPanel(PanelTag tag, boolean create) throws FormBuilderException
Creates a panel whose parameters are obtained from the specified tag. Just delegates to the wrappedComponentManager
object.- Specified by:
createPanel
in interfaceComponentManager
- Parameters:
tag
- the panel tagcreate
- the create flag- Returns:
- the new panel object
- Throws:
FormBuilderException
- if an error occurs
-
createDesktopPanel
public Object createDesktopPanel(DesktopPanelTag tag, boolean create) throws FormBuilderException
Creates a desktop panel whose parameters are obtained from the specified tag. The desktop panel can be used as basic background for MDI child windows. Just delegates to the wrappedComponentManager
object.- Specified by:
createDesktopPanel
in interfaceComponentManager
- Parameters:
tag
- the desktop panel tagcreate
- the create flag- Returns:
- the new desktop panel object
- Throws:
FormBuilderException
- if an error occurs
-
createSplitter
public Object createSplitter(SplitterTag tag, boolean create) throws FormBuilderException
Creates a splitter whose parameters are obtained from the specified tag. Just delegates to the wrappedComponentManager
object.- Specified by:
createSplitter
in interfaceComponentManager
- Parameters:
tag
- the splitter tagcreate
- the create flag- Returns:
- the new splitter component
- Throws:
FormBuilderException
- if an error occurs
-
createRadioGroup
public Object createRadioGroup(Map<String,Object> radioButtons) throws FormBuilderException
Creates a radio group which contains the radio buttons stored in the passed in map. Radio groups are treated as non visual components that merely implement the radio logic. They will not be inserted into a GUI container. The passed in map contains the names of the radio buttons as keys and the corresponding component objects as values. Just delegates to the wrappedComponentManager
object.- Specified by:
createRadioGroup
in interfaceComponentManager
- Parameters:
radioButtons
- a map with the radio button components that belong to the group- Returns:
- the new radio group
- Throws:
FormBuilderException
- if an error occurs
-
createButton
public ComponentHandler<Boolean> createButton(ButtonTag tag, boolean create) throws FormBuilderException
Creates a button component. All needed properties are extracted from the passed in tag. Buttons (or to be more precise: command buttons) are considered as input components though they do not gather user input. The reason for this is that the event mechanism is coupled toComponentHandler
instances, so for a button to generate events there must be an associated component handler. Note that the returned component handler is usually not added to the generatedForm
object. If the button really should be used as input component, its data is a boolean value indicating whether the button is selected (which makes sense if the button is used as a toggle button). Just delegates to the wrappedComponentManager
object.- Specified by:
createButton
in interfaceComponentManager
- Parameters:
tag
- the button tagcreate
- the create flag- Returns:
- the component handler for the new button
- Throws:
FormBuilderException
- if an error occurs
-
createToggleButton
public ComponentHandler<Boolean> createToggleButton(ToggleButtonTag tag, boolean create) throws FormBuilderException
Creates a toggle button component. A toggle button is a simple switch that can be selected (pressed) or not. So the data associated with components of this type is simply a boolean. Just delegates to the wrappedComponentManager
object.- Specified by:
createToggleButton
in interfaceComponentManager
- Parameters:
tag
- the tag defining the toggle buttoncreate
- the create flag- Returns:
- the component handler for the new toggle button
- Throws:
FormBuilderException
- if an error occurs
-
createTextField
public ComponentHandler<String> createTextField(TextFieldTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a text field. The data type of this handler is String. Just delegates to the wrappedComponentManager
object.- Specified by:
createTextField
in interfaceComponentManager
- Parameters:
tag
- the tag defining the text fieldcreate
- the create flag- Returns:
- the component handler for the text field
- Throws:
FormBuilderException
- if an error occurs
-
createTextArea
public ComponentHandler<String> createTextArea(TextAreaTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a text area. The data type of this handler is String. Just delegates to the wrappedComponentManager
object.- Specified by:
createTextArea
in interfaceComponentManager
- Parameters:
tag
- the tag defining the text areacreate
- the create flag- Returns:
- the component handler for the text area
- Throws:
FormBuilderException
- if an error occurs
-
createPasswordField
public ComponentHandler<String> createPasswordField(PasswordFieldTag tag, boolean create) throws FormBuilderException
Creates aComponentHandler
that wraps a password text field. This handler acts like a regular handler for text input fields. Only the visual representation is different because the characters typed by the user in the text field are not readable. Just delegates to the wrappedComponentManager
object.- Specified by:
createPasswordField
in interfaceComponentManager
- Parameters:
tag
- the tag defining the password text fieldcreate
- the create flag- Returns:
- the
ComponentHandler
for the password text field - Throws:
FormBuilderException
- if an error occurs
-
createCheckbox
public ComponentHandler<Boolean> createCheckbox(CheckboxTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a checkbox. This handler's data is of type boolean. Just delegates to the wrappedComponentManager
object.- Specified by:
createCheckbox
in interfaceComponentManager
- Parameters:
tag
- the tag defining the checkboxcreate
- the create flag- Returns:
- the component handler for the checkbox
- Throws:
FormBuilderException
- if an error occurs
-
createRadioButton
public ComponentHandler<Boolean> createRadioButton(RadioButtonTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a radio button. This handler's data is of type boolean. Just delegates to the wrappedComponentManager
object.- Specified by:
createRadioButton
in interfaceComponentManager
- Parameters:
tag
- the tag defining the radio buttoncreate
- the create flag- Returns:
- the component handler for the radio button
- Throws:
FormBuilderException
- if an error occurs
-
createComboBox
public ComponentHandler<Object> createComboBox(ComboBoxTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a combo box. This handler maintains a single data object of the same type as the combo box's list model. Just delegates to the wrappedComponentManager
object.- Specified by:
createComboBox
in interfaceComponentManager
- Parameters:
tag
- the tag defining the combo boxcreate
- the create flag- Returns:
- the component handler for the combo box
- Throws:
FormBuilderException
- if an error occurs
-
createListBox
public ComponentHandler<Object> createListBox(ListBoxTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a list box. This handler's data type is based on the type of the list's model and on the list's multi selection flag: for a single selection list the type is the same as the list's model's type, for a multi selection list it is an array of this type. Just delegates to the wrappedComponentManager
object.- Specified by:
createListBox
in interfaceComponentManager
- Parameters:
tag
- the tag defining the list boxcreate
- the create flag- Returns:
- the component handler for the list box
- Throws:
FormBuilderException
- if an error occurs
-
createTabbedPane
public ComponentHandler<Integer> createTabbedPane(TabbedPaneTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a tabbed pane. The handler's data consists of a singleInteger
object, which represents the (0-based) index of the selected tab. It can be read and set. Just delegates to the wrappedComponentManager
object.- Specified by:
createTabbedPane
in interfaceComponentManager
- Parameters:
tag
- the tag defining the tabbed panecreate
- the create flag- Returns:
- the component handler for the tabbed pane
- Throws:
FormBuilderException
- if an error occurs
-
createStaticText
public ComponentHandler<StaticTextData> createStaticText(StaticTextTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a static text element. The handler's data consists of a
object, which can be used to read and write the static text's properties. The returned handler can be casted into aStaticTextData
object; the additional methods defined by this interface can be used to directly set the key properties of the static text component. Just delegates to the wrappedStaticTextHandler
ComponentManager
object.- Specified by:
createStaticText
in interfaceComponentManager
- Parameters:
tag
- the tag defining the static textcreate
- the create flag- Returns:
- the component handler for the static text
- Throws:
FormBuilderException
- if an error occurs
-
createProgressBar
public ComponentHandler<Integer> createProgressBar(ProgressBarTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a progress bar element. The handler's data is an integer value representing the current position of the progress bar. The handler can be casted into aProgressBarHandler
object; the additional methods defined by this interface can be used to manipulate further properties of the progress bar. Just delegates to the wrappedComponentManager
object.- Specified by:
createProgressBar
in interfaceComponentManager
- Parameters:
tag
- the tag defining the progress barcreate
- the create flag- Returns:
- the component handler for the progress bar
- Throws:
FormBuilderException
- if an error occurs
-
createSlider
public ComponentHandler<Integer> createSlider(SliderTag tag, boolean create) throws FormBuilderException
Creates a component handler that wraps a slider component. The handler's data is an integer value representing the current value of the slider. Just delegates to the wrappedComponentManager
object.- Specified by:
createSlider
in interfaceComponentManager
- Parameters:
tag
- the tag defining the slidercreate
- the create flag- Returns:
- the component handler for the slider
- Throws:
FormBuilderException
- if an error occurs
-
createTable
public ComponentHandler<Object> createTable(TableTag tag, boolean create) throws FormBuilderException
Creates a table based on the information stored in the passed in table tag. This is a complex operation because it has to be ensured that the table is fully initialized. It is guaranteed that the tag contains only valid data. The table's data model, its columns, and form objects to be used for rendering or editing cells are available. The returnedComponentHandler
object wraps the table component. It can be casted into a
object. Its data depends on the selection type of the table: in single selection mode it is the index of the selected row; in multi selection mode it is an int[] with the indices of the selected rows. By registering a change listener at the returnedTableHandler
ComponentHandler
interested components can be notified when the table's selection changes. Just delegates to the wrappedComponentManager
object.- Specified by:
createTable
in interfaceComponentManager
- Parameters:
tag
- the table tagcreate
- the create flag- Returns:
- the component handler for the new table component
- Throws:
FormBuilderException
- if an error occurs
-
createTree
public ComponentHandler<Object> createTree(TreeTag tag, boolean create) throws FormBuilderException
Creates a tree component based on the information stored in the passed in tree tag. The tag has been fully initialized, it especially contains the model to be used for the tree. TheComponentHandler
returned by this method can be casted into a
object. Refer to the documentation of this class for more information about the data supported by this handler. Just delegates to the wrappedTreeHandler
ComponentManager
object.- Specified by:
createTree
in interfaceComponentManager
- Parameters:
tag
- the tree tagcreate
- the create flag- Returns:
- the component handler for the new tree component
- Throws:
FormBuilderException
- if an error occurs
-
-