Class LongOperation

    • Constructor Detail

      • LongOperation

        public LongOperation()
      • LongOperation

        public LongOperation​(org.springframework.core.task.TaskExecutor taskExecutor)
    • Method Detail

      • onStart

        public LongOperation onStart​(tools.dynamia.commons.Callback onStart)
      • execute

        public LongOperation execute​(tools.dynamia.commons.Callback executeCallback)
        asynchronous callback for your long operation code
      • onFinish

        public LongOperation onFinish​(tools.dynamia.commons.Callback onFinishCallback)
        optional callback method when the task has completed successfully
      • onCancel

        public LongOperation onCancel​(tools.dynamia.commons.Callback onCancelCallback)
        optional callback method when the task has been cancelled or was interrupted otherwise
      • onException

        public LongOperation onException​(Consumer<Exception> onExceptionConsumer)
        optional callback method when the task has completed with an uncaught Excepion
        Parameters:
        onExceptionConsumer -
      • onCleanup

        public LongOperation onCleanup​(tools.dynamia.commons.Callback onCleanupCallback)
        optional callback method when the task has completed (always called)
      • cancel

        public final void cancel()
        set the cancelled flag and try to interrupt the thread
      • isCancelled

        public final boolean isCancelled()
        check the cancelled flag
        Returns:
      • deactivate

        protected final void deactivate()
        deactivate the current active (see: activate()) thread/desktop after updates are done
      • checkCancelled

        protected final void checkCancelled()
                                     throws InterruptedException
        Checks if the task thread has been interrupted. Use this to check whether or not to exit a busy operation in case.
        Throws:
        InterruptedException - when the current task has been cancelled/interrupted
      • start

        public final LongOperation start()
        launch the long operation
      • run

        public final void run()
        Specified by:
        run in interface Runnable
      • finish

        protected void finish()
      • execute

        protected void execute()
      • runCallback

        protected void runCallback​(tools.dynamia.commons.Callback callback)
      • updateUI

        public void updateUI​(tools.dynamia.commons.Callback callback)
      • create

        public static LongOperation create​(org.springframework.core.task.TaskExecutor taskExecutor)