public class ComponentGroup extends Object
This class represents a group of components.
The form builder library supports adding components to logical groups. Logical in this context means that these groups do not have a direct representation on the generated GUI. They exist only during the builder process and can be used to reference components. Examples include constructing radio groups or composite component handlers.
A ComponentGroup instance does not contain the components
themselves, but rather their names. For obtaining the corresponding
components access to a ComponentBuilderData object is required.
| Constructor and Description |
|---|
ComponentGroup()
Creates a new instance of
ComponentGroup. |
| Modifier and Type | Method and Description |
|---|---|
void |
addComponent(String name)
Adds a component to this group.
|
static ComponentGroup |
createGroup(org.apache.commons.jelly.JellyContext context,
String name)
Creates a new
ComponentGroup instance and stores it in the
specified context. |
void |
enableGroup(ComponentBuilderData data,
boolean enabled)
Changes the enabled state of this
ComponentGroup. |
static ComponentGroup |
fromBeanContext(BeanContext context,
String groupName)
Obtains the
ComponentGroup with the specified name from the given
BeanContext. |
static ComponentGroup |
fromContext(org.apache.commons.jelly.JellyContext context,
String name)
Fetches the group with the given name from the specified jelly context.
|
Map<String,ComponentHandler<?>> |
getComponentHandlers(ComponentBuilderData data)
Returns a map with the
ComponentHandler objects of the components
this group refers to. |
Set<String> |
getComponentNames()
Returns a set with the names of all components contained in this group.
|
Map<String,Object> |
getComponents(ComponentBuilderData data)
Returns a map with all components this group refers to.
|
static boolean |
groupExists(org.apache.commons.jelly.JellyContext context,
String name)
Tests whether a group with the specified name exists in the given jelly
context.
|
static boolean |
groupExistsInBeanContext(BeanContext context,
String groupName)
Tests whether a group with the specified name exists in the given
BeanContext. |
static void |
storeGroup(org.apache.commons.jelly.JellyContext context,
String name,
ComponentGroup group)
Stores a component group in the jelly context under a given name.
|
public Set<String> getComponentNames()
public void addComponent(String name)
name - the name of the component to addpublic Map<String,Object> getComponents(ComponentBuilderData data) throws FormBuilderException
ComponentBuilderData
object. The resulting map contains the names of the components as keys
and the corresponding component objects as values. If a component name
cannot be resolved, a FormBuilderException exception is thrown.data - the ComponentBuilderData object (must not be
null)FormBuilderException - if a component cannot be resolvedIllegalArgumentException - if the ComponentBuilderData
object is nullpublic Map<String,ComponentHandler<?>> getComponentHandlers(ComponentBuilderData data) throws FormBuilderException
ComponentHandler objects of the components
this group refers to. This method works like
getComponents(ComponentBuilderData), but the resulting map
contains the ComponentHandlers rather than the components
themselves.data - the ComponentBuilderData object (must not be
null)FormBuilderException - if a component cannot be resolvedIllegalArgumentException - if the ComponentBuilderData
object is nullpublic void enableGroup(ComponentBuilderData data, boolean enabled) throws FormBuilderException
ComponentGroup. This method
obtains the ComponentHandler objects for all components that
belong to this group. Then it calls the setEnabled() method on
all these handlers.data - the ComponentBuilderData object (must not be
null)enabled - the new enabled flagFormBuilderException - if a component cannot be resolvedIllegalArgumentException - if the ComponentBuilderData
object is nullgetComponentHandlers(ComponentBuilderData)public static ComponentGroup fromContext(org.apache.commons.jelly.JellyContext context, String name) throws NoSuchElementException
context - the jelly context (must not be nullname - the name of the desired groupIllegalArgumentException - if the context is nullNoSuchElementException - if there is no such grouppublic static boolean groupExists(org.apache.commons.jelly.JellyContext context,
String name)
ComponentGroup objects are not stored under
their name in the context, but a specific prefix is used. So always this
method has to be used to check the existence of a group rather than
testing the context directly.context - the jelly contextname - the name of the groupIllegalArgumentException - if the context is nullpublic static void storeGroup(org.apache.commons.jelly.JellyContext context,
String name,
ComponentGroup group)
context - the contextname - the group's namegroup - the group to store (if null , the group will be
removed if it exists)public static ComponentGroup createGroup(org.apache.commons.jelly.JellyContext context, String name) throws FormBuilderException
ComponentGroup instance and stores it in the
specified context. This is a convenience method which performs the
following steps:
ComponentGroup instance is created.context - the Jelly context (must not be nullname - the name of the new ComponentGroup (must not be
null)ComponentGroup instanceFormBuilderException - if a group with this name already existsIllegalArgumentException - if the group name or the context is
nullpublic static ComponentGroup fromBeanContext(BeanContext context, String groupName)
ComponentGroup with the specified name from the given
BeanContext. This method is similar to
fromContext(JellyContext, String), but the ComponentGroup is resolved from a BeanContext object. This can
be useful if the group is to be obtained after a builder operation. In
this case, the Jelly context may not be available directly, but it can be
accessed through the BeanContext returned by the builder.context - the BeanContextgroupName - the name of the group to be obtainedComponentGroup instanceIllegalArgumentException - if the BeanContext is
nullInjectionException - if the group cannot be resolvedpublic static boolean groupExistsInBeanContext(BeanContext context, String groupName)
BeanContext. Works like groupExists(JellyContext, String), but
checks the given BeanContext.context - the BeanContextgroupName - the name of the group in questionComponentGroup can be found in this
BeanContextIllegalArgumentException - if the BeanContext is
nullCopyright © 2016 The JGUIraffe Team. All rights reserved.