Class AbstractDialogFactory

java.lang.Object
org.svetovid.dialogs.AbstractDialogFactory
All Implemented Interfaces:
DialogFactory
Direct Known Subclasses:
DefaultDialogFactory

public abstract class AbstractDialogFactory extends 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:
  • Field Details

    • locale

      protected Locale locale
    • clipboard

      protected Clipboard clipboard
    • defaultAutoCloseTimeout

      protected int defaultAutoCloseTimeout
    • bundle

      protected ResourceBundle bundle
    • okOptions

      protected String[] okOptions
    • yesNoOptions

      protected String[] yesNoOptions
    • yesNoCancelOptions

      protected String[] yesNoCancelOptions
    • okCancelOptions

      protected String[] okCancelOptions
    • loginExitOptions

      protected String[] loginExitOptions
    • okWithDetailsOptions

      protected String[] okWithDetailsOptions
    • messageIcon

      protected Icon messageIcon
    • informationIcon

      protected Icon informationIcon
    • warningIcon

      protected Icon warningIcon
    • errorIcon

      protected Icon errorIcon
    • confirmationIcon

      protected Icon confirmationIcon
    • questionIcon

      protected Icon questionIcon
    • passwordIcon

      protected Icon passwordIcon
    • loginIcon

      protected Icon loginIcon
    • exceptionIcon

      protected Icon exceptionIcon
    • timeoutIcon

      protected Icon timeoutIcon
    • findIcon

      protected Icon findIcon
    • replaceIcon

      protected Icon replaceIcon
    • fontIcon

      protected Icon fontIcon
    • colorIcon

      protected Icon colorIcon
    • folderIcon

      protected Icon folderIcon
    • fileIcon

      protected Icon fileIcon
    • dateIcon

      protected Icon dateIcon
    • timeIcon

      protected Icon timeIcon
    • logoIcon

      protected Icon logoIcon
    • newStackTraceStyle

      protected boolean newStackTraceStyle
  • Constructor Details

    • AbstractDialogFactory

      protected AbstractDialogFactory(Locale locale, Clipboard clipboard)
  • Method Details

    • getClipboard

      protected Clipboard getClipboard()
    • setClipboard

      protected void setClipboard(Clipboard newValue)
    • getLocale

      protected Locale getLocale()
    • setLocale

      protected void setLocale(Locale newValue)
    • showMessage

      public void showMessage(Component component, 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(Component component, String text, int timeout)
    • showInformation

      public void showInformation(Component component, 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(Component component, String text, int timeout)
    • showWarning

      public void showWarning(Component component, 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(Component component, String text, int timeout)
    • showError

      public void showError(Component component, 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(Component component, String text, int timeout)
    • showError

      public void showError(Component component, String text, 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(Component component, String text, Throwable th, int timeout)
    • showException

      public void showException(Component component, 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(Component component, Throwable th, int timeout)
    • askConfirmation

      public boolean askConfirmation(Component component, 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(Component component, String text, int timeout)
    • askConfirmationWithCancel

      public Boolean askConfirmationWithCancel(Component component, 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 Boolean askConfirmationWithCancel(Component component, String text, int timeout)
    • askQuestion

      public String askQuestion(Component component, 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 String askQuestion(Component component, String text, int timeout)
    • askQuestion

      public String askQuestion(Component component, String text, 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 String askQuestion(Component component, String text, String answer, int timeout)
    • askQuestion

      public Object askQuestion(Component component, String text, Object[] options, 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 Object askQuestion(Component component, String text, Object[] options, Object defaultOption, int timeout)
    • askPassword

      public char[] askPassword(Component component, 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(Component component, String text, int timeout)
    • askLogin

      public LoginData askLogin(Component component, 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(Component component, String text, int timeout)
    • askLogin

      public LoginData askLogin(Component component, String text, 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(Component component, String text, String username, int timeout)
    • showDialog

      public boolean showDialog(Component component, Component content, String title, 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(Component component, Component content, String title, Icon icon, int timeout)
    • showDialog

      public <T> T showDialog(Component component, DialogContent<T> content, String title, 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(Component component, DialogContent<T> content, String title, Icon icon, int timeout)
    • getIcon

      public Icon getIcon(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 JDialog createDialog(Component component, JOptionPane pane, String title, int timeout)
    • createDialog

      protected JDialog createDialog(Component component, JOptionPane pane, String title, JComponent focus, int timeout)
    • createDialog

      protected JDialog createDialog(Component component, JOptionPane pane, String title, String text, int timeout)
    • createDialog

      protected JDialog createDialog(Component component, JOptionPane pane, String title, JComponent focus, String text, int timeout)
    • destroyDialog

      protected void destroyDialog(JDialog dialog, JOptionPane pane)
    • addAutoFocusSupport

      protected void addAutoFocusSupport(JDialog dialog, JOptionPane pane, JComponent component)
    • addClipboardSupport

      protected void addClipboardSupport(JDialog dialog, JOptionPane pane, Clipboard clipboard, String text)
    • addAutoCloseSupport

      protected void addAutoCloseSupport(JDialog dialog, JOptionPane pane, int timeout)
    • constructStackTrace

      protected String constructStackTrace(Throwable t)
    • appendStackTrace

      protected void appendStackTrace(StringBuilder b, Throwable t)
    • appendStackTraceAsCause

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

      protected void appendThrowable(StringBuilder b, Throwable t, boolean isCause)
    • appendStackTraceElement

      protected void appendStackTraceElement(StringBuilder b, StackTraceElement e)
    • copyStringToClipboard

      protected static void copyStringToClipboard(Clipboard clipboard, String text)
    • copyStringFromClipboard

      protected static String copyStringFromClipboard(Clipboard clipboard)