Class FWMessageDialog

All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, Runnable, EventListener, Accessible, RootPaneContainer, WindowConstants

public final class FWMessageDialog extends JDialog implements ActionListener, Runnable
This class serves as replacement for the JOptionPane: modal info, warning, exception, question, confirm, input, chooser, file chooser, form and console dialogs with localised captions. The static show... methods block until the dialog is closed.
See Also:
  • Field Details

    • INFO_ICON

      public static final Icon INFO_ICON
      Icon for InfoDialogs.
    • CONSOLE_ICON

      public static final Icon CONSOLE_ICON
      Icon for ConsoleDialogs.
    • QUESTION_ICON

      public static final Icon QUESTION_ICON
      Icon for QuestionDialogs.
    • CONFIRM_ICON

      public static final Icon CONFIRM_ICON
      Icon for ConfirmDialogs.
    • WARNING_ICON

      public static final Icon WARNING_ICON
      Icon for WarningDialogs.
    • EXCEPTION_ICON

      public static final Icon EXCEPTION_ICON
      Icon for ThrowableDialogs.
    • PROGRESS_ICON

      public static final Icon PROGRESS_ICON
      Icon for ProgressDialogs.
    • QUESTION_TITLE

      public static final String QUESTION_TITLE
      Title for questions.
    • WARNING_TITLE

      public static final String WARNING_TITLE
      Title for warnings.
    • PROGRESS_TITLE

      public static final String PROGRESS_TITLE
      Title for progress dialogs.
    • CONSOLE_TITLE

      public static final String CONSOLE_TITLE
      Title for console dialogs.
    • AUTODISPOSE_INFINITE_WAITING_TIME

      public static final int AUTODISPOSE_INFINITE_WAITING_TIME
      Infinite waiting time for the autodispose-messagepane.
      See Also:
    • QUESTION_YES

      public static final int QUESTION_YES
      Represents a possitive answer to a question.
      See Also:
    • QUESTION_NO

      public static final int QUESTION_NO
      Represents a negative answer to a question.
      See Also:
    • QUESTION_CANCEL

      public static final int QUESTION_CANCEL
      Represents a break to a question.
      See Also:
    • CONFIRM_OK

      public static final int CONFIRM_OK
      Represents a possitive confirm.
      See Also:
    • CONFIRM_CANCEL

      public static final int CONFIRM_CANCEL
      Represents a negative confirm.
      See Also:
    • QUESTION_MESSAGE

      public static final int QUESTION_MESSAGE
      See Also:
    • INFO_MESSAGE

      public static final int INFO_MESSAGE
      See Also:
    • SEND_EMAIL

      public static final int SEND_EMAIL
      Represents a email send option.
      See Also:
    • CONSOLE

      public static final int CONSOLE
      Represents a console dialog.
      See Also:
    • FILE_CHOOSER_MULTISELECT

      public static final int FILE_CHOOSER_MULTISELECT
      Represents File Chooser with selection option.
      See Also:
    • FILE_CHOOSER_SELECT

      public static final int FILE_CHOOSER_SELECT
      Represents File Chooser to select or give File Name option.
      See Also:
    • FILE_CHOOSER_DIR

      public static final int FILE_CHOOSER_DIR
      Represents File chooser to select existing directory option.
      See Also:
    • FILE_CHOOSER_EXISTING

      public static final int FILE_CHOOSER_EXISTING
      Represents File chooser to select existing file option.
      See Also:
  • Method Details

    • pack

      public void pack()
      Overrides java.awt.Window to recognize minimum-size.
      Overrides:
      pack in class Window
    • actionPerformed

      public void actionPerformed(ActionEvent aActionEvent)
      Is called after one of the buttons is pressed: shows/hides the throwable details, saves a problem report, updates the console, opens the file chooser or closes the dialog and records the clicked button.
      Specified by:
      actionPerformed in interface ActionListener
    • showOptionPaneDialog

      public static int showOptionPaneDialog(Window aParent, String aMessage, String aTitle, int aIconType, int aButtonType)
      Replacement for JOptionPane.showOptionDialog with JOptionPane constants.
      Parameters:
      aParent - parent window
      aMessage - shown message
      aTitle - dialog title
      aIconType - JOptionPane message type (ERROR_MESSAGE, INFORMATION_MESSAGE, ...)
      aButtonType - JOptionPane option type (YES_NO_OPTION, OK_CANCEL_OPTION, ...)
      Returns:
      int representing the choice user has done (JOptionPane YES_OPTION, NO_OPTION, OK_OPTION, CANCEL_OPTION) or -1 if the dialog was closed otherwise
    • showCustomDialog

      public static int showCustomDialog(Window aParent, String aTitle, Icon aIcon, String aMessage, String[] aButtonCaptions)
      Shows a dialog with the custom settings.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aIcon - icon
      aMessage - shown message
      aButtonCaptions - captions of the buttons
      Returns:
      index of the clicked Button, -1 if the dialog was closed without button
    • showCustomDialog

      public static int showCustomDialog(Window aParent, String aTitle, Icon aIcon, String aMessage, int aDefaultButtonIndex)
      Shows a dialog with yes/no buttons.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aIcon - icon
      aMessage - shown message
      aDefaultButtonIndex - index of the default button (0 = yes, 1 = no)
      Returns:
      index of the clicked Button, -1 if the dialog was closed without button
    • showInfoDialog

      public static void showInfoDialog(Window aParent, String aInfo)
      Shows a simple infopanel.
      Parameters:
      aParent - parent window
      aInfo - shown info text
    • showInfoDialog

      public static void showInfoDialog(Window aParent, String aInfo, String aMessageID)
      Shows a simple infopanel.
      Parameters:
      aParent - parent window
      aInfo - shown info text
      aMessageID - message id (currently not used)
    • showConsoleDialog

      @Deprecated public static void showConsoleDialog(Window aParent, File aConsoleFile, String aMessageID)
      Deprecated.
      not used
      Shows the content of a log file in a console dialog.
      Parameters:
      aParent - parent window
      aConsoleFile - the log file
      aMessageID - message id (currently not used)
    • showAutodisposeInfoDialog

      public static void showAutodisposeInfoDialog(Window aParent, String aInfo, int aAutodisposeWaitingTime)
      Shows a simple infopanel that closes automatically.
      Parameters:
      aParent - parent window
      aInfo - shown info text
      aAutodisposeWaitingTime - waiting time until the dialog is closed (values below 1000 are seconds, otherwise milliseconds)
    • showInfoDialog

      public static void showInfoDialog(Window aParent, String aInfo, int aAutodisposeWaitingTime, String aMessageID)
      Shows a simple infopanel.
      Parameters:
      aParent - parent window
      aInfo - shown info text
      aAutodisposeWaitingTime - waiting time until the dialog is closed (values below 1000 are seconds, otherwise milliseconds), AUTODISPOSE_INFINITE_WAITING_TIME for no autodispose
      aMessageID - message id (currently not used)
    • showConsoleDialog

      public static void showConsoleDialog(Window aParent, File aConsoleFile, int aAutodisposeWaitingTime, String aMessageID)
      Shows the content of a log file in a console dialog with an update button.
      Parameters:
      aParent - parent window
      aConsoleFile - the log file
      aAutodisposeWaitingTime - waiting time until the dialog is closed (values below 1000 are seconds, otherwise milliseconds), AUTODISPOSE_INFINITE_WAITING_TIME for no autodispose
      aMessageID - message id (currently not used)
    • showInputDialogWithoutCancelButton

      public static String showInputDialogWithoutCancelButton(Window aParent, String aTitle, String aInfo)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo, Icon aIcon)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aIcon - icon
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo, boolean aPasswordField)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aPasswordField - true for a password field
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo, String aDefaultValue)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aDefaultValue - default value or default selection
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo, String aDefaultValue, boolean aPasswordField)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aDefaultValue - default value or default selection
      aPasswordField - true for a password field
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo, String aDefaultValue, boolean aPasswordField, boolean aShowCancelButton)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aDefaultValue - default value or default selection
      aPasswordField - true for a password field
      aShowCancelButton - whether the cancel button is shown
      Returns:
      the entered text, or null if cancelled
    • showInputDialog

      public static String showInputDialog(Window aParent, String aTitle, String aInfo, String aDefaultValue, boolean aPasswordField, boolean aShowCancelButton, Icon aIcon)
      Shows a simple input panel.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aDefaultValue - default value or default selection
      aPasswordField - true for a password field
      aShowCancelButton - whether the cancel button is shown
      aIcon - icon
      Returns:
      the entered text, or null if cancelled
    • showFileChooserDialog

      public static String showFileChooserDialog(Window aParent, String aTitle, String aInfo, String aDefaultValue, Integer aFileChooserOption)
      Shows an input panel with a button opening a file chooser.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aDefaultValue - default file (for FILE_CHOOSER_MULTISELECT a comma separated list of files); its extension selects the file filter
      aFileChooserOption - one of the FILE_CHOOSER_* constants
      Returns:
      the chosen file, for FILE_CHOOSER_MULTISELECT a comma separated list of all files in the combo box, or null if cancelled
    • showChooserDialog

      public static Object showChooserDialog(Window aParent, String aTitle, String aInfo, Collection<Object> aValueCollection)
      Shows a dialog with a combo box.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aValueCollection - values of the combo box
      Returns:
      the selected value, or null if cancelled
    • showChooserDialog

      public static Object showChooserDialog(Window aParent, String aTitle, String aInfo, Collection<Object> aValueCollection, Object aDefaultValue)
      Shows a dialog with a combo box.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aValueCollection - values of the combo box
      aDefaultValue - initially selected value
      Returns:
      the selected value, or null if cancelled
    • showDoubleChooserDialog

      public static Object[] showDoubleChooserDialog(Window aParent, String aTitle, String aInfo, Collection aSourceValueCollection, Collection aTargetValueCollection)
      Shows a dialog with two combo boxes.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aSourceValueCollection - values of the first combo box
      aTargetValueCollection - values of the second combo box
      Returns:
      the 2 selected values or null if cancel was pressed
    • showQuestionDialog

      public static int showQuestionDialog(Window aParent, String aQuestion, boolean aShowCancel)
      Shows a dialog, which asks the user to press either yes, no and perhaps cancel.
      Parameters:
      aParent - parent window
      aQuestion - shown question
      aShowCancel - whether a cancel button is shown
      Returns:
      int representing the choice user has done.
    • showQuestionDialog

      public static int showQuestionDialog(Window aParent, String aQuestion, boolean aShowCancel, int aDefaultButtonIndex)
      Shows a dialog, whichs ask the user to press either yes, no and perhaps cancel.
      Parameters:
      aParent - parent window
      aQuestion - shown question
      aShowCancel - whether a cancel button is shown
      aDefaultButtonIndex - index of the default button, -1 for the first button
      Returns:
      int representing the choice user has done.
    • showOptionDialog

      public static int showOptionDialog(Window aParent, String aMessage, String[] aOptions, int aMessageType)
      Shows a dialog, which asks the user to press either yes, no and perhaps cancel.
      Parameters:
      aParent - parent window
      aMessage - shown message
      aOptions - captions of the buttons (up to three are mapped to yes/no/cancel)
      aMessageType - QUESTION_MESSAGE or INFO_MESSAGE
      Returns:
      int representing the choice user has done.
    • showFormDialog

      public static net.simplace.core.FWObservable showFormDialog(Window aParent, String aTitle, String aInfo, org.jdom2.Element aFormElement, net.simplace.core.FWObservable aObservable, boolean aShowCancelButton)
      Shows a form dialog. If required fields are empty on OK, the error is logged and the dialog is shown again.
      Parameters:
      aParent - parent window
      aTitle - dialog title
      aInfo - shown info text
      aFormElement - the form definition
      aObservable - observable holding the form values
      aShowCancelButton - whether the cancel button is shown
      Returns:
      the observable of the form panel with the entered values, or null if cancelled
    • showQuestionDialog

      public static int showQuestionDialog(Window aParent, String aLocaleBundle, String aLocaleKey, boolean aShowCancel)
      Shows a dialog, which asks the user to press either yes, no and perhaps cancel.
      Parameters:
      aParent - parent window
      aLocaleBundle - name of the locale bundle
      aLocaleKey - key of the message text
      aShowCancel - whether a cancel button is shown
      Returns:
      int representing the choice user has done.
    • showQuestionDialog

      public static int showQuestionDialog(Window aParent, String aMessage)
      Shows a dialog, whichs ask the user to press either yes, no.
      Parameters:
      aParent - parent window
      aMessage - shown message
      Returns:
      int representing the choice user has done.
    • showQuestionDialog

      public static int showQuestionDialog(Window aParent, String aLocaleBundle, String aLocaleKey)
      Shows a dialog, whichs ask the user to press either yes, no.
      Parameters:
      aParent - parent window
      aLocaleBundle - name of the locale bundle
      aLocaleKey - key of the message text
      Returns:
      int representing the choice user has done.
    • showConfirmDialog

      public static int showConfirmDialog(Window aParent, String aMessage)
      Shows a dialog which asks the user to either confirm or break a process;
      Parameters:
      aParent - parent window
      aMessage - shown message
      Returns:
      int representing the choice user has done.
    • showConfirmDialog

      public static int showConfirmDialog(Window aParent, String aMessage, String aMessageID)
      Shows a dialog which asks the user to either confirm or break a process;
      Parameters:
      aParent - parent window
      aMessage - shown message
      aMessageID - message id (currently not used)
      Returns:
      int representing the choice user has done.
    • showWarningQuestion

      public static int showWarningQuestion(Window aParent, String aQuestion)
      Shows a dialog which asks the user with warning him/her of the importance.
      Parameters:
      aParent - parent window
      aQuestion - shown question
      Returns:
      int representing the choice user has done.
    • showWarningQuestion

      public static int showWarningQuestion(Window aParent, String aQuestion, int aDefaultButtonIndex)
      Shows a dialog which asks the user with warning him/her of the importance.
      Parameters:
      aParent - The parent window
      aQuestion - Question to pose
      aDefaultButtonIndex - 1=NO , 0=YES, -1=DefaultSettings
      Returns:
      int representing the choice user has done.
    • showWarningDialog

      public static void showWarningDialog(Window aParent, String aWarning, Throwable aThrowable)
      Shows a dialog which warns user of a minor Throwable.
      Parameters:
      aParent - parent window
      aWarning - shown warning
      aThrowable - throwable shown in the details, or null
    • showWarningDialog

      public static void showWarningDialog(Window aParent, String aWarning, String aMessageID, Throwable aThrowable)
      Shows a dialog which warns user of a minor Throwable.
      Parameters:
      aParent - parent window
      aWarning - shown warning
      aMessageID - message id (currently not used)
      aThrowable - throwable shown in the details, or null
    • showWarningDialog

      public static void showWarningDialog(Window aParent, String aWarning)
      Shows a dialog which warns user of something.
      Parameters:
      aParent - parent window
      aWarning - shown warning
    • showWarningDialog

      public static void showWarningDialog(Window aParent, String aLocaleBundle, String aLocaleKey)
      Shows a dialog which warns user of something.
      Parameters:
      aParent - parent window
      aLocaleBundle - name of the locale bundle
      aLocaleKey - key of the message text
    • showExceptionDialog

      public static void showExceptionDialog(Window aParent, String aMessage, Throwable aThrowable)
      Shows a dialog, which warns the user, that a Throwable has happened.
      Parameters:
      aParent - parent window
      aMessage - shown message
      aThrowable - throwable shown in the details, or null
    • showEmailExceptionDialog

      public static int showEmailExceptionDialog(Window aParent, String aMessage, Throwable aThrowable)
      Shows a dialog, which warns the user, that a Throwable has happened and also the Email functionality button. This should be used if a functionality is implemented for email sending.
      Parameters:
      aParent - parent window
      aMessage - shown message
      aThrowable - throwable shown in the details, or null
      Returns:
      int representing the choice user has done.
    • showExceptionDialog

      public static void showExceptionDialog(Window aParent, String aLocaleBundle, String aLocaleKey, Throwable aThrowable)
      Shows a dialog, which warns the user, that a Throwable has happened.
      Parameters:
      aParent - parent window
      aLocaleBundle - name of the locale bundle
      aLocaleKey - key of the message text
      aThrowable - throwable shown in the details, or null
    • run

      public void run()
      Waits the autodispose time and closes the dialog, if it isn`t closed manually in the given time.
      Specified by:
      run in interface Runnable
    • showMessage

      public static void showMessage(Window aWindow, FWMessage aMessage)
      Displays the given Message object.
      Parameters:
      aWindow - parent window
      aMessage - the message (type ERROR, INFO or WARNING selects the dialog)
    • updateConsole

      public static String updateConsole(File aConsoleFile)
      Reads the console (log) file and resolves its resource tags.
      Parameters:
      aConsoleFile - the log file
      Returns:
      the content of the file, or an empty string if it cannot be read