Class Dialogs


  • public class Dialogs
    extends java.lang.Object
    Error and Info Box utility class. This class should be used to have a common look and feel for error and info dialogs.
    Author:
    Holger Eichelberger
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Dialogs()
      Utility class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.eclipse.swt.widgets.Shell getDefaultShell()
      Returns the default shell of the workbench.
      static int showConfirmDialog​(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String message)
      Shows a confirmation dialog, where the user must decide between yes or no.
      private static int showDialog​(org.eclipse.swt.widgets.Shell parent, java.lang.String message, java.lang.String title, int style)
      Opens a specific dialog with the given parameters.
      static void showErrorDialog​(java.lang.String title, java.lang.Class<?> caller, java.lang.Exception exception)
      Displays an error dialog on the default shell for the given exception on the default shell.
      static void showErrorDialog​(java.lang.String title, java.lang.String message)
      Displays an error dialog on the default shell.
      static void showErrorDialog​(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.Class<?> caller, java.lang.Exception exception)
      Displays an error dialog for the given exception on the default shell.
      static void showErrorDialog​(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String message)
      Shows an error dialog.
      static int showInfoConfirmDialog​(java.lang.String title, java.lang.String message)
      Shows a confirmation dialog on the default shell, where the user must decide between yes or no.
      static void showInfoDialog​(java.lang.String title, java.lang.String message)
      Displays an error dialog on the default shell.
      static void showInfoDialog​(org.eclipse.swt.widgets.Shell parent, java.lang.String title, java.lang.String message)
      Shows an info dialog.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Dialogs

        private Dialogs()
        Utility class.
    • Method Detail

      • showDialog

        private static int showDialog​(org.eclipse.swt.widgets.Shell parent,
                                      java.lang.String message,
                                      java.lang.String title,
                                      int style)
        Opens a specific dialog with the given parameters.
        Parameters:
        parent - The parent of this dialog (may be null)
        message - The message to be shown in the message box.
        title - The title in the top of the window
        style - The SWT Style, which specifies the behavior of the dialog
        Returns:
        The result of the dialog or 0
      • getDefaultShell

        public static org.eclipse.swt.widgets.Shell getDefaultShell()
        Returns the default shell of the workbench.
        Returns:
        the default shell
      • showErrorDialog

        public static void showErrorDialog​(java.lang.String title,
                                           java.lang.Class<?> caller,
                                           java.lang.Exception exception)
        Displays an error dialog on the default shell for the given exception on the default shell.
        Parameters:
        title - the title of the error dialog
        caller - the calling class (for logging)
        exception - the exception the message shall be displayed for
      • showErrorDialog

        public static void showErrorDialog​(org.eclipse.swt.widgets.Shell parent,
                                           java.lang.String title,
                                           java.lang.Class<?> caller,
                                           java.lang.Exception exception)
        Displays an error dialog for the given exception on the default shell.
        Parameters:
        parent - The parent of this dialog (may be null, then the default shell will be used)
        title - the title of the error dialog
        caller - the calling class (for logging)
        exception - the exception the message shall be displayed for
      • showErrorDialog

        public static void showErrorDialog​(java.lang.String title,
                                           java.lang.String message)
        Displays an error dialog on the default shell.
        Parameters:
        title - the title of the error dialog
        message - the error message
      • showErrorDialog

        public static void showErrorDialog​(org.eclipse.swt.widgets.Shell parent,
                                           java.lang.String title,
                                           java.lang.String message)
        Shows an error dialog.
        Parameters:
        parent - The parent of this dialog (may be null, then the default shell will be used)
        title - the title of the error dialog
        message - the error massage
      • showInfoDialog

        public static void showInfoDialog​(java.lang.String title,
                                          java.lang.String message)
        Displays an error dialog on the default shell.
        Parameters:
        title - the title of the error dialog
        message - the error message
      • showInfoDialog

        public static void showInfoDialog​(org.eclipse.swt.widgets.Shell parent,
                                          java.lang.String title,
                                          java.lang.String message)
        Shows an info dialog.
        Parameters:
        parent - The parent of this dialog (may be null, then the default shell will be used)
        title - the title of the information dialog
        message - the information massage
      • showInfoConfirmDialog

        public static int showInfoConfirmDialog​(java.lang.String title,
                                                java.lang.String message)
        Shows a confirmation dialog on the default shell, where the user must decide between yes or no.
        Parameters:
        title - the title of the confirmation dialog
        message - The confirmation message/question
        Returns:
        SWT.YES or SWT.NO
      • showConfirmDialog

        public static int showConfirmDialog​(org.eclipse.swt.widgets.Shell parent,
                                            java.lang.String title,
                                            java.lang.String message)
        Shows a confirmation dialog, where the user must decide between yes or no.
        Parameters:
        parent - The parent of this dialog (may be null, then the default shell will be used)
        title - the title of the confirmation dialog
        message - The confirmation message/question
        Returns:
        SWT.YES or SWT.NO