Class ProgressDialog

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class ProgressDialog
    extends javax.swing.JDialog
    Provides a configurable progress dialog. Note that you do not create an instance of it directly. Instead use the static method forBlock(ProgressDialogBlockInterface) to get an instance which will exist for the duration of the provided callback.
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JDialog

        javax.swing.JDialog.AccessibleJDialog
      • Nested classes/interfaces inherited from class java.awt.Dialog

        java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      • Fields inherited from class javax.swing.JDialog

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Dialog

        DEFAULT_MODALITY_TYPE
      • Fields inherited from class java.awt.Component

        BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
      • Fields inherited from interface javax.swing.WindowConstants

        DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean abortWasRequested()
      Used to determine if the user requested to abort.
      void addReport​(ReportDataModel reportDataModel)
      Adds a section to the bottom of the dialog as a Report.
      void clearLog()
      Clears the log text area of all message.
      protected void confirmAbort()  
      void embiggen​(int margin)
      Enlarges the progress dialog to match the screen size less some margin on all sides.
      static void forBlock​(ProgressDialogBlockInterface block)
      Displays a progress dialog for the duration of called method.
      boolean getAbortButtonVisible()
      Gets whether the abort button is currently visible.
      boolean getLogAllStatusUpdates()
      Gets a value indicating whether all status message updates will be logged.
      java.lang.String getLogText()
      Gets the current text in the log text area.
      boolean getTimestampLoggedMessages()
      Sets the value determining whether messages logged will lead with a time stamp.
      void incrememntSubProgress()
      Increases the current value of the sub progress bar by 1.
      void incrementMainProgress()
      Increases the current value of the main progress bar by 1.
      void logMessage​(java.lang.String message)
      Logs a message to the log text area.
      void onAbort​(java.lang.Runnable callback)
      Allows you to supply a callback which will be called when the user aborts by clicking and confirming the abort button or closing the dialog.
      void onMessageLogged​(ProgressDialogLoggingCallback callback)
      Allows you to provide a callback which will be called each time a message is logged to this progress dialog.
      void setAbortButtonVisible​(boolean value)
      Sets whether the abort button should be visible.
      void setCompleted()
      This is a convenience method for setting the progress dialog into a "script completed" state.
      void setLogAllStatusUpdates​(boolean logAllStatusUpdates)
      Sets a value indicating whether all status message updates will be logged.
      void setLogVisible​(boolean value)
      Sets whether the log text area should be visible.
      void setMainProgress​(int value)
      Sets the current value for the main progress bar without changing the maximum value.
      void setMainProgress​(int value, int max)
      Sets the value and maximum value for the main progress bar.
      void setMainProgressVisible​(boolean value)
      Sets whether the main progress bar is visible.
      void setMainStatus​(java.lang.String status)
      Set the main status label text.
      void setMainStatusAndLogIt​(java.lang.String status)
      Set the main status label and writes it as a log message.
      void setReportDisplayVisible​(boolean value)
      Sets whether the report section is visible.
      void setSubProgress​(int value)
      Sets the current value for the sub progress bar without changing the maximum value.
      void setSubProgress​(int value, int max)
      Sets the value and maximum value for the sub progress bar.
      void setSubProgressVisible​(boolean value)
      Sets whether the sub progress bar is visible.
      void setSubStatus​(java.lang.String status)
      Set the sub status label text.
      void setSubStatusAndLogIt​(java.lang.String status)
      Set the sub status label and writes it as a log message.
      void setTextWrapping​(boolean wrapText)
      Sets whether text in the message area show be line/word wrapped.
      void setTimestampLoggedMessages​(boolean timestampLoggedMessages)
      Sets the value determining whether messages logged will lead with a time stamp.
      • Methods inherited from class javax.swing.JDialog

        addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Dialog

        addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBack
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • confirmAbort

        protected void confirmAbort()
      • abortWasRequested

        public boolean abortWasRequested()
        Used to determine if the user requested to abort.
        Returns:
        True if the user clicked abort and clicked yes on the confirmation dialog.
      • onAbort

        public void onAbort​(java.lang.Runnable callback)
        Allows you to supply a callback which will be called when the user aborts by clicking and confirming the abort button or closing the dialog.
        Parameters:
        callback - The callback to invoke on abort.
      • setMainStatus

        public void setMainStatus​(java.lang.String status)
        Set the main status label text.
        Parameters:
        status - The value set it to.
      • setMainStatusAndLogIt

        public void setMainStatusAndLogIt​(java.lang.String status)
        Set the main status label and writes it as a log message.
        Parameters:
        status - The value set it to.
      • setSubStatus

        public void setSubStatus​(java.lang.String status)
        Set the sub status label text.
        Parameters:
        status - The value to set it to.
      • setSubStatusAndLogIt

        public void setSubStatusAndLogIt​(java.lang.String status)
        Set the sub status label and writes it as a log message.
        Parameters:
        status - The value to set it to.
      • setMainProgress

        public void setMainProgress​(int value,
                                    int max)
        Sets the value and maximum value for the main progress bar.
        Parameters:
        value - The current value to set it to.
        max - The maximum value to set it to.
      • setMainProgress

        public void setMainProgress​(int value)
        Sets the current value for the main progress bar without changing the maximum value.
        Parameters:
        value - The current value to set it to.
      • incrementMainProgress

        public void incrementMainProgress()
        Increases the current value of the main progress bar by 1.
      • setMainProgressVisible

        public void setMainProgressVisible​(boolean value)
        Sets whether the main progress bar is visible.
        Parameters:
        value - True for visible, false for hidden.
      • setSubProgress

        public void setSubProgress​(int value,
                                   int max)
        Sets the value and maximum value for the sub progress bar.
        Parameters:
        value - The current value to set it to.
        max - The maximum value to set it to.
      • setSubProgress

        public void setSubProgress​(int value)
        Sets the current value for the sub progress bar without changing the maximum value.
        Parameters:
        value - The current value to set it to.
      • incrememntSubProgress

        public void incrememntSubProgress()
        Increases the current value of the sub progress bar by 1.
      • setSubProgressVisible

        public void setSubProgressVisible​(boolean value)
        Sets whether the sub progress bar is visible.
        Parameters:
        value - True for visible, false for hidden.
      • setAbortButtonVisible

        public void setAbortButtonVisible​(boolean value)
        Sets whether the abort button should be visible. Useful to hide the abort button if you do not plan on supporting responding to it.
        Parameters:
        value - True if you wish the button to be visible, false if you don't.
      • getAbortButtonVisible

        public boolean getAbortButtonVisible()
        Gets whether the abort button is currently visible.
        Returns:
        True if the button is currently visible.
      • setLogVisible

        public void setLogVisible​(boolean value)
        Sets whether the log text area should be visible. Useful if you will not be logging any messages while the progress dialog is up.
        Parameters:
        value - True to make the log text area visible, false to hide it.
      • logMessage

        public void logMessage​(java.lang.String message)
        Logs a message to the log text area.
        Parameters:
        message - The message to write. A newline is automatically appended.
      • setTextWrapping

        public void setTextWrapping​(boolean wrapText)
        Sets whether text in the message area show be line/word wrapped.
        Parameters:
        wrapText - True enables wrapping, false (default) disables it.
      • clearLog

        public void clearLog()
        Clears the log text area of all message.
      • getLogText

        public java.lang.String getLogText()
        Gets the current text in the log text area.
        Returns:
        The log text area's current contents.
      • getLogAllStatusUpdates

        public boolean getLogAllStatusUpdates()
        Gets a value indicating whether all status message updates will be logged.
        Returns:
        True if all status messages will be logged
      • setLogAllStatusUpdates

        public void setLogAllStatusUpdates​(boolean logAllStatusUpdates)
        Sets a value indicating whether all status message updates will be logged.
        Parameters:
        logAllStatusUpdates - True if all status messages should be logged
      • onMessageLogged

        public void onMessageLogged​(ProgressDialogLoggingCallback callback)
        Allows you to provide a callback which will be called each time a message is logged to this progress dialog. Useful if you wish messages logged to the progress dialog to additionally be recorded elsewhere.
        Parameters:
        callback - Callback interface object which will receive logged messages.
      • embiggen

        public void embiggen​(int margin)
        Enlarges the progress dialog to match the screen size less some margin on all sides.
        Parameters:
        margin - The amount in pixels of "margin" to consider when enlarging this progress dialog.
      • setCompleted

        public void setCompleted()
        This is a convenience method for setting the progress dialog into a "script completed" state. Main status is set to "Completed" and this is logged. Sub status if cleared. Main progress is set to 100%. Sub progress is set to 100%.
      • getTimestampLoggedMessages

        public boolean getTimestampLoggedMessages()
        Sets the value determining whether messages logged will lead with a time stamp.
        Returns:
        boolean True if you time stamps will be logged before each message.
      • setTimestampLoggedMessages

        public void setTimestampLoggedMessages​(boolean timestampLoggedMessages)
        Sets the value determining whether messages logged will lead with a time stamp.
        Parameters:
        timestampLoggedMessages - True if you want time stamps logged before each message.
      • addReport

        public void addReport​(ReportDataModel reportDataModel)
        Adds a section to the bottom of the dialog as a Report. Uses the provided ReportDataModel to make a ReportDisplayPanel which gets inserted under the log area and above the buttons. This method will ensure the report is visible. Use setReportDisplayVisible(boolean) with false to hide the panel once it is made visible.
        Parameters:
        reportDataModel - The data model to display at the bottom of the dialog. Must not be null.
      • setReportDisplayVisible

        public void setReportDisplayVisible​(boolean value)
        Sets whether the report section is visible. If the section is made visible with no ReportDataModel provided via the addReport(ReportDataModel) method, then the report will take no space and not be visible.
        Parameters:
        value - True for visible, false for hidden.