Package commandLineMenus
Class List<T>
- java.lang.Object
-
- commandLineMenus.Option
-
- commandLineMenus.Menu
-
- commandLineMenus.List<T>
-
public class List<T> extends Menu
Menu dynamically populated with a list of items. The type T is not the type displayed but the type kept in memory for further treatment. The data is read through a ListData. The selection of an item triggers either a ListAction, either a ListOption.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classList.ListActionOrOptionExceptionThrown if there is a problem with the listAction or the listOption.static classList.ManualOptionAddForbiddenExceptionThrown if one tries to manually edit the options displayed.static classList.NoListDataDefinedExceptionThrown if the current list has no ListData.-
Nested classes/interfaces inherited from class commandLineMenus.Menu
Menu.CollisionException, Menu.ConcurrentExecutionException, Menu.CycleDetectedException, Menu.EmptyMenuException, Menu.ShortcutMissingException
-
Nested classes/interfaces inherited from class commandLineMenus.Option
Option.ConcurrentModificationException, Option.NoActionDefinedException
-
-
Constructor Summary
Constructors Constructor Description List(java.lang.String title, ListData<T> data, ListAction<T> action)Creates a List.List(java.lang.String title, ListData<T> data, ListOption<T> option)Creates a List.List(java.lang.String title, java.lang.String shortcut, ListData<T> data, ListAction<T> action)Creates a List.List(java.lang.String title, java.lang.String shortcut, ListData<T> data, ListOption<T> option)Creates a List.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Option option)Do never call add() if this is a list, it is forbidden to manually add an option in a List.voidaddBack(java.lang.String shortcut)Adds an option to go back to the parent menu, if the list is empty, a go back option is automatically added with the 'q' shortcut.voidaddBack(java.lang.String title, java.lang.String shortcut)Adds an option to go back to the parent menu.voidaddQuit(java.lang.String shortcut)Adds an option to close all menus.voidaddQuit(java.lang.String title, java.lang.String shortcut)Adds an option to close all menus.voidsetListItemRenderer(ListItemRenderer<T> listItemRenderer)Overrides the default display of an item with a custom one. listItemRenderer only applies to the current list.-
Methods inherited from class commandLineMenus.Menu
getOptions, goBack, quit, setAutoBack, size, start, toString
-
Methods inherited from class commandLineMenus.Option
getRenderer, getShortcut, getTitle, setAction, setRenderer
-
-
-
-
Constructor Detail
-
List
public List(java.lang.String title, ListData<T> data, ListAction<T> action)Creates a List.- Parameters:
title- The title of the list.data- The implementation of ListData that refreshes the listaction- The implementation of ListAction that will be triggered if an item is selected.
-
List
public List(java.lang.String title, ListData<T> data, ListOption<T> option)Creates a List.- Parameters:
title- The title of the list.data- The implementation of ListData that refreshes the listoption- The sub-menu that will be opened if an item is selected.
-
List
public List(java.lang.String title, java.lang.String shortcut, ListData<T> data, ListAction<T> action)Creates a List.- Parameters:
title- The title of the list.shortcut- The shortcut that opens the list if this is a sub-menu.data- The implementation of ListData that refreshes the listaction- The implementation of ListAction that will be triggered if an item is selected.
-
List
public List(java.lang.String title, java.lang.String shortcut, ListData<T> data, ListOption<T> option)Creates a List.- Parameters:
title- The title of the list.shortcut- The shortcut that opens the list if this is a sub-menu.data- The implementation of ListData that refreshes the listoption- The sub-menu that will be opened if an item is selected.
-
-
Method Detail
-
add
public void add(Option option)
Do never call add() if this is a list, it is forbidden to manually add an option in a List.
-
addQuit
public void addQuit(java.lang.String shortcut)
Description copied from class:MenuAdds an option to close all menus.
-
addQuit
public void addQuit(java.lang.String title, java.lang.String shortcut)Description copied from class:MenuAdds an option to close all menus.
-
addBack
public void addBack(java.lang.String shortcut)
Adds an option to go back to the parent menu, if the list is empty, a go back option is automatically added with the 'q' shortcut.
-
addBack
public void addBack(java.lang.String title, java.lang.String shortcut)Description copied from class:MenuAdds an option to go back to the parent menu.
-
setListItemRenderer
public void setListItemRenderer(ListItemRenderer<T> listItemRenderer)
Overrides the default display of an item with a custom one. listItemRenderer only applies to the current list.- Parameters:
listItemRenderer- The implementation of ListItemRenderer that customizes the display.
-
-