Class Task

java.lang.Object
com.nomagic.task.SwingWorker<Object>
com.nomagic.task.Task

@OpenApi public abstract class Task extends com.nomagic.task.SwingWorker<Object>
Task for execution of some code on a separate thread.
  • Field Details

  • Constructor Details

    • Task

      public Task(String name)
  • Method Details

    • executeTaskOnSameThread

      public static void executeTaskOnSameThread(Task task) throws Exception
      Executes task on same thread. Updates progress status from same thread.
      Throws:
      Exception
    • setInterruptThreadOnCancel

      public void setInterruptThreadOnCancel(boolean interruptThreadOnCancel)
    • currentTaskStatus

      public static ProgressStatus currentTaskStatus()
      Returns currently active Task progress status
      Returns:
      currently active Task progress status or null if current thread is not executing a Task
    • setName

      public void setName(String name)
    • setException

      public void setException(@CheckForNull Throwable e)
    • getException

      public Throwable getException()
    • getName

      public String getName()
    • getStatus

      public ProgressStatus getStatus()
    • setStatus

      public void setStatus(ProgressStatus status)
    • isCompleted

      public boolean isCompleted()
    • isWorking

      public boolean isWorking()
    • isReady

      public boolean isReady()
    • isException

      public boolean isException()
    • isCanceled

      public boolean isCanceled()
    • setState

      public void setState(String state)
    • getState

      public String getState()
    • construct

      @CheckForNull public final Object construct()
      Description copied from class: com.nomagic.task.SwingWorker
      Compute the value to be returned by the get method.
      Specified by:
      construct in class com.nomagic.task.SwingWorker<Object>
      Returns:
      the result value
    • execute

      public abstract void execute() throws Exception
      Throws:
      Exception
    • interruptAndStop

      @Deprecated public final void interruptAndStop()
      Deprecated.
      See MDUML-57069 for deprecation
      Description copied from class: com.nomagic.task.SwingWorker
      A new method that interrupts ant stops the worker thread. Call this method to force the worker to stop what it's doing.
      Overrides:
      interruptAndStop in class com.nomagic.task.SwingWorker<Object>
    • doFinished

      public final void doFinished()
      Overrides:
      doFinished in class com.nomagic.task.SwingWorker<Object>
    • beforeFinished

      protected void beforeFinished()
      Method invoked on task's thread just before SwingWorker.finished() is called.
    • isFinished

      public boolean isFinished()
      Returns:
      true if task is completely finished (execute and finished methods are executed)
    • isCancelable

      public boolean isCancelable()
      Returns:
      Returns the cancelable.
    • setCancelable

      public void setCancelable(boolean cancelable)
      Parameters:
      cancelable - The cancelable to set.
    • interrupt

      public void interrupt()
      Sets state to CANCELED. Notifies all threads that are waiting on this object monitor.
      Overrides:
      interrupt in class com.nomagic.task.SwingWorker<Object>
    • isActiveTasks

      public static boolean isActiveTasks()
    • addPropertyChangedListener

      public void addPropertyChangedListener(PropertyChangeListener listener)
    • removePropertyChangedListener

      public void removePropertyChangedListener(PropertyChangeListener listener)
    • setFinished

      public void setFinished(boolean finished)
    • setDoFinishedExecuter

      public void setDoFinishedExecuter(com.nomagic.task.Task.DoFinishedExecuter doFinishedExecuter)
    • stopTask

      public void stopTask()
      Interrupt task and wait while it is working