|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opends.server.util.cli.MenuBuilder<T>
T
- The type of value returned by the call-backs. Use
Void
if the call-backs do not return a
value.public final class MenuBuilder<T>
An interface for incrementally building a command-line menu.
Constructor Summary | |
---|---|
MenuBuilder(ConsoleApplication app)
Creates a new menu. |
Method Summary | |
---|---|
void |
addBackOption(boolean isDefault)
Creates a "back" menu option. |
void |
addCancelOption(boolean isDefault)
Creates a "cancel" menu option. |
void |
addCharOption(Message c,
Message description,
MenuCallback<T> callback)
Adds a menu choice to the menu which will have a single letter as its key. |
void |
addCharOption(Message c,
Message description,
MenuResult<T> result)
Adds a menu choice to the menu which will have a single letter as its key and which returns the provided result. |
void |
addHelpOption(HelpCallback callback)
Creates a "help" menu option which will use the provided help call-back to display help relating to the other menu options. |
int |
addNumberedOption(Message description,
MenuCallback<T> callback,
Message... extraFields)
Adds a menu choice to the menu which will have a numeric key. |
int |
addNumberedOption(Message description,
MenuResult<T> result,
Message... extraFields)
Adds a menu choice to the menu which will have a numeric key and which returns the provided result. |
void |
addQuitOption()
Creates a "quit" menu option. |
void |
setAllowMultiSelect(boolean allowMultiSelect)
Sets the flag which indicates whether or not the menu will permit multiple numeric options to be selected at once. |
void |
setColumnHeadings(Message... headings)
Sets the optional column headings. |
void |
setColumnWidths(java.lang.Integer... widths)
Sets the optional column widths. |
void |
setDefault(Message description,
MenuCallback<T> callback)
Sets the optional default action for this menu. |
void |
setDefault(Message description,
MenuResult<T> result)
Sets the optional default action for this menu. |
void |
setMaxTries(int nTries)
Sets the maximum number of tries that the user can provide an invalid value in the menu. |
void |
setMultipleColumnThreshold(int threshold)
Sets the number of numeric options required to trigger multiple-column display. |
void |
setPrompt(Message prompt)
Sets the optional menu prompt. |
void |
setTitle(Message title)
Sets the optional menu title. |
Menu<T> |
toMenu()
Creates a menu from this menu builder. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MenuBuilder(ConsoleApplication app)
app
- The application console.Method Detail |
---|
public void addBackOption(boolean isDefault)
MenuResult.cancel()
result.
isDefault
- Indicates whether this option should be made the menu
default.public void addCancelOption(boolean isDefault)
MenuResult.cancel()
result.
isDefault
- Indicates whether this option should be made the menu
default.public void addCharOption(Message c, Message description, MenuCallback<T> callback)
c
- The single-letter message which will be used as the key
for this option.description
- The menu option description.callback
- The call-back associated with this option.public void addCharOption(Message c, Message description, MenuResult<T> result)
c
- The single-letter message which will be used as the key
for this option.description
- The menu option description.result
- The menu result which should be returned by this menu
choice.public void addHelpOption(HelpCallback callback)
callback
- The help call-back.public int addNumberedOption(Message description, MenuCallback<T> callback, Message... extraFields)
description
- The menu option description.callback
- The call-back associated with this option.extraFields
- Any additional fields associated with this menu option.
public int addNumberedOption(Message description, MenuResult<T> result, Message... extraFields)
description
- The menu option description.result
- The menu result which should be returned by this menu
choice.extraFields
- Any additional fields associated with this menu option.
public void addQuitOption()
MenuResult.quit()
result.
public void setAllowMultiSelect(boolean allowMultiSelect)
false
.
allowMultiSelect
- Indicates whether or not the menu will permit multiple
numeric options to be selected at once.public void setColumnHeadings(Message... headings)
headings
- The optional column headings.public void setColumnWidths(java.lang.Integer... widths)
null
indicates that the column should use its default width.
widths
- The optional column widths.public void setDefault(Message description, MenuCallback<T> callback)
description
- A short description of the default action.callback
- The call-back associated with the default action.public void setDefault(Message description, MenuResult<T> result)
description
- A short description of the default action.result
- The menu result which should be returned by default.public void setMultipleColumnThreshold(int threshold)
threshold
- The number of numeric options required to trigger
multiple-column display.public void setPrompt(Message prompt)
prompt
- The menu prompt, or null
if there is not
prompt.public void setTitle(Message title)
title
- The menu title, or null
if there is not
title.public Menu<T> toMenu()
public void setMaxTries(int nTries)
nTries
- the maximum number of tries.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |