Class BackgroundTaskHelper

java.lang.Object
de.ipk_gatersleben.ag_nw.graffiti.services.task.BackgroundTaskHelper
All Implemented Interfaces:
HelperClass

public class BackgroundTaskHelper
extends Object
implements HelperClass
Used to easily let a long running task running in background, with the possibility to provide a feedback of the progress,
Author:
klukas
  • Constructor Details

    • BackgroundTaskHelper

      public BackgroundTaskHelper​(Runnable workTask, BackgroundTaskStatusProvider statusProvider, String title, String taskName, boolean autoClose, boolean showDialogIsTrue_ShowPanelIsFalse)
      Creates a new BackgroundTaskHelper object.
      Parameters:
      workTask - The task to be executed.
      statusProvider - The statusProvider, probably linked to or returned by the workTask object.
      title - The Title of the Dialog / Pane
      taskName - The Task Name
      autoClose - If set to true, the pane or dialog will automatically close after completion of the job (with a timeout value)
      showDialogIsTrue_ShowPanelIsFalse - If set to true, a Dialog window will be shown, if set to false, a pane will be shown in the GUI.
    • BackgroundTaskHelper

      public BackgroundTaskHelper​(Runnable workTask, BackgroundTaskStatusProvider statusProvider, String title, String taskName, boolean autoClose, boolean showDialogIsTrue_ShowPanelIsFalse, int intialShowDelayForStatusPanel)
  • Method Details

    • startWork

      public void startWork​(Object referenceObject)
      Opens a progress window and starts the workTask that was provided in the constructor. The statusProvider is used for retreiving the current status, which is then shown. The dialog contains a stop-button. The statusProvider should make sure that the workTask stops as soon as possible in case the pleaseStop method is called.
    • getRunThread

      public Thread getRunThread()
    • isTaskWithGivenReferenceRunning

      public static boolean isTaskWithGivenReferenceRunning​(Object referenceObject)
    • issueSimpleTask

      public static void issueSimpleTask​(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp)
    • issueSimpleTask

      public static void issueSimpleTask​(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp, int delayForPanel)
    • issueSimpleTaskInWindow

      public static void issueSimpleTaskInWindow​(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp)
    • issueSimpleTaskInWindow

      public static void issueSimpleTaskInWindow​(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp, boolean modal, boolean autoclose)
    • issueSimpleTask

      public static void issueSimpleTask​(String taskName, String progressText, Runnable backgroundTask1, Runnable finishSwingTask)
    • issueSimpleTask

      public static void issueSimpleTask​(String taskName, String progressText1, String progressText2, Runnable backgroundTask1, Runnable finishSwingTask)
    • issueSimpleTask

      public static void issueSimpleTask​(String taskName, String progressText1, String progressText2, Runnable backgroundTask1, Runnable finishSwingTask, boolean autoclose)
    • showMessage

      public static void showMessage​(String message1, String message2)
    • executeLaterOnSwingTask

      public static void executeLaterOnSwingTask​(int delay, Runnable runnable)
    • lockGetSemaphore

      public static Semaphore lockGetSemaphore​(Object device, int maxLoad)
      Parameters:
      device - If specified, the Semaphore is saved in a hashmap and may be release using the method lockRelease. If set to null, always a new semaphore is returned.
      maxLoad - Max semaphore load.
      Returns:
      The desired semaphore.
    • lockAquire

      public static void lockAquire​(Object device, int maxLoad)
    • lockRelease

      public static void lockRelease​(Object device)