Class Lanterna

  • All Implemented Interfaces:
    adams.core.io.console.Console

    public class Lanterna
    extends Object
    implements adams.core.io.console.Console
    Helper for input using lanterna.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_Context

        protected com.googlecode.lanterna.gui2.MultiWindowTextGUI m_Context
        the lanterna context.
      • m_TextBoxLog

        protected com.googlecode.lanterna.gui2.TextBox m_TextBoxLog
        the text box for logging output.
    • Constructor Detail

      • Lanterna

        public Lanterna​(com.googlecode.lanterna.gui2.MultiWindowTextGUI context,
                        com.googlecode.lanterna.gui2.TextBox textBoxLog)
        Initializes the console helper.
        Parameters:
        context - the lanterna context
        textBoxLog - the textbox to use for logging output, can be null
    • Method Detail

      • enterMultiLineValue

        public String enterMultiLineValue​(String msg)
        Lets the user enter a multi-line value.
        Specified by:
        enterMultiLineValue in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterValue

        public String enterValue​(String msg)
        Lets the user enter a value.
        Specified by:
        enterValue in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterValue

        public String enterValue​(String msg,
                                 String initial)
        Lets the user enter a value.
        Specified by:
        enterValue in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        initial - the initial value, ignored if empty or null
        Returns:
        the entered value, null if cancelled or failed to read input (or initial value if empty string returned)
      • enterMultipleValues

        public String[] enterMultipleValues​(String msg)
        Lets the user enter multiple values. Empty string terminates the loop.
        Specified by:
        enterMultipleValues in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • enterPassword

        public adams.core.base.BasePassword enterPassword​(String msg)
        Lets the user enter a password.
        Specified by:
        enterPassword in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        Returns:
        the entered value, null if cancelled or failed to read input
      • selectOption

        public String selectOption​(String msg,
                                   String[] options)
        Lets the user select from a number of choices.
        Specified by:
        selectOption in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        options - the options to choose from
        Returns:
        the selected option, null if cancelled or failed to read input
      • selectOption

        public String selectOption​(String msg,
                                   String[] options,
                                   String initial)
        Lets the user select from a number of choices.
        Specified by:
        selectOption in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output before reading the input
        options - the options to choose from
        initial - the initial selection (selected if just hitting enter), null or empty string to ignore
        Returns:
        the selected option, null if cancelled or failed to read input
      • selectDirectory

        public adams.core.io.PlaceholderDirectory selectDirectory​(String msg,
                                                                  adams.core.io.PlaceholderDirectory initial)
        Lets the user select a directory.
        Specified by:
        selectDirectory in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output
        initial - the initial directory
        Returns:
        the directory, null if cancelled
      • selectFiles

        public adams.core.io.PlaceholderFile[] selectFiles​(String msg,
                                                           adams.core.io.PlaceholderFile... initial)
        Lets the user select files.
        Specified by:
        selectFiles in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output
        initial - the initial files
        Returns:
        the directory, null if cancelled
      • printlnOut

        public void printlnOut​(String msg)
        Outputs the message.
        Specified by:
        printlnOut in interface adams.core.io.console.Console
        Parameters:
        msg - the message to output
      • printlnErr

        public void printlnErr​(String msg)
        Outputs the error message.
        Specified by:
        printlnErr in interface adams.core.io.console.Console
        Parameters:
        msg - the error message to output