public abstract class RefreshTask
extends java.lang.Object
Provides an empty implementation of
refresh(Context, ProgressHandle)
and refreshApplication(Context, ProgressHandle)
methods.
The following example shows the 5 seconds task which periodically check
for thread interruption. Thread can be interrupted either by user
cancellation (clicking the cross (x) button) or by invoking the new
refresh action. When implementing your refresh
method, test for
interruption Thread.interrupted()
as often as possible and if true,
finish your task.
public static class TimeVastingTask extends RefreshTaskAdapter { public String getDisplayName() { return "Time Vasting Task"; } public void run() { try { for (int i = 0; i < 10; i++) { Thread.sleep(500); if (Thread.interrupted()) { String time = Integer.toString(500 + i*500); System.out.println("Cancelled after " + time + " ms."); return; } } catch (InterruptedException e) { System.out.println(e); } } }
The class instance has to be registered in your extension.xml
:
<refresh-hook xmlns="http://xmlns.oracle.com/ide/extension"> <observer>yourpackage.TimeVastingTask</observer> </refresh-hook>
Thread
Constructor and Description |
---|
RefreshTask() |
Modifier and Type | Method and Description |
---|---|
abstract java.lang.String |
getDisplayName() |
void |
refresh(Context context,
org.netbeans.api.progress.ProgressHandle handle) |
void |
refreshApplication(Context context,
org.netbeans.api.progress.ProgressHandle handle) |
public abstract java.lang.String getDisplayName()
public void refresh(Context context, org.netbeans.api.progress.ProgressHandle handle) throws java.lang.InterruptedException
java.lang.InterruptedException
public void refreshApplication(Context context, org.netbeans.api.progress.ProgressHandle handle) throws java.lang.InterruptedException
java.lang.InterruptedException