Class ListSelectDialog<T>

  • Type Parameters:
    T - Type of elements in the list
    All Implemented Interfaces:
    BasePane, Composite, Window

    public class ListSelectDialog<T>
    extends DialogWindow
    Dialog that allows the user to select an item from a list
    • Field Detail

      • result

        private T result
    • Constructor Detail

      • ListSelectDialog

        ListSelectDialog​(java.lang.String title,
                         java.lang.String description,
                         TerminalSize listBoxPreferredSize,
                         boolean canCancel,
                         java.util.List<T> content)
    • Method Detail

      • onSelect

        private void onSelect​(T item)
      • onCancel

        private void onCancel()
      • showDialog

        public T showDialog​(WindowBasedTextGUI textGUI)
        Opens the dialog by showing it on the GUI and doesn't return until the dialog has been closed
        Overrides:
        showDialog in class DialogWindow
        Parameters:
        textGUI - Text GUI to add the dialog to
        Returns:
        The item in the list that was selected or null if the dialog was cancelled
      • showDialog

        @SafeVarargs
        public static <T> T showDialog​(WindowBasedTextGUI textGUI,
                                       java.lang.String title,
                                       java.lang.String description,
                                       T... items)
        Shortcut for quickly creating a new dialog
        Type Parameters:
        T - Type of items in the dialog
        Parameters:
        textGUI - Text GUI to add the dialog to
        title - Title of the dialog
        description - Description of the dialog
        items - Items in the dialog
        Returns:
        The selected item or null if cancelled
      • showDialog

        @SafeVarargs
        public static <T> T showDialog​(WindowBasedTextGUI textGUI,
                                       java.lang.String title,
                                       java.lang.String description,
                                       int listBoxHeight,
                                       T... items)
        Shortcut for quickly creating a new dialog
        Type Parameters:
        T - Type of items in the dialog
        Parameters:
        textGUI - Text GUI to add the dialog to
        title - Title of the dialog
        description - Description of the dialog
        listBoxHeight - Maximum height of the list box, scrollbars will be used if there are more items
        items - Items in the dialog
        Returns:
        The selected item or null if cancelled
      • showDialog

        @SafeVarargs
        public static <T> T showDialog​(WindowBasedTextGUI textGUI,
                                       java.lang.String title,
                                       java.lang.String description,
                                       TerminalSize listBoxSize,
                                       T... items)
        Shortcut for quickly creating a new dialog
        Type Parameters:
        T - Type of items in the dialog
        Parameters:
        textGUI - Text GUI to add the dialog to
        title - Title of the dialog
        description - Description of the dialog
        listBoxSize - Maximum size of the list box, scrollbars will be used if the items cannot fit
        items - Items in the dialog
        Returns:
        The selected item or null if cancelled