Class AbstractNumberInputDialog

java.lang.Object
docking.DialogComponentProvider
docking.widgets.dialogs.AbstractNumberInputDialog
All Implemented Interfaces:
ActionContextProvider, StatusListener, TaskListener
Direct Known Subclasses:
BigIntegerNumberInputDialog, NumberInputDialog

public abstract class AbstractNumberInputDialog extends DialogComponentProvider
A base class for prompting users to enter a number into this dialog
  • Field Details

    • wasCancelled

      protected boolean wasCancelled
    • numberInputField

      protected IntegerTextField numberInputField
    • min

      protected BigInteger min
    • max

      protected BigInteger max
    • label

      protected JLabel label
    • defaultMessage

      protected String defaultMessage
  • Constructor Details

    • AbstractNumberInputDialog

      public AbstractNumberInputDialog(String title, String prompt, Integer initialValue, int min, int max, boolean showAsHex)
      Show a number input dialog
      Parameters:
      title - The title of the dialog
      prompt - the prompt to display before the number input field
      initialValue - the default value to display, null will leave the field blank
      min - the minimum allowed value of the field
      max - the maximum allowed value of the field
      showAsHex - if true, the initial value will be displayed as hex
    • AbstractNumberInputDialog

      public AbstractNumberInputDialog(String title, String prompt, BigInteger initialValue, BigInteger min, BigInteger max, boolean showAsHex)
      Show a number input dialog
      Parameters:
      title - The title of the dialog
      prompt - the prompt to display before the number input field
      initialValue - the default value to display, null will leave the field blank
      min - the minimum allowed value of the field
      max - the maximum allowed value of the field
      showAsHex - if true, the initial value will be displayed as hex
  • Method Details

    • buildMainPanel

      protected JPanel buildMainPanel(String prompt, boolean showAsHex)
      Define the Main panel for the dialog here
      Parameters:
      prompt - the prompt label text
      showAsHex - if true, show the value as hex
      Returns:
      JPanel the completed Main Panel
    • okCallback

      protected void okCallback()
      Gets called when the user clicks on the OK Action for the dialog.
      Overrides:
      okCallback in class DialogComponentProvider
    • cancelCallback

      protected void cancelCallback()
      Gets called when the user clicks on the Cancel Action for the dialog.
      Overrides:
      cancelCallback in class DialogComponentProvider
    • wasCancelled

      public boolean wasCancelled()
      Return whether the user cancelled the input dialog
      Returns:
      true if cancelled
    • getBigIntegerValue

      public BigInteger getBigIntegerValue()
      Get the current input value
      Returns:
      the value
      Throws:
      NumberFormatException - if entered value cannot be parsed
      IllegalStateException - if the dialog was cancelled
    • getLongValue

      public long getLongValue()
      Get the current input value as a long
      Returns:
      the value
      Throws:
      NumberFormatException - if entered value cannot be parsed
      IllegalStateException - if the dialog was cancelled
      ArithmeticException - if the value in this field will not fit into a long
    • getIntValue

      public int getIntValue()
      Get the current input value as an int
      Returns:
      the value
      Throws:
      NumberFormatException - if entered value cannot be parsed
      IllegalStateException - if the dialog was cancelled
      ArithmeticException - if the value in this field will not fit into an int
    • show

      public boolean show()
      show displays the dialog, gets the user input
      Returns:
      false if the user cancelled the operation
    • setInput

      public void setInput(int value)
      Sets the value in the input field to the indicated value.
      Parameters:
      value - the value
    • setDefaultMessage

      public void setDefaultMessage(String defaultMessage)
      Sets the default message to be displayed when valid values are in the text fields.
      Parameters:
      defaultMessage - the message to be displayed when valid values are in the text fields.
    • getMin

      public int getMin()
      Return the minimum acceptable value.
      Returns:
      the min
    • getMax

      public int getMax()
      Return the maximum acceptable value.
      Returns:
      the max
    • updateOKButtonEnablement

      protected void updateOKButtonEnablement()
    • buildDefaultPrompt

      protected static String buildDefaultPrompt(String entryType, int min, int max)
    • toBig

      protected static BigInteger toBig(Integer i)