Package docking.widgets.dialogs
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 Summary
Fields Modifier and Type Field Description protected java.lang.StringdefaultMessageprotected javax.swing.JLabellabelprotected java.math.BigIntegermaxprotected java.math.BigIntegerminprotected IntegerTextFieldnumberInputFieldprotected booleanwasCancelled-
Fields inherited from class docking.DialogComponentProvider
applyButton, buttonPanel, cancelButton, dismissButton, okButton, rootPanel
-
-
Constructor Summary
Constructors Constructor Description AbstractNumberInputDialog(java.lang.String title, java.lang.String prompt, java.lang.Integer initialValue, int min, int max, boolean showAsHex)Show a number input dialogAbstractNumberInputDialog(java.lang.String title, java.lang.String prompt, java.math.BigInteger initialValue, java.math.BigInteger min, java.math.BigInteger max, boolean showAsHex)Show a number input dialog
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.StringbuildDefaultPrompt(java.lang.String entryType, int min, int max)protected javax.swing.JPanelbuildMainPanel(java.lang.String prompt, boolean showAsHex)Define the Main panel for the dialog hereprotected voidcancelCallback()Gets called when the user clicks on the Cancel Action for the dialog.java.math.BigIntegergetBigIntegerValue()Get the current input valueintgetIntValue()Get the current input value as an intlonggetLongValue()Get the current input value as a longintgetMax()Return the maximum acceptable value.intgetMin()Return the minimum acceptable value.protected voidokCallback()Gets called when the user clicks on the OK Action for the dialog.voidsetDefaultMessage(java.lang.String defaultMessage)Sets the default message to be displayed when valid values are in the text fields.voidsetInput(int value)Sets the value in the input field to the indicated value.booleanshow()showdisplays the dialog, gets the user inputprotected static java.math.BigIntegertoBig(java.lang.Integer i)protected voidupdateOKButtonEnablement()booleanwasCancelled()Return whether the user cancelled the input dialog-
Methods inherited from class docking.DialogComponentProvider
addAction, addApplyButton, addButton, addCancelButton, addDismissButton, addOKButton, addWorkPanel, alertMessage, alertMessage, applyCallback, cancelCurrentTask, clearScheduledTask, clearStatusText, close, dialogClosed, dialogShown, dismissCallback, dispose, doInitialize, escapeCallback, executeProgressTask, getActionContext, getActions, getBackground, getBounds, getComponent, getDefaultButton, getDefaultSize, getDialogSize, getFocusComponent, getGlassPane, getHelpLocatdion, getId, getIntialLocation, getLocationOnScreen, getParent, getPreferredSize, getRemberSize, getRememberLocation, getStatusColor, getStatusLabel, getStatusText, getTaskMonitorComponent, getTaskScheduler, getTitle, getUseSharedLocation, hideTaskMonitorComponent, isApplyEnabled, isCancelEnabled, isModal, isOKEnabled, isResizeable, isRunningTask, isShowing, isTransient, isVisible, notifyContextChanged, removeAction, removeButton, removeWorkPanel, repack, setApplyEnabled, setApplyToolTip, setBackground, setCancelButtonText, setCancelEnabled, setCancelToolTip, setCursor, setDefaultButton, setDefaultSize, setDialogSize, setDismissToolTip, setFocusComponent, setGlassPane, setHelpLocation, setInitialLocation, setMinimumSize, setMinimumSize, setOkButtonText, setOkEnabled, setOkToolTip, setPreferredSize, setRememberLocation, setRememberSize, setResizable, setStatusJustification, setStatusText, setStatusText, setStatusText, setTitle, setTransient, setUseSharedLocation, showProgressBar, showTaskMonitorComponent, stopProgressTimer, taskCancelled, taskCompleted, toFront, toString, waitForCurrentTask
-
-
-
-
Field Detail
-
wasCancelled
protected boolean wasCancelled
-
numberInputField
protected IntegerTextField numberInputField
-
min
protected java.math.BigInteger min
-
max
protected java.math.BigInteger max
-
label
protected javax.swing.JLabel label
-
defaultMessage
protected java.lang.String defaultMessage
-
-
Constructor Detail
-
AbstractNumberInputDialog
public AbstractNumberInputDialog(java.lang.String title, java.lang.String prompt, java.lang.Integer initialValue, int min, int max, boolean showAsHex)Show a number input dialog- Parameters:
title- The title of the dialogprompt- the prompt to display before the number input fieldinitialValue- the default value to display, null will leave the field blankmin- the minimum allowed value of the fieldmax- the maximum allowed value of the fieldshowAsHex- if true, the initial value will be displayed as hex
-
AbstractNumberInputDialog
public AbstractNumberInputDialog(java.lang.String title, java.lang.String prompt, java.math.BigInteger initialValue, java.math.BigInteger min, java.math.BigInteger max, boolean showAsHex)Show a number input dialog- Parameters:
title- The title of the dialogprompt- the prompt to display before the number input fieldinitialValue- the default value to display, null will leave the field blankmin- the minimum allowed value of the fieldmax- the maximum allowed value of the fieldshowAsHex- if true, the initial value will be displayed as hex
-
-
Method Detail
-
buildMainPanel
protected javax.swing.JPanel buildMainPanel(java.lang.String prompt, boolean showAsHex)Define the Main panel for the dialog here- Parameters:
prompt- the prompt label textshowAsHex- 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:
okCallbackin classDialogComponentProvider
-
cancelCallback
protected void cancelCallback()
Gets called when the user clicks on the Cancel Action for the dialog.- Overrides:
cancelCallbackin classDialogComponentProvider
-
wasCancelled
public boolean wasCancelled()
Return whether the user cancelled the input dialog- Returns:
- true if cancelled
-
getBigIntegerValue
public java.math.BigInteger getBigIntegerValue()
Get the current input value- Returns:
- the value
- Throws:
java.lang.NumberFormatException- if entered value cannot be parsedjava.lang.IllegalStateException- if the dialog was cancelled
-
getLongValue
public long getLongValue()
Get the current input value as a long- Returns:
- the value
- Throws:
java.lang.NumberFormatException- if entered value cannot be parsedjava.lang.IllegalStateException- if the dialog was cancelledjava.lang.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:
java.lang.NumberFormatException- if entered value cannot be parsedjava.lang.IllegalStateException- if the dialog was cancelledjava.lang.ArithmeticException- if the value in this field will not fit into an int
-
show
public boolean show()
showdisplays 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(java.lang.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 java.lang.String buildDefaultPrompt(java.lang.String entryType, int min, int max)
-
toBig
protected static java.math.BigInteger toBig(java.lang.Integer i)
-
-