org.universAAL.middleware.ui.rdf
Class Repeat

Package class diagram package Repeat
java.lang.Object
  extended by org.universAAL.middleware.rdf.Resource
      extended by org.universAAL.middleware.rdf.FinalizedResource
          extended by org.universAAL.middleware.ui.rdf.FormElement
              extended by org.universAAL.middleware.ui.rdf.FormControl
                  extended by org.universAAL.middleware.ui.rdf.Group
                      extended by org.universAAL.middleware.ui.rdf.Repeat

public class Repeat
extends Group

A subclass of 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.

Author:
mtazari, Carsten Stockloew

Field Summary
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.
 
Fields inherited from class org.universAAL.middleware.ui.rdf.Group
PROP_CHILDREN
 
Fields inherited from class org.universAAL.middleware.ui.rdf.FormControl
PROP_CONTROL_LABEL, PROP_HELP, PROP_HINT, PROP_PARENT_CONTROL, PROP_REFERENCED_PPATH, PROP_VALUE_RESTRICTION
 
Fields inherited from class org.universAAL.middleware.ui.rdf.FormElement
PROP_APPEARANCE
 
Fields inherited from class org.universAAL.middleware.rdf.Resource
ANON_URI_PREFIX, blockAddingTypes, isXMLLiteral, ns_delim_index, 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, PROP_uAAL_INVOLVED_HUMAN_USER, props, RDF_EMPTY_LIST, RDF_NAMESPACE, RDFS_NAMESPACE, TYPE_RDF_LIST, TYPE_RDFS_CLASS, uAAL_NAMESPACE_PREFIX, uAAL_SERVICE_NAMESPACE, uAAL_VOCABULARY_NAMESPACE, uri
 
Constructor Summary
Repeat()
          For exclusive use by de-serializers.
Repeat(Group parent, Label label, PropertyPath ref, MergedRestriction valueRestriction, List initialValue)
          Constructs a new repeat control.
 
Method Summary
 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 Forms which each contains in its IOControls group the corresponding row of FormControls.
 
Methods inherited from class org.universAAL.middleware.ui.rdf.Group
doModelBasedExpansion, getChildren, getComplexity, getHierarchyLevel, getMaxLength, getNumberOfSubgroups, hasInput, hasOutput, isRootGroup, setProperty
 
Methods inherited from class org.universAAL.middleware.ui.rdf.FormControl
getAncestorRepeat, getFormObject, getHelpString, getHintString, getLabel, getParentGroup, getParentRepeat, getReferencedPPath, getRestrictions, getSuperGroups, getTypeURI, getValue, hasFocus, hasValue, isOfBooleanType, isOfPrimitiveType, isRepeatable, setHelpString, setHintString, toString
 
Methods inherited from class org.universAAL.middleware.ui.rdf.FormElement
addAppearanceRecommendation, getAppearanceRecommendations
 
Methods inherited from class org.universAAL.middleware.rdf.FinalizedResource
addType, getLocalName, getNamespace, getProperty, getPropertyURIs, getType, getTypes, getURI, hasQualifiedName, isAnon, numberOfProperties
 
Methods inherited from class org.universAAL.middleware.rdf.Resource
addMultiLangProp, asList, asList, asRDFList, changeProperty, copy, deepCopy, equals, generateAnonURI, getDefaultLang, getFilename, getMultiLangProp, getOrConstructLabel, getPropSerializationType, getResource, getResourceComment, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isClosedCollection, isQualifiedName, isWellFormed, literal, representsQualifiedURI, serializesAsXMLLiteral, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toStringRecursive, toStringRecursive, unliteral
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MY_URI

public static final String MY_URI
See Also:
Constant Field Values

PROP_IS_DELETABLE

public static final String PROP_IS_DELETABLE
Indicates if entries can be removed from the list of initial values associated with a repeat control.

See Also:
Constant Field Values

PROP_IS_EDITABLE

public static final String PROP_IS_EDITABLE
Indicates if entries in the list of initial values associated with a repeat control can be edited.

See Also:
Constant Field Values

PROP_IS_EXPANDABLE

public static final String PROP_IS_EXPANDABLE
Indicates if new entries can be added to the list of initial values associated with a repeat control.

See Also:
Constant Field Values

PROP_SEARCHABLE_FIELD

public static final 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.

See Also:
Constant Field Values
Constructor Detail

Repeat

public Repeat()
For exclusive use by de-serializers.


Repeat

public Repeat(Group parent,
              Label label,
              PropertyPath ref,
              MergedRestriction valueRestriction,
              List initialValue)
Constructs a new repeat control.

Parameters:
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.
Method Detail

addValue

public 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. Note: changes to the selection itself (achieved by calling Input.storeUserInput(Object) on child controls of a reapt) are only local until either this method or updateSelection() is called.

Returns:
true, if either there is no selection or the value differs from the selected entry in the the list of values currently associated with this repeat control. Otherwise it does not add the value and returns false.

banEntryAddition

public 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.

See Also:
PROP_IS_EXPANDABLE

banEntryDeletion

public 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.

See Also:
PROP_IS_DELETABLE

banEntryEdit

public 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.

See Also:
PROP_IS_EDITABLE

getAllValues

public 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. Empty cells will add a null value to the returned list.


getMaxCardinality

public int getMaxCardinality()
Returns the maximum number of values that can be associated with this repeat control. A negative integer is returned if there is no upper limit.


getMinCardinality

public int getMinCardinality()
Returns the minimum number of values that must be associated with this repeat control. A non-positive integer is returned if there is no lower limit.


getNumberOfValues

public int getNumberOfValues()
Returns the number of entries currently existing in the list of values associated with this repeat control.


getSearchableField

public FormControl getSearchableField()
See Also:
PROP_SEARCHABLE_FIELD

getSelectionIndex

public int getSelectionIndex()
Returns the index of the current selection in the list of values associated with this repeat control. If there is no selection, returns a negative number.


getValue

public Object getValue(String[] pp)
Returns the value that can be reached by the given path starting from the current selection.


listAcceptsNewEntries

public boolean listAcceptsNewEntries()
See Also:
PROP_IS_EXPANDABLE

listEntriesDeletable

public boolean listEntriesDeletable()
See Also:
PROP_IS_DELETABLE

listEntriesEditable

public boolean listEntriesEditable()
See Also:
PROP_IS_EDITABLE

moveSelectionDown

public 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). Can be used for sorting the list of values associated with this repeat control.


moveSelectionUp

public 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). Can be used for sorting the list of values associated with this repeat control.


removeSelection

public boolean removeSelection()
Removes the current selection from the list of values associated with this repeat control. After this operation, there will be no selection and it must be set explicitly by calling setSelection(int).

Returns:
true, if there was a selection; false, otherwise.

setSearchableField

public void setSearchableField(FormControl fc)
See Also:
PROP_SEARCHABLE_FIELD

setSelection

public 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. If the given index is out of range, the effect will be equivalent to de-selecting any current selection.


updateSelection

public 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. In this case, it returns true, otherwise null.


virtualFormExpansion

public List virtualFormExpansion()
Generates a List of Forms which each contains in its IOControls group the corresponding row of FormControls. Each of these FormControls will be a copy of the Repeat's FormControls 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 Forms 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 Resources or a List of Objects (in which case the propertypaths of the child of the Repeat should be empty.

Returns:
a List of Forms.
Throws:
IllegalArgumentException - if the prerequisites are not met.

searchFormControl

public FormControl searchFormControl(String formControlURI)

Overrides:
searchFormControl in class Group
Returns:
the FormControl or null if not found.


Copyright © 2014 universAAL Consortium. All Rights Reserved.