Package com.install4j.api.screens
Interface Console
- All Superinterfaces:
ProgressInterface
A
Console
object allows you to display information to the user and request input when the installer or uninstaller is running in console mode.
Installers or uninstallers must be started with the "-c" argument to run in console mode.
A console object is passed to the handleConsole
methods of screens and form components.- See Also:
-
Field Summary
Fields inherited from interface com.install4j.api.context.ProgressInterface
OVERWRITE_ALL, OVERWRITE_NEVER, OVERWRITE_NO, OVERWRITE_YES, RETRY_CANCEL, RETRY_NO, RETRY_YES
-
Method Summary
Modifier and TypeMethodDescriptionint[]
askMultipleSelection
(String message, String[] descriptions, String[] keys, int[] defaultValues, boolean oneLinePerOption) Ask the user to select multiple elements from a list of options.boolean
askOkCancel
(String message) Ask the user a question that has to be answered with "OK" or "Cancel".boolean
askOkCancel
(String message, boolean defaultValue) Ask the user a question that has to be answered with "OK" or "Cancel".int
Ask the user a question with a fixed set of answers.int
Ask the user a question with a fixed set of answers.int
askOption
(String message, String[] descriptions, String[] keys, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption) Ask the user a question with a fixed set of answers.int
askOption
(String message, String[] descriptions, String[] keys, String[] helpTexts, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption) Ask the user a question with a fixed set of answers.askPassword
(String message, String defaultValue) Ask the user to enter a password.Ask the user to enter a string with a default string that can be accepted by the user.boolean
Ask the user a question that has to be answered with "Yes" or "No".boolean
Ask the user a question that has to be answered with "Yes" or "No".void
Print a long text to the console and partition it into pages.void
Print an object to the console by invoking itstoString()
method.void
printHeader
(String title) Print the header for a new screen.void
println()
Print a line feed to the console.void
Print an object to the console by invoking itstoString()
method and append a line feed.readLine()
Read input from the console.void
Print [Enter] to the console and wait for the user to hit the Enter key.Methods inherited from interface com.install4j.api.context.ProgressInterface
askContinue, askOverwrite, askRetry, getPercentCompleted, isAlertsShown, isUnattendedProgressDialog, setDetailMessage, setIndeterminateProgress, setPercentCompleted, setSecondaryPercentCompleted, setStatusMessage, showFailure
-
Method Details
-
print
Print an object to the console by invoking itstoString()
method.- Parameters:
val
- the object to be printed
-
println
Print an object to the console by invoking itstoString()
method and append a line feed.- Parameters:
val
- the object to be printed
-
println
void println()Print a line feed to the console. -
more
Print a long text to the console and partition it into pages. Line breaks are introduced after 75 characters, and a "more" notice is printed every 25 lines.- Parameters:
text
- the text- Throws:
UserCanceledException
- if the user cancels the "more" notice, typically with CTRL-C
-
readLine
Read input from the console.- Returns:
- the string that was entered by the user.
- Throws:
UserCanceledException
- if the user cancels the prompt, typically with CTRL-C
-
askYesNo
Ask the user a question that has to be answered with "Yes" or "No". There is no default value.- Parameters:
message
- the question- Returns:
- whether the user answered "Yes"
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C
-
askYesNo
Ask the user a question that has to be answered with "Yes" or "No". The default value is configurable.- Parameters:
message
- the questiondefaultValue
- whether "Yes" is the default value- Returns:
- whether the user answered "Yes"
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C
-
askOkCancel
Ask the user a question that has to be answered with "OK" or "Cancel". There is no default value.- Parameters:
message
- the question- Returns:
- whether the user answered "OK"
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.
-
askOkCancel
Ask the user a question that has to be answered with "OK" or "Cancel". The default value is configurable.- Parameters:
message
- the questiondefaultValue
- whether "OK" is the default value- Returns:
- whether the user answered "OK"
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C. Note that this is different from a "Cancel" answer.
-
askOption
int askOption(@Nls String message, @Nls String[] descriptions, String[] keys) throws UserCanceledException Ask the user a question with a fixed set of answers. There is no default value.- Parameters:
message
- the questiondescriptions
- an array with a textual description for each optionkeys
- an array with a short key for each option. Keys are what the user enters to select the desired option.- Returns:
- the selected index of the option
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
askOption
int askOption(@Nls String message, @Nls String[] descriptions, String[] keys, int defaultValue) throws UserCanceledException Ask the user a question with a fixed set of answers. The default value is configurable.- Parameters:
message
- the questiondescriptions
- an array with a textual description for each optionkeys
- an array with a short key for each option. Keys are what the user enters to select the desired option.defaultValue
- the index of the default option- Returns:
- the selected index of the option
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
askOption
int askOption(@Nls String message, @Nls String[] descriptions, String[] keys, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption) throws UserCanceledException Ask the user a question with a fixed set of answers. The default value, the no-selection policy as well as the presentation of the options are configurable.- Parameters:
message
- the questiondescriptions
- an array with a textual description for each optionkeys
- an array with a short key for each option. Keys are what the user enters to select the desired option.defaultValue
- the index of the default optionallowNoSelection
- if the question should allow an empty answer, the return value is -1 in that case.oneLinePerOption
- if the options should be presented on option per line. By default, all options are presented on the same line.- Returns:
- the index of the selected option or -1 if no answer is given.
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
askOption
int askOption(@Nls String message, @Nls String[] descriptions, String[] keys, @Nls String[] helpTexts, int defaultValue, boolean allowNoSelection, boolean oneLinePerOption) throws UserCanceledException Ask the user a question with a fixed set of answers. The default value, the help texts, the no-selection policy as well as the presentation of the options are configurable.- Parameters:
message
- the questiondescriptions
- an array with a textual description for each optionkeys
- an array with a short key for each option. Keys are what the user enters to select the desired option.helpTexts
- an array with help texts that can be shown by the user, array elements can be null for no helpdefaultValue
- the index of the default optionallowNoSelection
- if the question should allow an empty answer, the return value is -1 in that case.oneLinePerOption
- if the options should be presented on option per line. By default, all options are presented on the same line.- Returns:
- the index of the selected option or -1 if no answer is given.
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
askMultipleSelection
int[] askMultipleSelection(@Nls String message, @Nls String[] descriptions, String[] keys, int[] defaultValues, boolean oneLinePerOption) throws UserCanceledException Ask the user to select multiple elements from a list of options. The default selection and the presentation of the options are configurable.- Parameters:
message
- the questiondescriptions
- an array with a textual description for each optionkeys
- an array with a short key for each option. Keys are what the user enters to select the desired options.defaultValues
- an array with the indices of the options that are selected by defaultoneLinePerOption
- if the options should be presented on option per line. By default, all options are presented on the same line.- Returns:
- an array with the indices of the selected options. The length of the array can be zero if no options were selected.
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
askString
Ask the user to enter a string with a default string that can be accepted by the user.- Parameters:
message
- the prompt before the inputdefaultValue
- the default string- Returns:
- the string entered by the user or the default value if the user hits the Enter key.
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
askPassword
Ask the user to enter a password.- Parameters:
message
- the prompt before the inputdefaultValue
- the default string- Returns:
- the string entered by the user or the default value if the user hits the Enter key.
- Throws:
UserCanceledException
- if the user cancels the question, typically with CTRL-C.
-
waitForEnter
Print [Enter] to the console and wait for the user to hit the Enter key.- Throws:
UserCanceledException
- if the user cancels the notice, typically with CTRL-C.
-
printHeader
Print the header for a new screen. This invokes the "Console screen change handler" that is set for the application node on the Screens & Actions tab. If that script is not configured, nothing will be printed.- Parameters:
title
- the title- Throws:
UserCanceledException
- if the user cancels the notice, typically with CTRL-C.
-