Class Menu
java.lang.Object
pretty.layout.Menu
-
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()Rollback all lines and temporary linesvoiddivider()Push a divider to the menucharGet a char from the usercharGet a char from the userdoubleGet a double from the userdoubleGet a double from the userfloatGet a float from the userfloatGet a float from the userstatic MenuGet the singleton instance of MenuintGet an integer from the userintGet an integer from the userlongGet an long integer from the userlongGet an long integer from the userintShow options to the user and get the selected optionintShow options to the user and get the selected optionbooleanGet a confirmation from the userbooleangetPageConfirmation(String reject) Get a confirmation from the userintgetPageOption(String[] options) Get an option from the userintgetPageOption(String[] options, int page, int optionsPerPage, int selected, String exit) Get an option from the userintgetPageOption(String[] options, Integer[] lockeds) Get an option from the userintgetPageOption(String[] options, Integer[] lockeds, int optionsPerPage, int selected, String exit) Get an option from the userintgetPageOption(String[] options, Integer[] lockeds, int selected, String exit) Get an option from the userintgetPageOption(String[] options, Integer[] lockeds, String exit) Get an option from the userintgetPageOption(String[] options, String exit) Get an option from the userGet a string from the userGet a string from the uservoidPush a header to the menuvoidphantomPush(String line) Push a line to the menu without rendering itvoidPush a line to the menuvoidPush a line to the menuvoidPush a footer to the menu with the only option to go backvoidrollback()Rollback the last line and temporary linesvoidrollback(int count) Rollback a number of lines, not including temporary linesvoidRollback the last line, keeping temporary linesvoidstart()Start the menu, called by the router by defaultvoidtemporarilyPush(String line) Temporarily push a line to the menu.voidRollback the last line and temporary lines and print an warning messagevoidRollback a number of lines and temporary lines and print an warning message
-
Method Details
-
getInstance
-
start
public void start()Start the menu, called by the router by default -
push
-
push
Push a line to the menu- Parameters:
line- - the line to be pushednewLine- - if the line should be end with a new line
-
temporarilyPush
Temporarily push a line to the menu. The line will be removed after the next rollback.- Parameters:
line- - the line to be temporarily pushed
-
phantomPush
Push a line to the menu without rendering it- Parameters:
line- - the line to be pushed
-
rollback
public void rollback()Rollback the last line and temporary lines -
rollback
public void rollback(int count) Rollback a number of lines, not including temporary lines- Parameters:
count- - the number of lines
-
rollbackKeepingTemporary
public void rollbackKeepingTemporary()Rollback the last line, keeping temporary lines -
cleanup
public void cleanup()Rollback all lines and temporary lines -
warning
Rollback the last line and temporary lines and print an warning message- Parameters:
message- - the message to be printed
-
warning
Rollback a number of lines and temporary lines and print an warning message- Parameters:
message- - the message to be printedrollbacks- - the number of lines to rollback
-
header
-
divider
public void divider()Push a divider to the menu -
getInt
-
getInt
-
getLong
-
getLong
-
getDouble
-
getDouble
-
getFloat
-
getFloat
-
getChar
-
getChar
-
getString
-
getString
-
getOption
-
getOption
Show options to the user and get the selected option- Parameters:
prompt- - the prompt to be shownoptions- - the options to be shownselected- - the default selected option- Returns:
- the selected option, or -1 if no options is passed
-
pushPageBack
public void pushPageBack()Push a footer to the menu with the only option to go back -
getPageConfirmation
public boolean getPageConfirmation()Get a confirmation from the user- Returns:
- true, if the user confirms, false otherwise
-
getPageConfirmation
Get a confirmation from the user- Parameters:
reject- - reject option message- Returns:
- true, if the user confirms, false otherwise
-
getPageOption
Get an option from the user- Parameters:
options- - the options to be shown- Returns:
- the selected option or -1 if no options are selected
-
getPageOption
-
getPageOption
-
getPageOption
-
getPageOption
Get an option from the user- Parameters:
options- - the options to be shownlockeds- - the locked optionsselected- - the default selected optionexit- - exit option message- Returns:
- the selected option or -1 if no options are selected
-
getPageOption
Get an option from the user- Parameters:
options- - the options to be shownpage- - the current pageoptionsPerPage- - the max number of options per pageselected- - the default selected optionexit- - exit option message- Returns:
- the selected option or -1 if no options are selected
-
getPageOption
public int getPageOption(String[] options, Integer[] lockeds, int optionsPerPage, int selected, String exit) Get an option from the user- Parameters:
options- - the options to be shownlockeds- - the locked optionsoptionsPerPage- - the max number of options per pageselected- - the default selected optionexit- - exit option message- Returns:
- - the selected option or -1 if no options are selected
-