|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectti.chimera.Service
ti.chimera.service.Prompt
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.
Nested Class Summary | |
static interface |
Prompt.Progress
An object implementing this interface is returned by showProgress(java.lang.String)
in order to allow the client code to programatically update or dismiss
the progress. |
Constructor Summary | |
Prompt()
Class Constructor. |
Method Summary | |
abstract java.lang.String |
askQuestion(java.lang.String msg,
java.lang.String[] choices)
Ask a question of the user. |
abstract void |
showErrorMessage(java.lang.String msg)
Display an error message to the user. |
abstract void |
showInfoMessage(java.lang.String msg)
Display an info message to the user. |
abstract Prompt.Progress |
showProgress(java.lang.String msg)
Display a progress message to the user. |
abstract void |
showWarningMessage(java.lang.String msg)
Display a warning message to the user. |
Methods inherited from class ti.chimera.Service |
getName, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Prompt()
Method Detail |
public abstract void showErrorMessage(java.lang.String msg)
msg
- the error message to displaypublic abstract void showWarningMessage(java.lang.String msg)
msg
- the warning message to displaypublic abstract void showInfoMessage(java.lang.String msg)
msg
- the info message to displaypublic abstract Prompt.Progress showProgress(java.lang.String msg)
Prompt.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, Prompt.Progress.setRange(int, int)
and Prompt.Progress.setValue(int)
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();
msg
- the message to display
public abstract java.lang.String askQuestion(java.lang.String msg, java.lang.String[] choices)
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; ....
msg
- the message to displaychoices
- array of choices presented to the user
choices
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |