public interface ComponentManager
Definition of an interface to a concrete GUI manager.
The form framework tries to be independent of a specific GUI technology like Swing or SWT. Instead widgets are addressed in a generic way, as objects. This interface defines accessor methods for such generic GUI objects. Concrete implementation classes will map these methods onto an existing GUI library.
The most important client for this interface is the form builder jelly tag library. The tags represent generic form elements, e.g. labels, text fields or radio buttons. Concrete implementations for these elements are created through interface methods. This makes it possible to plug in different GUI libraries. So one and the same jelly script could once create a Swing GUI and another time an SWT GUI.
A large part of the methods defined in this interface deal with the creation
of GUI components. Those components are wrapped into a
ComponentHandler
implementation, which makes it possible to add them
to a Form
object and to access their
data. Some of these methods have a boolean argument create
.
During the processing of the Jelly script that defines the GUI they are
called twice, once with the argument set to true and once with the
argument set to false. The first call comes before the tag's body is
evaluated, the second after that. This allows for different ways of
constructing component hierarchies (e.g. in Swing components are added to
containers using an add()
of the container, SWT on the other
hand requires the container being passed into the component's constructor -
thus the container must have been created prior than the component.
Additional methods are responsible for creating auxiliary objects, like icons, fonts or layout constraints, or for manipulating container objects, which can contain other GUI elements.
Note: This interface is not intended to be directly
implemented by client code. It is subject to change even in minor releases as
new features are made available. Therefore if an application needs to provide
a custom implementation of this interface, it should extend an existing
implementation. For instance, the ComponentManagerWrapper
class is a
good candidate if only a subset of methods is to be modified.
Modifier and Type | Method and 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 the
PlatformEventManager interface for dealing with event
notifications. |
Object |
createFont(FontTag tag)
Creates a font object from the data specified by the given
FontTag . |
Object |
createIcon(Locator locator)
Creates an icon object with the data obtained from the specified
Locator |
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 a
ComponentHandler 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 a
WidgetHandler for the specified component. |
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.
|
void addContainerComponent(Object container, Object component, Object constraints)
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
nullvoid setContainerLayout(Object container, Object layout)
container
- the containerlayout
- the new layout managerPlatformEventManager createEventManager()
PlatformEventManager
interface for dealing with event
notifications. This method is called once when the event handling
features are used for the first time.WidgetHandler getWidgetHandlerFor(Object component)
WidgetHandler
for the specified component. This
method is called by ComponentBuilderData
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.component
- the componentWidgetHandler
wrapping the specified componentObject createLabel(LabelTag tag, boolean create) throws FormBuilderException
tag
- the label tagcreate
- the create flagFormBuilderException
- if an error occursvoid linkLabel(Object label, Object component, String text) throws FormBuilderException
componentref
attribute of a LabelTag
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).label
- the label (as returned by the createLabel()
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 setFormBuilderException
- if an error occursObject createIcon(Locator locator) throws FormBuilderException
Locator
locator
- the Locator
pointing to the dataFormBuilderException
- if an error occursObject createFont(FontTag tag) throws FormBuilderException
FontTag
.tag
- the FontTag
FormBuilderException
- if an error occursObject createPercentLayout(PercentLayoutTag tag) throws FormBuilderException
tag
- the percent layout tagFormBuilderException
- if an error occursObject createButtonLayout(ButtonLayoutTag tag) throws FormBuilderException
tag
- the button layout tagFormBuilderException
- if an error occursObject createBorderLayout(BorderLayoutTag tag) throws FormBuilderException
tag
- the border layout tagFormBuilderException
- if an error occursObject createPanel(PanelTag tag, boolean create) throws FormBuilderException
tag
- the panel tagcreate
- the create flagFormBuilderException
- if an error occursObject createDesktopPanel(DesktopPanelTag tag, boolean create) throws FormBuilderException
tag
- the desktop panel tagcreate
- the create flagFormBuilderException
- if an error occursObject createSplitter(SplitterTag tag, boolean create) throws FormBuilderException
tag
- the splitter tagcreate
- the create flagFormBuilderException
- if an error occursObject createRadioGroup(Map<String,Object> radioButtons) throws FormBuilderException
radioButtons
- a map with the radio button components that belong to
the groupFormBuilderException
- if an error occursComponentHandler<Boolean> createButton(ButtonTag tag, boolean create) throws FormBuilderException
ComponentHandler
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 generated
Form
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).tag
- the button tagcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Boolean> createToggleButton(ToggleButtonTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the toggle buttoncreate
- the create flagFormBuilderException
- if an error occursComponentHandler<String> createTextField(TextFieldTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the text fieldcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<String> createTextArea(TextAreaTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the text areacreate
- the create flagFormBuilderException
- if an error occursComponentHandler<String> createPasswordField(PasswordFieldTag tag, boolean create) throws FormBuilderException
ComponentHandler
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.tag
- the tag defining the password text fieldcreate
- the create flagComponentHandler
for the password text fieldFormBuilderException
- if an error occursComponentHandler<Boolean> createCheckbox(CheckboxTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the checkboxcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Boolean> createRadioButton(RadioButtonTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the radio buttoncreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Object> createComboBox(ComboBoxTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the combo boxcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Object> createListBox(ListBoxTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the list boxcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Integer> createTabbedPane(TabbedPaneTag tag, boolean create) throws FormBuilderException
Integer
object, which represents the
(0-based) index of the selected tab. It can be read and set.tag
- the tag defining the tabbed panecreate
- the create flagFormBuilderException
- if an error occursComponentHandler<StaticTextData> createStaticText(StaticTextTag tag, boolean create) throws FormBuilderException
StaticTextData
object, which can be used to read and write the static text's properties.
The returned handler can be casted into a
StaticTextHandler
object; the additional methods defined by this interface can be used to
directly set the key properties of the static text component.tag
- the tag defining the static textcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Integer> createProgressBar(ProgressBarTag tag, boolean create) throws FormBuilderException
ProgressBarHandler
object; the additional methods defined by this interface can be used to
manipulate further properties of the progress bar.tag
- the tag defining the progress barcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Integer> createSlider(SliderTag tag, boolean create) throws FormBuilderException
tag
- the tag defining the slidercreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Object> createTable(TableTag tag, boolean create) throws FormBuilderException
ComponentHandler
object wraps the table component. It can
be casted into a
TableHandler
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 returned ComponentHandler
interested components can be notified when the table's selection changes.tag
- the table tagcreate
- the create flagFormBuilderException
- if an error occursComponentHandler<Object> createTree(TreeTag tag, boolean create) throws FormBuilderException
ComponentHandler
returned
by this method can be casted into a
TreeHandler
object. Refer to the documentation of this class for more information
about the data supported by this handler.tag
- the tree tagcreate
- the create flagFormBuilderException
- if an error occursCopyright © 2016 The JGUIraffe Team. All rights reserved.