Class Task

    • Constructor Summary

      Constructors 
      Constructor Description
      Task​(java.lang.String title)
      Creates new Task.
      Task​(java.lang.String title, boolean canCancel, boolean hasProgress, boolean isModal)
      Construct a new Task.
      Task​(java.lang.String title, boolean canCancel, boolean hasProgress, boolean isModal, boolean waitForTaskCompleted)
      Construct a new Task.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addTaskListener​(TaskListener listener)
      Sets the task listener on this task.
      boolean canCancel()
      Returns true if the task can be canceled.
      void cancel()  
      int getStatusTextAlignment()
      Returns the alignment of the text displayed in the modal dialog.
      java.lang.String getTaskTitle()
      Get the title associated with the task
      boolean hasProgress()
      Return true if the task has a progress indicator.
      boolean isModal()
      Returns true if the dialog associated with the task is modal.
      void monitoredRun​(TaskMonitor monitor)
      When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
      protected void notifyTaskListeners​(boolean wasCancelled)  
      abstract void run​(TaskMonitor monitor)
      This is the method that will be called to do the work
      void setHasProgress​(boolean b)
      Sets this task to have progress or not.
      • Methods inherited from class java.lang.Object

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

      • waitForTaskCompleted

        protected boolean waitForTaskCompleted
    • Constructor Detail

      • Task

        public Task​(java.lang.String title)
        Creates new Task.
        Parameters:
        title - the title associated with the task
      • Task

        public Task​(java.lang.String title,
                    boolean canCancel,
                    boolean hasProgress,
                    boolean isModal)
        Construct a new Task.
        Parameters:
        title - title the title associated with the task
        canCancel - true means that the user can cancel the task
        hasProgress - true means that the dialog should show a progress indicator
        isModal - true means that the dialog is modal and the task has to complete or be canceled before any other action can occur
      • Task

        public Task​(java.lang.String title,
                    boolean canCancel,
                    boolean hasProgress,
                    boolean isModal,
                    boolean waitForTaskCompleted)
        Construct a new Task.
        Parameters:
        title - title the title associated with the task
        canCancel - true means that the user can cancel the task
        hasProgress - true means that the dialog should show a progress indicator
        isModal - true means that the dialog is modal and the task has to complete or be canceled before any other action can occur
        waitForTaskCompleted - true causes the running thread to block until the finish or cancelled callback has completed on the swing thread. Note: passing true only makes sense if the task is modal.
    • Method Detail

      • getTaskTitle

        public final java.lang.String getTaskTitle()
        Get the title associated with the task
        Returns:
        String title shown in the dialog
      • getStatusTextAlignment

        public int getStatusTextAlignment()
        Returns the alignment of the text displayed in the modal dialog. The default is SwingConstants.CENTER. For status updates where the initial portion of the text does not change, SwingConstants.LEADING is recommended. To change the default value, simply override this method and return one of SwingConstants CENTER, LEADING or TRAILING.
        Returns:
        the alignment of the text displayed
      • monitoredRun

        public final void monitoredRun​(TaskMonitor monitor)
        When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
        Specified by:
        monitoredRun in interface MonitoredRunnable
        Parameters:
        monitor - the task monitor
      • cancel

        public void cancel()
      • notifyTaskListeners

        protected void notifyTaskListeners​(boolean wasCancelled)
      • hasProgress

        public boolean hasProgress()
        Return true if the task has a progress indicator.
        Returns:
        boolean true if the task shows progress
      • setHasProgress

        public void setHasProgress​(boolean b)
        Sets this task to have progress or not. Note: changing this value after launching the task will have no effect.
        Parameters:
        b - true to show progress, false otherwise.
      • canCancel

        public boolean canCancel()
        Returns true if the task can be canceled.
        Returns:
        boolean true if the user can cancel the task
      • isModal

        public boolean isModal()
        Returns true if the dialog associated with the task is modal.
        Returns:
        boolean true if the associated dialog is modal
      • addTaskListener

        public void addTaskListener​(TaskListener listener)
        Sets the task listener on this task. It is a programming error to call this method more than once or to call this method if a listener was passed into the constructor of this class.
        Parameters:
        listener - the listener