Package org.praxislive.ide.core.api
Interface Task
- All Superinterfaces:
org.openide.util.Cancellable
- All Known Subinterfaces:
Task.WithResult<T>
- All Known Implementing Classes:
AbstractTask,AbstractTask.WithResult,SerialTasks
public interface Task
extends org.openide.util.Cancellable
A task to be executed. The task may complete within a call to
execute() or initiate asynchronous operation, such as making calls
into the PraxisCORE hub. If the caller needs to know when an asynchronous
task is completed, it may add a property change listener.
A task may only be executed once.
All methods should be called on, and all listeners are fired on, the Swing event thread.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe possible states of a Task.static interfaceAn extension of Task that produces a result when it completes successfully. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of property used when firing state change events. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a property change listener.Optional description of this task to be presented to the user.execute()Initiate execution of the task.getState()Query the current task state.log()Optional log of information generated by execution of this task, suitable for presentation to the user.voidRemove a property change listener.static CompletionStage<Void> Execute the task wrapped in a completion stage.Methods inherited from interface org.openide.util.Cancellable
cancel
-
Field Details
-
PROP_STATE
Name of property used when firing state change events.- See Also:
-
-
Method Details
-
execute
Task.State execute()Initiate execution of the task. This method returnsTask.State.RUNNINGwhen the task is running asynchronous operations. The caller may add a property listener if it needs to know when and how those operations complete.A task can only be executed once. This method will throw an
IllegalStateExceptionif the task state is notTask.State.NEW.- Returns:
- task state
- Throws:
IllegalStateException- if the task state is not NEW.
-
getState
Task.State getState()Query the current task state.- Returns:
- task state
-
addPropertyChangeListener
Add a property change listener.- Parameters:
listener- property change listener
-
removePropertyChangeListener
Remove a property change listener.- Parameters:
listener- property change listener
-
description
Optional description of this task to be presented to the user.- Returns:
- optional description
-
log
Optional log of information generated by execution of this task, suitable for presentation to the user.- Returns:
- task log
-
run
Execute the task wrapped in a completion stage.- Parameters:
task- task to execute- Returns:
- task completion stage
-