org.universAAL.support.utils.ui.low
Class SubDialog

Package class diagram package SubDialog
java.lang.Object
  extended by org.universAAL.middleware.rdf.Resource
      extended by org.universAAL.middleware.rdf.FinalizedResource
          extended by org.universAAL.middleware.ui.UIRequest
              extended by org.universAAL.support.utils.ui.low.SubDialog
All Implemented Interfaces:
Matchable, Request, Requirement, IContainer

public class SubDialog
extends UIRequest
implements IContainer

A helper class that lets you build UIRequests easily so you can send them with your UICaller class. Just create an instance of this for the addressed user and add Simple Form Controls to it. This one specifically creates a SubDialog, which is an interaction unit between applications and users that is started by a pre-existing Dialog. SubDialogs take control of the whole interaction space (e.g. occupy the full screen) until they are dismissed by the application or another Dialog comes in front of them. When a SubDialog is finished, the interaction returns to the Dialog that triggered it. SubDialogs have two groups for Controls: The main Controls group is for any kind of control. The Submits group is only for Submits intended to end the dialog or lead to new dialogs.

Example: Creating a SubDialog for selecting a light from a list and have commands for turning it on and off.

Dialog sd=new Dialog(user,"Light interface",parent.getURI());

Out out=new Out("-","Select one of the following lights");

sd.add(out);

SelectOne list=new SelectOne(LIST_URI, "Lights");

list.setOptions(new String[]{"ligth1","light2","light3"});

sd.add(list);

SubmitCmd s1=new SubmitCmd(SUBMIT_ON,"Turn On");

sd.addSubmit(s1);

SubmitCmd s2=new SubmitCmd(SUBMIT_OFF,"Turn Off");

sd.addSubmit(s2);

caller.sendUIRequest(sd);

Notice that Simple Form Controls will be rendered in the same order as they are added. Once they are added they can no longer be modified, so set all their properties before adding them to the Dialog. Take into account however that Simple Group controls need to be added to the Dialog BEFORE other controls can be added to those Groups.

This is not necessarily faster nor better than the usual way of doing it with Form and UIRequest. It's just an alternative way that might help those less familiarized with universAAL.

Author:
alfiva

Field Summary
 
Fields inherited from class org.universAAL.middleware.ui.UIRequest
MY_URI, PROP_ADDRESSED_USER, PROP_DIALOG_FORM, PROP_DIALOG_LANGUAGE, PROP_DIALOG_PRIORITY, PROP_DIALOG_PRIVACY_LEVEL, PROP_HAS_ACCESS_IMPAIRMENT, PROP_HAS_PREFERENCE, PROP_PRESENTATION_LOCATION, PROP_PRESENTATION_MODALITY, PROP_PRESENTATION_MODALITY_ALT, uAAL_UI_NAMESPACE
 
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
SubDialog(User user, String title, String parentDialogURI)
          Use this helper class to create a UIRequest that is easy to use.
SubDialog(User user, String title, String parentDialogURI, LevelRating priority, PrivacyLevel privacy)
          Use this helper class to create a UIRequest that is easy to use.
 
Method Summary
 String[] add(Control ctrl)
          Add the given Simple Control UI element to this container.
 void addExtra(String property, Object extra)
          Add an extra property to the form used in this UI request.
 void addHidden(String ref, Object hidden)
          Add a hidden object so it is sent within the UI request, but not shown to the user.
 String addSubmit(SubmitCmd ctrl)
          Add a Submit Form Control to the Submit group of the SubDialog.
 
Methods inherited from class org.universAAL.middleware.ui.UIRequest
getAddressedUser, getAltPresentationModality, getDialogForm, getDialogID, getDialogLanguage, getDialogPriority, getDialogPrivacyLevel, getDialogType, getImpairments, getPreferences, getPresentationLocation, getPropSerializationType, matches, setAltPresentationModality, setCollectedInput, setImpairments, setPreferences, setPresentationLocation, setPresentationModality
 
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, getResource, getResourceComment, getResourceLabel, getStaticFieldValue, hashCode, hasProperty, isAnon, isBlockingAddingTypes, isClosedCollection, isQualifiedName, isWellFormed, literal, representsQualifiedURI, serializesAsXMLLiteral, setProperty, setPropertyPath, setPropertyPath, setPropertyPathFromOffset, setResourceComment, setResourceLabel, toString, toStringRecursive, toStringRecursive, unliteral
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubDialog

public SubDialog(User user,
                 String title,
                 String parentDialogURI)
Use this helper class to create a UIRequest that is easy to use. This SubDialog extends UIRequest so you can use it with a UICaller. This constructor needs the URI of the Dialog that triggers this SubDialog. Default values are used for priority (low) and privacy (insensible).

Parameters:
user - The user to which the request is addressed.
title - The title of the Dialog.
parentDialogURI - The URI of the Dialog that triggered this SubDialog.

SubDialog

public SubDialog(User user,
                 String title,
                 String parentDialogURI,
                 LevelRating priority,
                 PrivacyLevel privacy)
Use this helper class to create a UIRequest that is easy to use. This SubDialog extends UIRequest so you can use it with a UICaller. This constructor needs the URI of the Dialog that triggers this SubDialog.

Parameters:
user - The user to which the request is addressed.
title - The title of the Dialog.
parentDialogURI - The URI of the Dialog that triggered this SubDialog.
priority - Set a custom priority for the SubDialog.
privacy - Set the required privacy level for the SubDialog.
Method Detail

add

public String[] add(Control ctrl)
Description copied from interface: IContainer
Add the given Simple Control UI element to this container. Once the control is added it cannot be modified. Controls are renedered in the same order they are added. Controls that are Containers and can add elements as well, like Group or Repeat, must be added BEFORE other controls can be added to them. Controls that need references, like Inputs (with property paths), or Submits (with IDs) will be given an automatic reference if none was set. This reference will be returned by this method, in the form of an Array of Strings representing the reference: a Path for Inputs, or a single String for Submits IDs.

Specified by:
add in interface IContainer
Parameters:
ctrl - The Simple Control UI element to be added.
Returns:
The Array of Strings representing the reference Property Path for Input Controls, or with a single String for Submits IDs.

addSubmit

public String addSubmit(SubmitCmd ctrl)
Add a Submit Form Control to the Submit group of the SubDialog. Submit group is for Submits that end the SubDialog or lead to new dialogs.

Parameters:
ctrl - The Submit to add
Returns:
The String representing the ID to be used to identify the Submit in the response.

addHidden

public void addHidden(String ref,
                      Object hidden)
Add a hidden object so it is sent within the UI request, but not shown to the user. When the UI response is being handled by the UI caller, this hidden input can be retrieved by calling uiresponse.getUserInput(new String[]{ref}); , being ref the one you used in this method.

Parameters:
ref - The reference you will use to access the hidden object later from the response
hidden - The object you want to hide

addExtra

public void addExtra(String property,
                     Object extra)
Add an extra property to the form used in this UI request. Extra properties may be used by I/O Handlers to allow the developer to fine-tune things like the layout. The equivalent in native API is to call setProperty() on a Form object. Use this only as recommended by the Handler you intend to use, since it is the Handler the one who will interpret the property.

Parameters:
property - The property of a Form that a certain Handler will inspect for its own purposes.
extra - The value to be set into the property.


Copyright © 2014 universAAL Consortium. All Rights Reserved.