Package org.esa.snap.ui
Class AbstractDialog
- java.lang.Object
-
- org.esa.snap.ui.AbstractDialog
-
- Direct Known Subclasses:
AbstractModalDialog
,ModalDialog
,ModelessDialog
public abstract class AbstractDialog extends Object
TheAbstractDialog
is the base class forModalDialog
andModelessDialog
, two helper classes used to quickly construct modal and modeless dialogs. The dialogs created with this class have a unique border and font and a standard button row for the typical buttons like "OK", "Cancel" etc.Instances of a modal dialog are created with a parent component, a title, the actual dialog content component, and a bit-combination of the standard buttons to be used.
A limited way of input validation is provided by the
verifyUserInput
method which can be overridden in order to returnfalse
if a user input is invalid. In this case theonOK()
,onYes()
andonNo()
methods are NOT called.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractDialog(JDialog dialog, int buttonMask, Object[] otherButtons, String helpID)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
center()
Centers the dialog within its parent window.abstract void
close()
This method is called, when the user clicks the close button of the dialog's top window bar.protected void
collectButtons(List<AbstractButton> buttons)
Called by the constructor in order to initialise the user interface.AbstractButton
getButton(int buttonID)
Gets the button for the given identifier.int
getButtonID()
Gets the identifier for the most recently pressed button.int
getButtonMask()
Gets the button mask passed to the constructor.JPanel
getButtonPanel()
Component
getContent()
Gets the dialog's content component.String
getHelpID()
Gets the help identifier for the dialog.JDialog
getJDialog()
Gets the underlying Swing dialog passed to the constructor.Window
getParent()
Gets the owner of the dialog.protected String
getQualifiedPropertyName(String name)
String
getTitle()
void
hide()
Hides the dialog.protected void
onApply()
Called if the "Apply" button has been clicked.protected void
onCancel()
Called if the "Cancel" button has been clicked.protected void
onClose()
Called if the "Close" button has been clicked.protected void
onHelp()
Called if the help button has been clicked.protected void
onNo()
Called if the "No" button has been clicked.protected void
onOK()
Called if the "OK" button has been clicked.protected void
onOther()
Called if a non-standard button has been clicked.protected void
onReset()
Called if the reset button has been clicked.protected void
onYes()
Called if the "Yes" button has been clicked.protected void
registerButton(int buttonID, AbstractButton button)
protected void
setButtonID(int buttonID)
Sets the identifier for the most recently pressed button.void
setContent(Component content)
Sets the dialog's content component.void
setContent(Object content)
Sets the dialog's content.void
setHelpID(String helpID)
Sets the help identifier for the dialog.void
setTitle(String title)
int
show()
Shows the dialog.static void
showErrorDialog(Component component, String message, String dialogTitle)
void
showErrorDialog(String errorMessage)
Shows an error dialog on top of this dialog.void
showErrorDialog(String message, String title)
static void
showInformationDialog(Component component, String message, String dialogTitle)
void
showInformationDialog(String infoMessage)
Shows an information dialog on top of this dialog.void
showInformationDialog(String infoMessage, String title)
static void
showWarningDialog(Component component, String message, String dialogTitle)
void
showWarningDialog(String warningMessage)
Shows a warning dialog on top of this dialog.void
showWarningDialog(String warningMessage, String title)
protected boolean
verifyUserInput()
Called in order to perform input validation.
-
-
-
Field Detail
-
ID_OK
public static final int ID_OK
- See Also:
- Constant Field Values
-
ID_YES
public static final int ID_YES
- See Also:
- Constant Field Values
-
ID_NO
public static final int ID_NO
- See Also:
- Constant Field Values
-
ID_APPLY
public static final int ID_APPLY
- See Also:
- Constant Field Values
-
ID_CLOSE
public static final int ID_CLOSE
- See Also:
- Constant Field Values
-
ID_CANCEL
public static final int ID_CANCEL
- See Also:
- Constant Field Values
-
ID_RESET
public static final int ID_RESET
- See Also:
- Constant Field Values
-
ID_HELP
public static final int ID_HELP
- See Also:
- Constant Field Values
-
ID_OTHER
public static final int ID_OTHER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getJDialog
public JDialog getJDialog()
Gets the underlying Swing dialog passed to the constructor.- Returns:
- the underlying Swing dialog.
-
getParent
public Window getParent()
Gets the owner of the dialog.- Returns:
- The owner of the dialog.
-
getTitle
public String getTitle()
- Returns:
- The dialog's title.
-
setTitle
public void setTitle(String title)
- Parameters:
title
- The dialog's title.
-
getButtonMask
public int getButtonMask()
Gets the button mask passed to the constructor.- Returns:
- The button mask.
-
getButtonID
public int getButtonID()
Gets the identifier for the most recently pressed button.- Returns:
- The identifier for the most recently pressed button.
-
setButtonID
protected void setButtonID(int buttonID)
Sets the identifier for the most recently pressed button.- Parameters:
buttonID
- The identifier for the most recently pressed button.
-
getHelpID
public String getHelpID()
Gets the help identifier for the dialog.- Returns:
- The help identifier.
-
setHelpID
public void setHelpID(String helpID)
Sets the help identifier for the dialog.- Parameters:
helpID
- The help identifier.
-
getButtonPanel
public JPanel getButtonPanel()
-
getContent
public Component getContent()
Gets the dialog's content component.- Returns:
- The dialog's content component.
-
setContent
public void setContent(Component content)
Sets the dialog's content component.- Parameters:
content
- The dialog's content component.
-
setContent
public void setContent(Object content)
Sets the dialog's content.- Parameters:
content
- The dialog's content.
-
getButton
public AbstractButton getButton(int buttonID)
Gets the button for the given identifier.- Parameters:
buttonID
- The button identifier.- Returns:
- The button, or
null
.
-
show
public int show()
Shows the dialog. Overrides shall callsuper.show()
at the end.- Returns:
- the identifier of the last button pressed or zero if this is a modeless dialog.
-
hide
public void hide()
Hides the dialog. Overrides shall callsuper.hide()
at the end. This method does nothing else than hiding the underlying Swing dialog.- See Also:
getJDialog()
-
close
public abstract void close()
This method is called, when the user clicks the close button of the dialog's top window bar. It can also be called directly. Override to implement the dialog's default close behaviour.
-
center
public void center()
Centers the dialog within its parent window.
-
showErrorDialog
public void showErrorDialog(String errorMessage)
Shows an error dialog on top of this dialog.- Parameters:
errorMessage
- The message.
-
showErrorDialog
public static void showErrorDialog(Component component, String message, String dialogTitle)
-
showInformationDialog
public void showInformationDialog(String infoMessage)
Shows an information dialog on top of this dialog.- Parameters:
infoMessage
- The message.
-
showInformationDialog
public static void showInformationDialog(Component component, String message, String dialogTitle)
-
showWarningDialog
public void showWarningDialog(String warningMessage)
Shows a warning dialog on top of this dialog.- Parameters:
warningMessage
- The message.
-
showWarningDialog
public static void showWarningDialog(Component component, String message, String dialogTitle)
-
onOK
protected void onOK()
Called if the "OK" button has been clicked. The default implementation callshide()
. Clients should override this method to implement meaningful behaviour.
-
onYes
protected void onYes()
Called if the "Yes" button has been clicked. The default implementation callshide()
. Clients should override this method to implement meaningful behaviour.
-
onNo
protected void onNo()
Called if the "No" button has been clicked. The default implementation callshide()
. Clients should override this method to implement meaningful behaviour.
-
onCancel
protected void onCancel()
Called if the "Cancel" button has been clicked. The default implementation callshide()
. Clients should override this method to implement meaningful behaviour.
-
onApply
protected void onApply()
Called if the "Apply" button has been clicked. The default implementation does nothing. Clients should override this method to implement meaningful behaviour.
-
onClose
protected void onClose()
Called if the "Close" button has been clicked. The default implementation callshide()
. Clients should override this method to implement meaningful behaviour.
-
onReset
protected void onReset()
Called if the reset button has been clicked. The default implementation does nothing. Clients should override this method to implement meaningful behaviour.
-
onHelp
protected void onHelp()
Called if the help button has been clicked. Clients should override this method to implement a different behaviour.
-
onOther
protected void onOther()
Called if a non-standard button has been clicked. The default implementation callshide()
. Clients should override this method to implement meaningful behaviour.
-
verifyUserInput
protected boolean verifyUserInput()
Called in order to perform input validation.- Returns:
true
if and only if the validation was successful.
-
collectButtons
protected void collectButtons(List<AbstractButton> buttons)
Called by the constructor in order to initialise the user interface. The default implementation does nothing.- Parameters:
buttons
- The container into which new buttons shall be collected.
-
registerButton
protected void registerButton(int buttonID, AbstractButton button)
-
-