Package com.sun.interview
A wizard is a tool that asks the user a series of simple questions, in order to achieve a complex goal, such as installing, configuring or using a complex piece of software. Each question is represented by an object which defines the text of the question to be asked, and the type of the response that is expected. Each question also specifies the next question to be asked, which may depend on the answers to any of the questions that have already been asked. All questions belong to an "interview", and the complete set of questions for a wizard may be grouped into one or more different interviews.
By design, questions are simple to write and do not have any dependence on any GUI API: the presentation of the questions of a wizard is left to a separate utility: more than one may be available.
Guide to writing wizards
The questions for a wizard are most conveniently written as a series of anonymous inner classes. Each question extends the appropriate subtype ofQuestion
,
depending on the appropriate type of response. Normally, the arguments to
the supertype constructor are the interview which contains
the question, and a short name to identify the question. Anonymous
initializers are used to complete the setup of the question, and
each question defines a getNext
method to
define its successor. This method will be called whenever the response
to the question changes, and may return different values depending
on the response to this question and any other questions that have
already been asked. If the user has not yet answered a question, or
has answered it incorrectly, the getNext
method may return
null
. This will prevent any tool processing the questions
from moving beyond this question until a valid response has been given.Question name = new StringQuestion(interview, "name") { { setText("what is your name?"); } protected Question getNext() { return age; } }
Questions can conveniently be created as fields within
an implementation of Interview
.
Interview personal = new Interview("personal") { { setFirstQuestion(name); setTitle("personal questions"); } private Question name = new StringQuestion(this, "name") { ... }; private Question age = new IntQuestion(this, "int") { ... }; private Question sex = new ChoiceQuestion(this, "sex") { ... }; }
FinalQuestion
is a special type of
question that is used to indicate the end of an interview, and does
not provide any response. You may still choose to set some text to be
presented to the user, to announce that they have reached the last question. Question end = new FinalQuestion(interview, "end") { setText("This completes the interview."); };You can invoke one interview from another by using the
callInterview
method,
to recursively invoke a sub-interview before continuing to
process to the next question in the current interview.
The sub-interview will begin at the first question in that
interview, and will proceed until an instance of
FinalQuestion
is found, at which point control will revert
to the successor question given to callInterview
.
Question a5 = new ...Question(....) { .... protected Question getNext() { callInterview(subInterview, a6); } }; // this question will be asked after the subInterview has been completed Question a6 = new ....Question(...) { ... };
- Since:
- 1.0
-
ClassDescriptionA filter which accepts all (non-directory) files.A Checklist is a sorted collection of messages, for the purpose of providing a list of actions that must be performed in association with a completed interview.An Item contains a message to appear in a checklist.A
question
to which the response is one of a number of choices.Aquestion
to which the response is one of a number of choices.A specialized base class for questions which have more than one value to be manipulated by the user.A filter which accepts directories.A "null" question with no response.A filter which accepts files based on their extension.An interface for filtering files.Aquestion
to which the response is one or more filenames.Aquestion
to which the response is a filename.A filter which accepts all files and directories.A special type of question used to indicate the last of the questions of an interview.Aquestion
to which the response is an floating point number.Class that contains a number of static method to work with both JavaTest and JavaHelp objects to make the core JavaTest classes unaware of JavaHelp.An exception used to report errors while using a TestSuite object.The interface that implements bridge between javax.help package and JavaTest.Aquestion
to which the response is an IP address.The base class for an interview: a series ofquestions
, to be presented to the user via some tool such as an assistant or wizard.Deprecated.No longer used in this API, direct JavaHelp usage was removed.This exception is to report problems that occur while updating an interview.Deprecated.No longer used in this API, direct JavaHelp usage was removed.This exception is thrown when a question is expected to be on the current path, and is not.An observer interface for receiving notifications as the state of the interview is updated.InterviewSet is an interview that is also a container for an ordered set of child interviews.This exception will be thrown when an attempt to made to specify a dependency that would create a dependency cycle.Aquestion
to which the response is an integer.Implementation of the HelpSetFactory interface which is aware of javax.help library.This exception is to report problems found while opening a JavaHelp help set.This exception is thrown when a named help set cannot be found.Aquestion
to support the construction of an open-ended set of complex values determined by a specified subinterview.A special subtype of Interview to use for the questions in the body of a loop.A "null" question with no response.TheProperties
class represents a persistent set of properties.Aquestion
which consists of many key-value pairs.Constraints allowing a value to be either a boolean or Yes/No response.Constrains the response to filenames or paths, and allows chooser widgets to be rendered for the user when appropriate.Constraints specifying a floating point type.Value restrictions for string type responses.Questions are the primary constituent elements ofinterviews
.Aquestion
to which the response is an array of strings.Aquestion
to which the response is a string.Aquestion
to which the response is a set of selected nodes within a tree.An interface that provides the model for the tree whose nodes are selected by a TreeQuestion.An API (with a basic front-end application) for batch editing an interview.This exception is used to indicate a problem with the command line arguments.This exception is to report problems that occur while editing the responses to questions in an interview.An API (with a basic front-end application) for generating HTML printouts of aninterview
.This exception is to report problems that occur with command line arguments.This exception is to report problems that occur while updating an interview.Aquestion
to which the response is yes or no.