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 Summary
Constructors Constructor Description BackgroundTaskHelper(Runnable workTask, BackgroundTaskStatusProvider statusProvider, String title, String taskName, boolean autoClose, boolean showDialogIsTrue_ShowPanelIsFalse)
Creates a new BackgroundTaskHelper object.BackgroundTaskHelper(Runnable workTask, BackgroundTaskStatusProvider statusProvider, String title, String taskName, boolean autoClose, boolean showDialogIsTrue_ShowPanelIsFalse, int intialShowDelayForStatusPanel)
-
Method Summary
Modifier and Type Method Description static void
executeLaterOnSwingTask(int delay, Runnable runnable)
Thread
getRunThread()
static void
issueSimpleTask(String taskName, String progressText, Runnable backgroundTask1, Runnable finishSwingTask)
static void
issueSimpleTask(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp)
static void
issueSimpleTask(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp, int delayForPanel)
static void
issueSimpleTask(String taskName, String progressText1, String progressText2, Runnable backgroundTask1, Runnable finishSwingTask)
static void
issueSimpleTask(String taskName, String progressText1, String progressText2, Runnable backgroundTask1, Runnable finishSwingTask, boolean autoclose)
static void
issueSimpleTaskInWindow(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp)
static void
issueSimpleTaskInWindow(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp, boolean modal, boolean autoclose)
static boolean
isTaskWithGivenReferenceRunning(Object referenceObject)
static void
lockAquire(Object device, int maxLoad)
static Semaphore
lockGetSemaphore(Object device, int maxLoad)
static void
lockRelease(Object device)
static void
showMessage(String message1, String message2)
void
startWork(Object referenceObject)
Opens a progress window and starts theworkTask
that was provided in the constructor.
-
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 / PanetaskName
- The Task NameautoClose
- 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
Opens a progress window and starts theworkTask
that was provided in the constructor. ThestatusProvider
is used for retreiving the current status, which is then shown. The dialog contains a stop-button. ThestatusProvider
should make sure that theworkTask
stops as soon as possible in case thepleaseStop
method is called. -
getRunThread
-
isTaskWithGivenReferenceRunning
-
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
-
issueSimpleTask
-
issueSimpleTask
-
showMessage
-
executeLaterOnSwingTask
-
lockGetSemaphore
- 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
-
lockRelease
-