Class ProgressFrame

  • All Implemented Interfaces:
    jebl.util.Cancelable

    public final class ProgressFrame
    extends jebl.util.ProgressListener
    An implementation of ProgressListener which displays progress using a progress bar and a cancel button in a Frame.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class jebl.util.ProgressListener

        jebl.util.ProgressListener.Wrapper
    • Field Summary

      • Fields inherited from class jebl.util.ProgressListener

        EMPTY
    • Constructor Summary

      Constructors 
      Constructor Description
      ProgressFrame​(java.lang.String title, java.lang.String message)
      Creates a progress frame manager to display the progress of a potentially time-consuming operation.
      ProgressFrame​(java.lang.String title, java.lang.String message, long delay, boolean startDelayImmediately)
      Deprecated.
      ProgressFrame​(java.lang.String title, java.lang.String message, long delay, boolean startDelayImmediately, java.awt.Window parentWindowToDisable)
      ProgressFrame​(java.lang.String title, java.lang.String message, java.awt.Window parentWindowToDisable)
      Creates a progress frame manager to display the progress of a potentially time-consuming operation.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void _addInfo​(java.lang.String message)  
      void _addWarning​(java.lang.String message)  
      protected void _setImage​(java.awt.Image image)  
      protected void _setIndeterminateProgress()  
      protected void _setMessage​(java.lang.String message)  
      protected void _setProgress​(double fractionCompleted)  
      void addFeedbackAction​(java.lang.String label, java.lang.String description, org.virion.jam.util.SimpleListener listener)  
      void addFeedbackAction​(java.lang.String label, org.virion.jam.util.SimpleListener listener)  
      void addProgressListener​(jebl.util.ProgressListener progressListener)
      Adds a listener to be notified about all progress messages (i.e all methods in ProgressListener) that this ProgressFrame receives.
      void cancel()
      Cancels this progress frame.
      java.awt.Frame getFrame()
      Deprecated.
      java.awt.Window getWindow()
      Get the window which is used to display progress.
      boolean isCanceled()  
      void removeFeedbackAction​(java.lang.String label)  
      void removeProgressListener​(jebl.util.ProgressListener progressListener)
      void setAutoMinimize​(int delayInMilliseconds)
      Deprecated.
      this isn't nice for the users.
      void setCancelable​(boolean isCancelable)
      Set whether this progress frame should be cancelable by the user.
      void setCancelButtonLabel​(java.lang.String label)
      Set the label for the "Cancel" button.
      void setComplete()
      Sets the progress to 100%, causing the frame to close if it is visible.
      void setIcons​(Icons icons)
      Set the icons for the frame/task bar (displayed in the left corner of the title bar).
      void setTitle​(java.lang.String title)  
      • Methods inherited from class jebl.util.ProgressListener

        addInfo, addWarning, createSplitProgress, createSplitProgress, forCancelable, getSplitProgress, setImage, setIndeterminateProgress, setMessage, setMessageOrThrow, setProgress, setProgress, setProgress, setProgressOrThrow, setProgressOrThrow, throwExceptionIfCanceled
      • Methods inherited from class java.lang.Object

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

      • ProgressFrame

        public ProgressFrame​(java.lang.String title,
                             java.lang.String message)
        Creates a progress frame manager to display the progress of a potentially time-consuming operation. After returning from the constructor, the Swing frame will automatically be created and become visible after a small delay (under a second) has elapsed. If ProgressListener.setProgress(double) isn't called before this delay has elapsed the progress frame will show with indeterminate progress

        typical usage:

         ProgressFrame progress = new ProgressFrame("Title", "doing stuff");
         while(! cancelled) {
              //do some stuff
              if (progress.setProgress(fractionComplete)) {
                  cancelled = true;
              }
         }
         progress.setComplete ();
         
        Parameters:
        title - Title of the progress frame
        message - Initial message to display above the progress bar (replaced by any message set during progress of the operation)
        Since:
        API 4.61 (Geneious 5.6.1)
      • ProgressFrame

        public ProgressFrame​(java.lang.String title,
                             java.lang.String message,
                             java.awt.Window parentWindowToDisable)
        Creates a progress frame manager to display the progress of a potentially time-consuming operation. After returning from the constructor, the Swing frame will automatically be created and become visible after a small delay (under a second) has elapsed. If ProgressListener.setProgress(double) isn't called before this delay has elapsed the progress frame will show with indeterminate progress

        typical usage:

         ProgressFrame progress = new ProgressFrame("Title", "doing stuff");
         while(! cancelled) {
              //do some stuff
              if (progress.setProgress(fractionComplete)) {
                  cancelled = true;
              }
         }
         progress.setComplete ();
         
        Parameters:
        title - Title of the progress frame
        message - Initial message to display above the progress bar (replaced by any message set during progress of the operation)
        parentWindowToDisable - A window which is disabled immediately and remains disabled until the progress frame is complete.
        Since:
        API 4.61 (Geneious 5.6.1)
      • ProgressFrame

        @Deprecated
        public ProgressFrame​(java.lang.String title,
                             java.lang.String message,
                             long delay,
                             boolean startDelayImmediately)
        Deprecated.
        Creates a progress frame to display the progress of a potentially time-consuming operation. The progress frame will not become visible until the operation has taken at least delay milliseconds.

        typical usage:

         ProgressFrame progress = new ProgressFrame("pros", "doing stuff", 1000);
         while(! cancelled) {
              //do some stuff
              if (progress.setProgress(fractionComplete)) {
                  cancelled = true;
              }
         }
         progress.setComplete ();
         
        Parameters:
        title - Title of the progress frame
        message - Initial message to display above the progress bar (replaced by any message set during progress of the operation)
        delay - Delay in milliseconds before displaying the ProgressFrame.
        startDelayImmediately - if true, then the delay count starts immediately. If false, then the delay timer is started when the first setProgress or setMessage call is made.
      • ProgressFrame

        @Deprecated
        public ProgressFrame​(java.lang.String title,
                             java.lang.String message,
                             long delay,
                             boolean startDelayImmediately,
                             java.awt.Window parentWindowToDisable)
        Creates a progress frame to display the progress of a potentially time-consuming operation. The progress frame will not become visible until the operation has taken at least delay milliseconds.

        typical usage:

         ProgressFrame progress = new ProgressFrame("pros", "doing stuff", 1000);
         while(! cancelled) {
              //do some stuff
              if (progress.setProgress(fractionComplete)) {
                  cancelled = true;
              }
         }
         progress.setComplete ();
         
        Parameters:
        title - Title of the progress frame
        message - Initial message to display above the progress bar (replaced by any message set during progress of the operation)
        delay - Delay in milliseconds before displaying the ProgressFrame.
        startDelayImmediately - if true, then the delay count starts immediately. If false, then the delay timer is started when the first setProgress or setMessage call is made.
        parentWindowToDisable - A window which is disabled immediately and remains disabled until the progress frame is complete.
    • Method Detail

      • setTitle

        public void setTitle​(java.lang.String title)
        Overrides:
        setTitle in class jebl.util.ProgressListener
      • setIcons

        public void setIcons​(Icons icons)
        Set the icons for the frame/task bar (displayed in the left corner of the title bar). Must be called before the frame is made visible.

        This has no effect on Mac OS (because there is no frame icon).

        Parameters:
        icons - Icons to display
      • getFrame

        @Deprecated
        public java.awt.Frame getFrame()
        Deprecated.
        Get the frame which is used to display progress. This will only return a non-null value after the frame has become visible (normally after the delay period).
        Returns:
        the frame which is used to display progress. Will only return a non-null value after the frame has become visible (normally after the delay period).
      • getWindow

        public java.awt.Window getWindow()
        Get the window which is used to display progress. This will only return a non-null value after the frame has become visible (normally after the delay period).
        Returns:
        the window which is used to display progress. Will only return a non-null value after the frame has become visible (normally after the delay period).
      • cancel

        public void cancel()
        Cancels this progress frame. This is the same as clicking the cancel button. This is safe to call even after the progress has already been canceled or finished.
      • _setProgress

        protected void _setProgress​(double fractionCompleted)
        Specified by:
        _setProgress in class jebl.util.ProgressListener
        Parameters:
        fractionCompleted - a number between 0 and 1 inclusive representing the fraction of the operation completed.
      • _setIndeterminateProgress

        protected void _setIndeterminateProgress()
        Specified by:
        _setIndeterminateProgress in class jebl.util.ProgressListener
      • _setMessage

        protected void _setMessage​(java.lang.String message)
        Specified by:
        _setMessage in class jebl.util.ProgressListener
      • isCanceled

        public boolean isCanceled()
        Specified by:
        isCanceled in interface jebl.util.Cancelable
        Specified by:
        isCanceled in class jebl.util.ProgressListener
      • _addWarning

        public void _addWarning​(java.lang.String message)
        Overrides:
        _addWarning in class jebl.util.ProgressListener
      • _addInfo

        public void _addInfo​(java.lang.String message)
        Overrides:
        _addInfo in class jebl.util.ProgressListener
      • setComplete

        public void setComplete()
        Sets the progress to 100%, causing the frame to close if it is visible.
      • addProgressListener

        public void addProgressListener​(jebl.util.ProgressListener progressListener)
        Adds a listener to be notified about all progress messages (i.e all methods in ProgressListener) that this ProgressFrame receives.
        Parameters:
        progressListener - the progress listener to notify
        Since:
        API 4.14 (Geneious 5.1)
      • removeProgressListener

        public void removeProgressListener​(jebl.util.ProgressListener progressListener)
        Parameters:
        progressListener - the progress listener to notify
        Since:
        API 4.14 (Geneious 5.1)
      • _setImage

        protected void _setImage​(java.awt.Image image)
        Overrides:
        _setImage in class jebl.util.ProgressListener
      • addFeedbackAction

        public void addFeedbackAction​(java.lang.String label,
                                      org.virion.jam.util.SimpleListener listener)
        Overrides:
        addFeedbackAction in class jebl.util.ProgressListener
      • addFeedbackAction

        public void addFeedbackAction​(java.lang.String label,
                                      java.lang.String description,
                                      org.virion.jam.util.SimpleListener listener)
        Overrides:
        addFeedbackAction in class jebl.util.ProgressListener
      • removeFeedbackAction

        public void removeFeedbackAction​(java.lang.String label)
        Overrides:
        removeFeedbackAction in class jebl.util.ProgressListener
      • setAutoMinimize

        @Deprecated
        public void setAutoMinimize​(int delayInMilliseconds)
        Deprecated.
        this isn't nice for the users. Don't use it.
        After the specified delay has passed (since the frame became visible) the progress frame will automatically minimize. If the progress of the operation reaches a certain threshold (40% currently) before the auto-minimize delay has passed then the auto-minimize will be canceled. This is because the operation will probably finish shortly so the user would be better to wait. Useful when you want to run a lengthy operation in the background and make it clear to the user that they can continue working (eg. installing a plugin).
        Parameters:
        delayInMilliseconds - delay before minimized
      • setCancelButtonLabel

        public void setCancelButtonLabel​(java.lang.String label)
        Set the label for the "Cancel" button. Useful if canceling is not acutally possible and the button should have a lable like "Hide" in stead.
        Parameters:
        label - label for the cancel button
      • setCancelable

        public void setCancelable​(boolean isCancelable)
        Set whether this progress frame should be cancelable by the user. If not, the cancel button will be hidden and the frame will have no close button.
        Parameters:
        isCancelable - whether this progress frame should be cancelable by the user
        Since:
        API 4.611 (Geneious 6.1.1)