| java.lang.Object ti.chimera.Service ti.chimera.service.Prompt
Prompt | abstract public class Prompt extends ti.chimera.Service (Code) | | The "prompt" service, used to implement a mechanism to display info/warning/
error messages to the user, or prompt the user for input. The purpose is
to seperate the decision of how to interact with user from code that needs
to interact with the user. This service could be implemented, for example,
either by poping up dialogs, or with console I/O... it is even possible that
an "expect"-like implementation of this service could be used to automate
things.
author: Rob Clark version: 0.1 |
Inner Class :public interface Progress | |
Constructor Summary | |
public | Prompt() Class Constructor. |
Prompt | public Prompt()(Code) | | Class Constructor.
|
askQuestion | abstract public String askQuestion(String msg, String[] choices)(Code) | | Ask a question of the user. The msg is displayed to the
user, who must then choose one of the choices. The choice selected
by the user is returned. This method blocks until a result is choisen.
For example:
var result = services["prompt"].askQuestion( "Do you want to continue?", [ "Yes", "No" ] );
if( result == "No" )
return;
....
Parameters: msg - the message to display Parameters: choices - array of choices presented to the user one of the elements from choices |
showErrorMessage | abstract public void showErrorMessage(String msg)(Code) | | Display an error message to the user. This method blocks until the user
dismisses the message.
Parameters: msg - the error message to display |
showInfoMessage | abstract public void showInfoMessage(String msg)(Code) | | Display an info message to the user. This method blocks until the user
dismisses the message.
Parameters: msg - the info message to display |
showProgress | abstract public Progress showProgress(String msg)(Code) | | Display a progress message to the user. A progress message has a progress
bar to display progress. This returns a
Progress to allow the
client code to programatically update the progress, and dispose of the
progress message once complete.
The progress displayed to the user is initially in "indeterminate" mode
to indicate that the length of time to take is unknown. Once the length
of time is known,
Progress.setRange and
Progress.setValue can be used to update the progress display.
For example:
var progress = services["prompt"].showProgress("This will take a while");
// progress is in "indeterminate" mode until you compute length of time:
progress.setRange( 0, computeTime() );
var t = currentTimeMillis();
while( !done() )
{
doSomeWork();
p.setValue( currentTimeMillis() - t );
}
// done, so dismiss progress dialog:
progress.dispose();
Parameters: msg - the message to display an object allowing the progress display to be programaticallyupdated by the client code |
showWarningMessage | abstract public void showWarningMessage(String msg)(Code) | | Display a warning message to the user. This method blocks until the user
dismisses the message.
Parameters: msg - the warning message to display |
|
|