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 voidexecuteLaterOnSwingTask(int delay, Runnable runnable)ThreadgetRunThread()static voidissueSimpleTask(String taskName, String progressText, Runnable backgroundTask1, Runnable finishSwingTask)static voidissueSimpleTask(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp)static voidissueSimpleTask(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp, int delayForPanel)static voidissueSimpleTask(String taskName, String progressText1, String progressText2, Runnable backgroundTask1, Runnable finishSwingTask)static voidissueSimpleTask(String taskName, String progressText1, String progressText2, Runnable backgroundTask1, Runnable finishSwingTask, boolean autoclose)static voidissueSimpleTaskInWindow(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp)static voidissueSimpleTaskInWindow(String taskName, String progressText, Runnable backgroundTask, Runnable finishSwingTask, BackgroundTaskStatusProvider sp, boolean modal, boolean autoclose)static booleanisTaskWithGivenReferenceRunning(Object referenceObject)static voidlockAquire(Object device, int maxLoad)static SemaphorelockGetSemaphore(Object device, int maxLoad)static voidlockRelease(Object device)static voidshowMessage(String message1, String message2)voidstartWork(Object referenceObject)Opens a progress window and starts theworkTaskthat 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 theworkTaskthat was provided in the constructor. ThestatusProvideris used for retreiving the current status, which is then shown. The dialog contains a stop-button. ThestatusProvidershould make sure that theworkTaskstops as soon as possible in case thepleaseStopmethod 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
-