Top Description Fields Constructors Methods
org.eclipse.swt.custom

public Class BusyIndicator

extends Object
Class Inheritance
Imports
java.util.*, java.util.concurrent.*, java.util.concurrent.atomic.*, org.eclipse.swt.*, org.eclipse.swt.graphics.*, org.eclipse.swt.widgets.*

Support for showing a Busy Cursor during a long running process.
See Also
BusyIndicator snippets, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv static final String
pack-priv static final String
private static final AtomicInteger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static void
clearBusyCursor(Display display, Integer busyId)

public static <V, E extends Exception> CompletableFuture<V>
compute(SwtCallable<V, E>
the action that should be executed and produces a result of the CompletableFuture
action
)

If called from a Display thread use the given SwtCallable to produces a CompletableFuture providing busy feedback using the busy indicator while computation is running.

public static <V, E extends Exception> CompletableFuture<V>
compute(SwtCallable<V, E>
the action that should be executed and produces a result of the CompletableFuture
action
,
Executor
the Executor to perform the computation in case this is called from a Display thread, passing a Display will throw an IllegalArgumentException as this will lead to a blocking UI and violates the contract of this method
executor
)

If called from a Display thread use the given SwtCallable to compute a CompletableFuture providing busy feedback using the busy indicator while computation is running.

public static <E extends Exception> CompletableFuture<?>
execute(SwtRunnable<E>
the action that should be executed and produces a result of the CompletableFuture
action
)

If called from a Display thread use the given SwtRunnable to produces a CompletableFuture providing busy feedback using the busy indicator while execution is running.

public static <E extends Exception> CompletableFuture<?>
execute(SwtRunnable<E>
the action that should be executed and produces a result of the CompletableFuture
action
,
Executor
the Executor to perform the computation in case this is called from a Display thread, passing a Display will throw an IllegalArgumentException as this will lead to a blocking UI and violates the contract of this method
executor
)

If called from a Display thread use the given SwtRunnable to produces a CompletableFuture providing busy feedback using the busy indicator while execution is running.

private static Integer
private static void
setCursorAndId(Shell shell, Cursor cursor, Integer busyId)

Paranoia code to make sure we don't break UI because of one shell disposed, see bug 532632 comment 20

public static void
showWhile(Display
the display on which the busy feedback should be displayed. If the display is null, the Display for the current thread will be used. If there is no Display for the current thread, the runnable code will be executed and no busy feedback will be displayed.
display
,
Runnable
the runnable for which busy feedback is to be shown. Must not be null.
runnable
)

Runs the given Runnable while providing busy feedback using this busy indicator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUSY_CURSORback to summary
pack-priv static final String BUSY_CURSOR
BUSYID_NAMEback to summary
pack-priv static final String BUSYID_NAME
nextBusyIdback to summary
private static final AtomicInteger nextBusyId

Constructor Detail

BusyIndicatorback to summary
public BusyIndicator()

Method Detail

clearBusyCursorback to summary
private static void clearBusyCursor(Display display, Integer busyId)
computeback to summary
public static <V, E extends Exception> CompletableFuture<V> compute(SwtCallable<V, E> action)

If called from a Display thread use the given SwtCallable to produces a CompletableFuture providing busy feedback using the busy indicator while computation is running. If called from a non Display the computation is performed in place and the result returned as a CompletableFuture. It is therefore safe to call this method from any thread and the SwtCallable is always evaluated outside the UI. The ForkJoinPool#commonPool() is used to execute the computation in case this is called from a Display thread

Parameters
action:SwtCallable<V, E>

the action that should be executed and produces a result of the CompletableFuture

Since
3.123
computeback to summary
public static <V, E extends Exception> CompletableFuture<V> compute(SwtCallable<V, E> action, Executor executor)

If called from a Display thread use the given SwtCallable to compute a CompletableFuture providing busy feedback using the busy indicator while computation is running. If called from a non Display the computation is performed in place and the result returned as a CompletableFuture. It is therefore safe to call this method from any thread and the SwtCallable is always evaluated outside the UI.

Parameters
action:SwtCallable<V, E>

the action that should be executed and produces a result of the CompletableFuture

executor:Executor

the Executor to perform the computation in case this is called from a Display thread, passing a Display will throw an IllegalArgumentException as this will lead to a blocking UI and violates the contract of this method

Since
3.123
executeback to summary
public static <E extends Exception> CompletableFuture<?> execute(SwtRunnable<E> action)

If called from a Display thread use the given SwtRunnable to produces a CompletableFuture providing busy feedback using the busy indicator while execution is running. If called from a non Display the execution is performed in place and the result returned as a CompletableFuture. It is therefore safe to call this method from any thread and the SwtCallable is always evaluated outside the UI. The ForkJoinPool#commonPool() is used to execute the computation in case this is called from a Display thread

Parameters
action:SwtRunnable<E>

the action that should be executed and produces a result of the CompletableFuture

Since
3.123
executeback to summary
public static <E extends Exception> CompletableFuture<?> execute(SwtRunnable<E> action, Executor executor)

If called from a Display thread use the given SwtRunnable to produces a CompletableFuture providing busy feedback using the busy indicator while execution is running. If called from a non Display the execution is performed in place and the result returned as a CompletableFuture. It is therefore safe to call this method from any thread and the SwtCallable is always evaluated outside the UI.

Parameters
action:SwtRunnable<E>

the action that should be executed and produces a result of the CompletableFuture

executor:Executor

the Executor to perform the computation in case this is called from a Display thread, passing a Display will throw an IllegalArgumentException as this will lead to a blocking UI and violates the contract of this method

Since
3.123
setBusyCursorback to summary
private static Integer setBusyCursor(Display display)
setCursorAndIdback to summary
private static void setCursorAndId(Shell shell, Cursor cursor, Integer busyId)

Paranoia code to make sure we don't break UI because of one shell disposed, see bug 532632 comment 20

showWhileback to summary
public static void showWhile(Display display, Runnable runnable)

Runs the given Runnable while providing busy feedback using this busy indicator.

Parameters
display:Display

the display on which the busy feedback should be displayed. If the display is null, the Display for the current thread will be used. If there is no Display for the current thread, the runnable code will be executed and no busy feedback will be displayed.

runnable:Runnable

the runnable for which busy feedback is to be shown. Must not be null.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the runnable is null