Class AbstractDialogFactory

  • All Implemented Interfaces:
    DialogFactory
    Direct Known Subclasses:
    DefaultDialogFactory

    public abstract class AbstractDialogFactory
    extends java.lang.Object
    implements DialogFactory
    This is a default implementation of a dialog factory used for showing various types of dialog boxes containing messages, information, questions, etc. For documentation see DialogFactory interface.
    Version:
    1.0
    Author:
    Ivan Pribela
    See Also:
    DialogFactory
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractDialogFactory​(java.util.Locale locale, java.awt.datatransfer.Clipboard clipboard)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addAutoCloseSupport​(javax.swing.JDialog dialog, javax.swing.JOptionPane pane, int timeout)  
      protected void addAutoFocusSupport​(javax.swing.JDialog dialog, javax.swing.JOptionPane pane, javax.swing.JComponent component)  
      protected void addClipboardSupport​(javax.swing.JDialog dialog, javax.swing.JOptionPane pane, java.awt.datatransfer.Clipboard clipboard, java.lang.String text)  
      protected void appendStackTrace​(java.lang.StringBuilder b, java.lang.Throwable t)  
      protected void appendStackTraceAsCause​(java.lang.StringBuilder b, java.lang.Throwable t, java.lang.StackTraceElement[] originalStack)  
      protected void appendStackTraceElement​(java.lang.StringBuilder b, java.lang.StackTraceElement e)  
      protected void appendThrowable​(java.lang.StringBuilder b, java.lang.Throwable t, boolean isCause)  
      boolean askConfirmation​(java.awt.Component component, java.lang.String text)
      Displays confirmation message box containing desired message, and asking from the user to answer {code Yes} or No.
      protected boolean askConfirmation​(java.awt.Component component, java.lang.String text, int timeout)  
      java.lang.Boolean askConfirmationWithCancel​(java.awt.Component component, java.lang.String text)
      Displays confirmation message box containing desired message, and asking from the user to answer Yes, No or Cancel.
      protected java.lang.Boolean askConfirmationWithCancel​(java.awt.Component component, java.lang.String text, int timeout)  
      LoginData askLogin​(java.awt.Component component, java.lang.String text)
      Displays login dialog box containing desired message, and asking for user name and password.
      protected LoginData askLogin​(java.awt.Component component, java.lang.String text, int timeout)  
      LoginData askLogin​(java.awt.Component component, java.lang.String text, java.lang.String username)
      Displays login dialog box containing desired message, and asking for user name and password.
      protected LoginData askLogin​(java.awt.Component component, java.lang.String text, java.lang.String username, int timeout)  
      char[] askPassword​(java.awt.Component component, java.lang.String text)
      Displays password dialog box containing desired message, and asking from the user to enter password.
      protected char[] askPassword​(java.awt.Component component, java.lang.String text, int timeout)  
      java.lang.String askQuestion​(java.awt.Component component, java.lang.String text)
      Displays question message box containing desired question, and asking the user to enter the answer.
      java.lang.String askQuestion​(java.awt.Component component, java.lang.String text, int timeout)  
      java.lang.Object askQuestion​(java.awt.Component component, java.lang.String text, java.lang.Object[] options, java.lang.Object defaultOption)
      Displays question message box containing desired question, and asking the user to choose one of the provided options.
      protected java.lang.Object askQuestion​(java.awt.Component component, java.lang.String text, java.lang.Object[] options, java.lang.Object defaultOption, int timeout)  
      java.lang.String askQuestion​(java.awt.Component component, java.lang.String text, java.lang.String answer)
      Displays question message box containing desired question, and asking the user to enter the answer.
      protected java.lang.String askQuestion​(java.awt.Component component, java.lang.String text, java.lang.String answer, int timeout)  
      protected java.lang.String constructStackTrace​(java.lang.Throwable t)  
      protected static java.lang.String copyStringFromClipboard​(java.awt.datatransfer.Clipboard clipboard)  
      protected static void copyStringToClipboard​(java.awt.datatransfer.Clipboard clipboard, java.lang.String text)  
      protected javax.swing.JDialog createDialog​(java.awt.Component component, javax.swing.JOptionPane pane, java.lang.String title, int timeout)  
      protected javax.swing.JDialog createDialog​(java.awt.Component component, javax.swing.JOptionPane pane, java.lang.String title, java.lang.String text, int timeout)  
      protected javax.swing.JDialog createDialog​(java.awt.Component component, javax.swing.JOptionPane pane, java.lang.String title, javax.swing.JComponent focus, int timeout)  
      protected javax.swing.JDialog createDialog​(java.awt.Component component, javax.swing.JOptionPane pane, java.lang.String title, javax.swing.JComponent focus, java.lang.String text, int timeout)  
      protected void destroyDialog​(javax.swing.JDialog dialog, javax.swing.JOptionPane pane)  
      protected java.awt.datatransfer.Clipboard getClipboard()  
      javax.swing.Icon getIcon​(java.lang.String type)
      Returns a dialog icon of the desired type.
      protected java.util.Locale getLocale()  
      protected void setClipboard​(java.awt.datatransfer.Clipboard newValue)  
      protected void setLocale​(java.util.Locale newValue)  
      boolean showDialog​(java.awt.Component component, java.awt.Component content, java.lang.String title, javax.swing.Icon icon)
      Displays a dialog with the given icon and title containing the supplied component.
      protected boolean showDialog​(java.awt.Component component, java.awt.Component content, java.lang.String title, javax.swing.Icon icon, int timeout)  
      <T> T showDialog​(java.awt.Component component, DialogContent<T> content, java.lang.String title, javax.swing.Icon icon)
      Displays a dialog with the given icon and title containing the supplied content.
      protected <T> T showDialog​(java.awt.Component component, DialogContent<T> content, java.lang.String title, javax.swing.Icon icon, int timeout)  
      void showError​(java.awt.Component component, java.lang.String text)
      Displays error message box containing desired message.
      protected void showError​(java.awt.Component component, java.lang.String text, int timeout)  
      void showError​(java.awt.Component component, java.lang.String text, java.lang.Throwable th)
      Displays error message box containing desired message and optionally stack-trace of the supplied exception.
      protected void showError​(java.awt.Component component, java.lang.String text, java.lang.Throwable th, int timeout)  
      void showException​(java.awt.Component component, java.lang.Throwable th)
      Displays error message box containing stack-trace of the supplied exception.
      protected void showException​(java.awt.Component component, java.lang.Throwable th, int timeout)  
      void showInformation​(java.awt.Component component, java.lang.String text)
      Displays informational message box containing desired message.
      protected void showInformation​(java.awt.Component component, java.lang.String text, int timeout)  
      void showMessage​(java.awt.Component component, java.lang.String text)
      Displays message box containing desired message.
      protected void showMessage​(java.awt.Component component, java.lang.String text, int timeout)  
      void showWarning​(java.awt.Component component, java.lang.String text)
      Displays warning message box containing desired message.
      protected void showWarning​(java.awt.Component component, java.lang.String text, int timeout)  
      • Methods inherited from class java.lang.Object

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

      • locale

        protected java.util.Locale locale
      • clipboard

        protected java.awt.datatransfer.Clipboard clipboard
      • defaultAutoCloseTimeout

        protected int defaultAutoCloseTimeout
      • bundle

        protected java.util.ResourceBundle bundle
      • okOptions

        protected java.lang.String[] okOptions
      • yesNoOptions

        protected java.lang.String[] yesNoOptions
      • yesNoCancelOptions

        protected java.lang.String[] yesNoCancelOptions
      • okCancelOptions

        protected java.lang.String[] okCancelOptions
      • loginExitOptions

        protected java.lang.String[] loginExitOptions
      • okWithDetailsOptions

        protected java.lang.String[] okWithDetailsOptions
      • messageIcon

        protected javax.swing.Icon messageIcon
      • informationIcon

        protected javax.swing.Icon informationIcon
      • warningIcon

        protected javax.swing.Icon warningIcon
      • errorIcon

        protected javax.swing.Icon errorIcon
      • confirmationIcon

        protected javax.swing.Icon confirmationIcon
      • questionIcon

        protected javax.swing.Icon questionIcon
      • passwordIcon

        protected javax.swing.Icon passwordIcon
      • loginIcon

        protected javax.swing.Icon loginIcon
      • exceptionIcon

        protected javax.swing.Icon exceptionIcon
      • timeoutIcon

        protected javax.swing.Icon timeoutIcon
      • findIcon

        protected javax.swing.Icon findIcon
      • replaceIcon

        protected javax.swing.Icon replaceIcon
      • fontIcon

        protected javax.swing.Icon fontIcon
      • colorIcon

        protected javax.swing.Icon colorIcon
      • folderIcon

        protected javax.swing.Icon folderIcon
      • fileIcon

        protected javax.swing.Icon fileIcon
      • dateIcon

        protected javax.swing.Icon dateIcon
      • timeIcon

        protected javax.swing.Icon timeIcon
      • logoIcon

        protected javax.swing.Icon logoIcon
      • newStackTraceStyle

        protected boolean newStackTraceStyle
    • Constructor Detail

      • AbstractDialogFactory

        protected AbstractDialogFactory​(java.util.Locale locale,
                                        java.awt.datatransfer.Clipboard clipboard)
    • Method Detail

      • getClipboard

        protected java.awt.datatransfer.Clipboard getClipboard()
      • setClipboard

        protected void setClipboard​(java.awt.datatransfer.Clipboard newValue)
      • getLocale

        protected java.util.Locale getLocale()
      • setLocale

        protected void setLocale​(java.util.Locale newValue)
      • showMessage

        public void showMessage​(java.awt.Component component,
                                java.lang.String text)
        Description copied from interface: DialogFactory
        Displays message box containing desired message.
        Specified by:
        showMessage in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
      • showMessage

        protected void showMessage​(java.awt.Component component,
                                   java.lang.String text,
                                   int timeout)
      • showInformation

        public void showInformation​(java.awt.Component component,
                                    java.lang.String text)
        Description copied from interface: DialogFactory
        Displays informational message box containing desired message.
        Specified by:
        showInformation in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
      • showInformation

        protected void showInformation​(java.awt.Component component,
                                       java.lang.String text,
                                       int timeout)
      • showWarning

        public void showWarning​(java.awt.Component component,
                                java.lang.String text)
        Description copied from interface: DialogFactory
        Displays warning message box containing desired message.
        Specified by:
        showWarning in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
      • showWarning

        protected void showWarning​(java.awt.Component component,
                                   java.lang.String text,
                                   int timeout)
      • showError

        public void showError​(java.awt.Component component,
                              java.lang.String text)
        Description copied from interface: DialogFactory
        Displays error message box containing desired message.
        Specified by:
        showError in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
      • showError

        protected void showError​(java.awt.Component component,
                                 java.lang.String text,
                                 int timeout)
      • showError

        public void showError​(java.awt.Component component,
                              java.lang.String text,
                              java.lang.Throwable th)
        Description copied from interface: DialogFactory
        Displays error message box containing desired message and optionally stack-trace of the supplied exception.
        Specified by:
        showError in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
        th - exception which is used to build up the stack-trace information.
      • showError

        protected void showError​(java.awt.Component component,
                                 java.lang.String text,
                                 java.lang.Throwable th,
                                 int timeout)
      • showException

        public void showException​(java.awt.Component component,
                                  java.lang.Throwable th)
        Description copied from interface: DialogFactory
        Displays error message box containing stack-trace of the supplied exception.
        Specified by:
        showException in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        th - exception which is used to build up the stack-trace information.
      • showException

        protected void showException​(java.awt.Component component,
                                     java.lang.Throwable th,
                                     int timeout)
      • askConfirmation

        public boolean askConfirmation​(java.awt.Component component,
                                       java.lang.String text)
        Description copied from interface: DialogFactory
        Displays confirmation message box containing desired message, and asking from the user to answer {code Yes} or No.
        Specified by:
        askConfirmation in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
        Returns:
        true if user answered yes; false otherwise.
      • askConfirmation

        protected boolean askConfirmation​(java.awt.Component component,
                                          java.lang.String text,
                                          int timeout)
      • askConfirmationWithCancel

        public java.lang.Boolean askConfirmationWithCancel​(java.awt.Component component,
                                                           java.lang.String text)
        Description copied from interface: DialogFactory
        Displays confirmation message box containing desired message, and asking from the user to answer Yes, No or Cancel.
        Specified by:
        askConfirmationWithCancel in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
        Returns:
        true if user answered yes; false if user answered no; and null otherwise.
      • askConfirmationWithCancel

        protected java.lang.Boolean askConfirmationWithCancel​(java.awt.Component component,
                                                              java.lang.String text,
                                                              int timeout)
      • askQuestion

        public java.lang.String askQuestion​(java.awt.Component component,
                                            java.lang.String text)
        Description copied from interface: DialogFactory
        Displays question message box containing desired question, and asking the user to enter the answer.
        Specified by:
        askQuestion in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
        Returns:
        String containing text that user entered; null if user has chosen not to answer.
      • askQuestion

        public java.lang.String askQuestion​(java.awt.Component component,
                                            java.lang.String text,
                                            int timeout)
      • askQuestion

        public java.lang.String askQuestion​(java.awt.Component component,
                                            java.lang.String text,
                                            java.lang.String answer)
        Description copied from interface: DialogFactory
        Displays question message box containing desired question, and asking the user to enter the answer.
        Specified by:
        askQuestion in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
        answer - the initial answer for user to modify.
        Returns:
        String containing text that user entered; null if user has chosen not to answer.
      • askQuestion

        protected java.lang.String askQuestion​(java.awt.Component component,
                                               java.lang.String text,
                                               java.lang.String answer,
                                               int timeout)
      • askQuestion

        public java.lang.Object askQuestion​(java.awt.Component component,
                                            java.lang.String text,
                                            java.lang.Object[] options,
                                            java.lang.Object defaultOption)
        Description copied from interface: DialogFactory
        Displays question message box containing desired question, and asking the user to choose one of the provided options.
        Specified by:
        askQuestion in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the message box.
        options - list of available options for the user to choose from.
        defaultOption - initial option that is to be selected.
        Returns:
        one of the options provided or null if user has chosen not to answer.
      • askQuestion

        protected java.lang.Object askQuestion​(java.awt.Component component,
                                               java.lang.String text,
                                               java.lang.Object[] options,
                                               java.lang.Object defaultOption,
                                               int timeout)
      • askPassword

        public char[] askPassword​(java.awt.Component component,
                                  java.lang.String text)
        Description copied from interface: DialogFactory
        Displays password dialog box containing desired message, and asking from the user to enter password.
        Specified by:
        askPassword in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the dialog box.
        Returns:
        password entered by the user as an array of char; null if user has chosen not to enter the password.
      • askPassword

        protected char[] askPassword​(java.awt.Component component,
                                     java.lang.String text,
                                     int timeout)
      • askLogin

        public LoginData askLogin​(java.awt.Component component,
                                  java.lang.String text)
        Description copied from interface: DialogFactory
        Displays login dialog box containing desired message, and asking for user name and password.
        Specified by:
        askLogin in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the dialog box.
        Returns:
        user data (user name and password) stored in LoginData object; null if user has chosen not to enter login data.
      • askLogin

        protected LoginData askLogin​(java.awt.Component component,
                                     java.lang.String text,
                                     int timeout)
      • askLogin

        public LoginData askLogin​(java.awt.Component component,
                                  java.lang.String text,
                                  java.lang.String username)
        Description copied from interface: DialogFactory
        Displays login dialog box containing desired message, and asking for user name and password.
        Specified by:
        askLogin in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        text - text which will be displayed in the dialog box.
        username - default user name.
        Returns:
        user data (user name and password) stored in LoginData object; null if user has chosen not to enter login information.
      • askLogin

        protected LoginData askLogin​(java.awt.Component component,
                                     java.lang.String text,
                                     java.lang.String username,
                                     int timeout)
      • showDialog

        public boolean showDialog​(java.awt.Component component,
                                  java.awt.Component content,
                                  java.lang.String title,
                                  javax.swing.Icon icon)
        Description copied from interface: DialogFactory
        Displays a dialog with the given icon and title containing the supplied component.
        Specified by:
        showDialog in interface DialogFactory
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        content - the component to display on the dialog
        title - title of the dialog
        icon - icon to display on the dialog
        Returns:
        true if user answered ok; false otherwise.
      • showDialog

        protected boolean showDialog​(java.awt.Component component,
                                     java.awt.Component content,
                                     java.lang.String title,
                                     javax.swing.Icon icon,
                                     int timeout)
      • showDialog

        public <T> T showDialog​(java.awt.Component component,
                                DialogContent<T> content,
                                java.lang.String title,
                                javax.swing.Icon icon)
        Description copied from interface: DialogFactory
        Displays a dialog with the given icon and title containing the supplied content.
        Specified by:
        showDialog in interface DialogFactory
        Type Parameters:
        T - type of dialog content
        Parameters:
        component - determines the frame in which the dialog is displayed; if the parentComponent has no Frame, a default Frame is used.
        content - the component to display on the dialog
        title - title of the dialog
        icon - icon to display on the dialog
        Returns:
        The object retrieved from the content component if user answered ok; null otherwise.
      • showDialog

        protected <T> T showDialog​(java.awt.Component component,
                                   DialogContent<T> content,
                                   java.lang.String title,
                                   javax.swing.Icon icon,
                                   int timeout)
      • getIcon

        public javax.swing.Icon getIcon​(java.lang.String type)
        Description copied from interface: DialogFactory
        Returns a dialog icon of the desired type.
        Specified by:
        getIcon in interface DialogFactory
        Parameters:
        type - determines which icon to return: "question", "warning", "error", or other
        Returns:
        Returns a dialog icon of the given type.
      • createDialog

        protected javax.swing.JDialog createDialog​(java.awt.Component component,
                                                   javax.swing.JOptionPane pane,
                                                   java.lang.String title,
                                                   int timeout)
      • createDialog

        protected javax.swing.JDialog createDialog​(java.awt.Component component,
                                                   javax.swing.JOptionPane pane,
                                                   java.lang.String title,
                                                   javax.swing.JComponent focus,
                                                   int timeout)
      • createDialog

        protected javax.swing.JDialog createDialog​(java.awt.Component component,
                                                   javax.swing.JOptionPane pane,
                                                   java.lang.String title,
                                                   java.lang.String text,
                                                   int timeout)
      • createDialog

        protected javax.swing.JDialog createDialog​(java.awt.Component component,
                                                   javax.swing.JOptionPane pane,
                                                   java.lang.String title,
                                                   javax.swing.JComponent focus,
                                                   java.lang.String text,
                                                   int timeout)
      • destroyDialog

        protected void destroyDialog​(javax.swing.JDialog dialog,
                                     javax.swing.JOptionPane pane)
      • addAutoFocusSupport

        protected void addAutoFocusSupport​(javax.swing.JDialog dialog,
                                           javax.swing.JOptionPane pane,
                                           javax.swing.JComponent component)
      • addClipboardSupport

        protected void addClipboardSupport​(javax.swing.JDialog dialog,
                                           javax.swing.JOptionPane pane,
                                           java.awt.datatransfer.Clipboard clipboard,
                                           java.lang.String text)
      • addAutoCloseSupport

        protected void addAutoCloseSupport​(javax.swing.JDialog dialog,
                                           javax.swing.JOptionPane pane,
                                           int timeout)
      • constructStackTrace

        protected java.lang.String constructStackTrace​(java.lang.Throwable t)
      • appendStackTrace

        protected void appendStackTrace​(java.lang.StringBuilder b,
                                        java.lang.Throwable t)
      • appendStackTraceAsCause

        protected void appendStackTraceAsCause​(java.lang.StringBuilder b,
                                               java.lang.Throwable t,
                                               java.lang.StackTraceElement[] originalStack)
      • appendThrowable

        protected void appendThrowable​(java.lang.StringBuilder b,
                                       java.lang.Throwable t,
                                       boolean isCause)
      • appendStackTraceElement

        protected void appendStackTraceElement​(java.lang.StringBuilder b,
                                               java.lang.StackTraceElement e)
      • copyStringToClipboard

        protected static void copyStringToClipboard​(java.awt.datatransfer.Clipboard clipboard,
                                                    java.lang.String text)
      • copyStringFromClipboard

        protected static java.lang.String copyStringFromClipboard​(java.awt.datatransfer.Clipboard clipboard)