Class Task

    • Field Detail

      • STATE_CHANGED_PROPERTY

        public static final java.lang.String STATE_CHANGED_PROPERTY
        See Also:
        Constant Field Values
      • mCurrentRunningCount

        private static final java.util.concurrent.atomic.AtomicInteger mCurrentRunningCount
      • currentTaskStatus

        private static final java.lang.ThreadLocal<ProgressStatus> currentTaskStatus
      • mState

        private java.lang.String mState
      • mExceptions

        private final java.lang.Throwable[] mExceptions
      • mCancelable

        private boolean mCancelable
      • mFinished

        private volatile boolean mFinished
      • mInterruptThreadOnCancel

        private boolean mInterruptThreadOnCancel
      • mDoFinishedExecuter

        private com.nomagic.task.Task.DoFinishedExecuter mDoFinishedExecuter
      • mStateChangeSupport

        private java.beans.PropertyChangeSupport mStateChangeSupport
        Register listeners to report task change
    • Constructor Detail

      • Task

        public Task​(java.lang.String name)
    • Method Detail

      • 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​(java.lang.String name)
      • setException

        public void setException​(@CheckForNull
                                 java.lang.Throwable e)
      • getException

        public java.lang.Throwable getException()
      • getName

        public java.lang.String getName()
      • isCompleted

        public boolean isCompleted()
      • isWorking

        public boolean isWorking()
      • isReady

        public boolean isReady()
      • isException

        public boolean isException()
      • isCanceled

        public boolean isCanceled()
      • unregisterTask

        private static void unregisterTask()
      • setState

        public void setState​(java.lang.String state)
      • firePropertyChange

        private void firePropertyChange​(java.lang.String name,
                                        java.lang.Object oldValue,
                                        java.lang.Object newValue)
        Fires property change event by given parameters
        Parameters:
        name - property name
        oldValue - old property value
        newValue - new property value
      • getState

        public java.lang.String getState()
      • construct

        @CheckForNull
        public final java.lang.Object construct()
        Specified by:
        construct in class com.nomagic.task.SwingWorker<java.lang.Object>
      • registerTask

        private static void registerTask()
      • execute

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

        @Deprecated
        public final void interruptAndStop()
        Deprecated.
        See MDUML-57069 for deprecation
        Overrides:
        interruptAndStop in class com.nomagic.task.SwingWorker<java.lang.Object>
      • doFinished

        public final void doFinished()
        Overrides:
        doFinished in class com.nomagic.task.SwingWorker<java.lang.Object>
      • 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<java.lang.Object>
      • isActiveTasks

        public static boolean isActiveTasks()
      • addPropertyChangedListener

        public void addPropertyChangedListener​(java.beans.PropertyChangeListener listener)
      • removePropertyChangedListener

        public void removePropertyChangedListener​(java.beans.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