public class Repeat extends Group
Group
whose children are all of the same type. Hence it
allows only one child as a pseudo placeholder for all the repeatable form
controls of that single type. Consequently, calling
FormControl.getValue()
on repeat controls returns always an instance
of {java.util.List} containing a list of objects with the same type. An
implication hereof is that also the initial value for repeat controls must be
a list.
As direct child of a repeat control, neither Submit
nor repeat
controls are allowed. If this single pseudo placeholder is then a
Group
control, then the children of that group play quasi the role of
columns in a virtual table whose rows are the entries of the list returned by
FormControl.getValue()
. Otherwise, the Repeat object represents a one
column list of simple values.
As the single child control of a Repeat object is only a pseudo placeholder
control, its FormControl.PROP_REFERENCED_PPATH
property must be null.
If this single child is a Group
control, then the reference path for
all of the form controls in the subtree rooted at the pseudo child must have
a value relative to that repeat control and not relative to the root of the
form data, as it must be in all other cases.
This implementation uses a fixed selection model (confer Java standard
selection models like ListSelectionModel
and
TreeSelectionModel
), where the single child control
of it represents always the selected list entry. A selection index points to
the corresponding entry in the list returned by FormControl.getValue()
. If this
index is out of range (normally -1), then the data held by the single child
control is understood as candidate for being added to the list of values (see
addValue()
).
The above mentioned selection model does not provide any eventing mechanism because the change of the selection occurs only through public methods of the class (which means that there is no automatic change of selection) and also it is assumed that instances of this class are not used in parallel so that the component having the control over it is the only source of selection change (by calling appropriate methods) that does not need to be notified.
Modifier and Type | Field and Description |
---|---|
static String |
MY_URI |
static String |
PROP_IS_DELETABLE
Indicates if entries can be removed from the list of initial values
associated with a repeat control.
|
static String |
PROP_IS_EDITABLE
Indicates if entries in the list of initial values associated with a
repeat control can be edited.
|
static String |
PROP_IS_EXPANDABLE
Indicates if new entries can be added to the list of initial values
associated with a repeat control.
|
static String |
PROP_SEARCHABLE_FIELD
The form control in the repeat that plays the role of a searchable column
in the sense that the UI handler should provide an additional input field
where the user can enter text to be used to select a specific entry in
the list of values associated with a repeat control.
|
PROP_CHILDREN
PROP_CONTROL_LABEL, PROP_HELP, PROP_HINT, PROP_PARENT_CONTROL, PROP_REFERENCED_PPATH, PROP_VALUE_RESTRICTION
PROP_APPEARANCE
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, NAMESPACE_PREFIX, ns_delim_index, PROP_INVOLVED_HUMAN_USER, PROP_RDF_FIRST, PROP_RDF_REST, PROP_RDF_TYPE, PROP_RDFS_COMMENT, PROP_RDFS_LABEL, PROP_SERIALIZATION_FULL, PROP_SERIALIZATION_OPTIONAL, PROP_SERIALIZATION_REDUCED, PROP_SERIALIZATION_UNDEFINED, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, SERVICE_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uri, VOCABULARY_NAMESPACE
Constructor and Description |
---|
Repeat()
For exclusive use by de-serializers.
|
Repeat(Group parent,
Label label,
PropertyPath ref,
MergedRestriction valueRestriction,
List initialValue)
Constructs a new repeat control.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addValue()
Adds the value held by the single pseudo child control to the end of the
list of values associated with this repeat control.
|
void |
banEntryAddition()
If applications have provided a list as initial data for this repeat
control, they can forbid the addition of new values to that list by
calling this method.
|
void |
banEntryDeletion()
If applications have provided a list as initial data for this repeat
control, they can forbid the deletion of values from that list by calling
this method.
|
void |
banEntryEdit()
If applications have provided a list as initial data for this repeat
control, they can forbid the edition of existing values in that list by
calling this method.
|
List |
getAllValues(FormControl fc)
If the given form control is a column in this repeat control, this method
returns the list of all values in that column in the order of their
appearance in the list of values associated with this repeat control.
|
int |
getMaxCardinality()
Returns the maximum number of values that can be associated with this
repeat control.
|
int |
getMinCardinality()
Returns the minimum number of values that must be associated with this
repeat control.
|
int |
getNumberOfValues()
Returns the number of entries currently existing in the list of values
associated with this repeat control.
|
FormControl |
getSearchableField() |
int |
getSelectionIndex()
Returns the index of the current selection in the list of values
associated with this repeat control.
|
Object |
getValue(String[] pp)
Returns the value that can be reached by the given path starting from the
current selection.
|
boolean |
listAcceptsNewEntries() |
boolean |
listEntriesDeletable() |
boolean |
listEntriesEditable() |
void |
moveSelectionDown()
If there is a selection that is not the last element in the list of
values associated with this repeat control, its place will be exchanged
with the next list element (the element whose index is equal to the
selection index plus 1).
|
void |
moveSelectionUp()
If there is a selection that is not the first element in the list of
values associated with this repeat control (its index is greater than 0),
its place will be exchanged with the previous list element (the element
whose index is equal to the selection index minus 1).
|
boolean |
removeSelection()
Removes the current selection from the list of values associated with
this repeat control.
|
FormControl |
searchFormControl(String formControlURI) |
void |
setSearchableField(FormControl fc) |
void |
setSelection(int i)
Changes the current selection to point to the element that has the given
index (the parameter i) in the list of values associated with this
repeat.
|
boolean |
updateSelection()
If there is a valid selection, the local changes to it will be reflected
in the list of values associated with this repeat control.
|
List |
virtualFormExpansion()
Generates a
List of Form s which each contains in its
IOControls group the corresponding row of FormControl s. |
doModelBasedExpansion, getChildren, getComplexity, getHierarchyLevel, getMaxLength, getNumberOfSubgroups, hasInput, hasOutput, isRootGroup, setProperty
getAncestorRepeat, getFormObject, getHelpString, getHintString, getLabel, getParentGroup, getParentRepeat, getReferencedPPath, getRestrictions, getSuperGroups, getTypeURI, getValue, hasFocus, hasValue, isOfBooleanType, isOfPrimitiveType, isRepeatable, setHelpString, setHintString, toString
addAppearanceRecommendation, getAppearanceRecommendations
addType, getLocalName, getNamespace, getProperty, getPropertyURIs, getType, getTypes, getURI, hasQualifiedName, isAnon, numberOfProperties
addMultiLangProp, asList, asList, asRDFList, changeProperty, copy, deepCopy, equals, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getOrConstructLabel, getPropSerializationType, getResource, getResourceComment, getResourceLabel, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isClosedCollection, isQualifiedName, isWellFormed, literal, representsQualifiedURI, serializesAsXMLLiteral, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toStringRecursive, toStringRecursive, unliteral
public static final String MY_URI
public static final String PROP_IS_DELETABLE
public static final String PROP_IS_EDITABLE
public static final String PROP_IS_EXPANDABLE
public static final String PROP_SEARCHABLE_FIELD
public Repeat()
public Repeat(Group parent, Label label, PropertyPath ref, MergedRestriction valueRestriction, List initialValue)
parent
- The mandatory parent group as the direct container of this
repeat control. See FormControl.PROP_PARENT_CONTROL
.label
- The optional Label
to be associated with this input
field. See FormControl.PROP_CONTROL_LABEL
.ref
- See FormControl.PROP_REFERENCED_PPATH
; mandatory.valueRestriction
- See FormControl.PROP_VALUE_RESTRICTION
. Because repeat
controls may contain input controls, you may specify here a
MergedRestriction
to let
the dialog package to derive the value restrictions for
contained input controls if the form data does not bear the
required info or if you want to define more restrictions
compared to that model-based restrictions.initialValue
- A List
to be used as the initial value for
this repeat.public boolean addValue()
Input.storeUserInput(Object)
on child controls of a reapt) are
only local until either this method or updateSelection()
is
called.public void banEntryAddition()
PROP_IS_EXPANDABLE
public void banEntryDeletion()
PROP_IS_DELETABLE
public void banEntryEdit()
PROP_IS_EDITABLE
public List getAllValues(FormControl fc)
public int getMaxCardinality()
public int getMinCardinality()
public int getNumberOfValues()
public FormControl getSearchableField()
PROP_SEARCHABLE_FIELD
public int getSelectionIndex()
public Object getValue(String[] pp)
public boolean listAcceptsNewEntries()
PROP_IS_EXPANDABLE
public boolean listEntriesDeletable()
PROP_IS_DELETABLE
public boolean listEntriesEditable()
PROP_IS_EDITABLE
public void moveSelectionDown()
public void moveSelectionUp()
public boolean removeSelection()
setSelection(int)
.public void setSearchableField(FormControl fc)
PROP_SEARCHABLE_FIELD
public void setSelection(int i)
public boolean updateSelection()
public List virtualFormExpansion()
List
of Form
s which each contains in its
IOControls group the corresponding row of FormControl
s. Each of
these FormControl
s will be a copy of the Repeat
's
FormControl
s but their FormControl.getValue()
and
Input.storeUserInput(Object)
(if applies) will be redirected to
the correct place.
If the Repeat
's child is a single FormControl
, then each
generated Form
's IOControls group will contain the copy of the
referenced FormControl
. If the Repeat
's child is a
Group
, then the Group
's children will be copied into the
new Form
s IOGroup.
This works because the dataRoot of each new Form
is the one
corresponding for the row, so each FormControl
can be modeled as
usual. this works whether the property path of the Repeat
points
to a List
of Resource
s or a List
of
Object
s (in which case the propertypaths of the child of the
Repeat
should be empty.
List
of Form
s.IllegalArgumentException
- if the prerequisites are not met.public FormControl searchFormControl(String formControlURI)
searchFormControl
in class Group
FormControl
or null if not found.Copyright © 2018 universAAL Consortium. All rights reserved.