Class SimpleWorkState<V>

java.lang.Object
org.jhotdraw8.fxbase.concurrent.SimpleWorkState<V>
Type Parameters:
V - the type of the result value
All Implemented Interfaces:
javafx.concurrent.Worker<V>, WorkState<V>

public class SimpleWorkState<V> extends Object implements WorkState<V>
A simple implementation of the WorkState interface.

This implementation requires that the FX Application Thread is running.

  • Property Details

  • Constructor Details

    • SimpleWorkState

      public SimpleWorkState()
      Creates a new instance.
    • SimpleWorkState

      public SimpleWorkState(@Nullable String title)
      Creates a new instance with the specified title.
      Parameters:
      title - a title
  • Method Details

    • updateValue

      public void updateValue(@Nullable V newValue)
      This method may be called on any thread.
      Specified by:
      updateValue in interface WorkState<V>
      Parameters:
      newValue - the new value
    • getValue

      public @Nullable V getValue()
      Gets the value of the value property.
      Specified by:
      getValue in interface javafx.concurrent.Worker<V>
      Specified by:
      getValue in interface WorkState<V>
      Property description:
      Returns:
      the value of the value property
      See Also:
    • valueProperty

      public javafx.beans.property.ReadOnlyObjectProperty<V> valueProperty()
      Specified by:
      valueProperty in interface javafx.concurrent.Worker<V>
      Specified by:
      valueProperty in interface WorkState<V>
      Returns:
      the value property
      See Also:
    • updateWorkDone

      public void updateWorkDone(double newValue)
      This method may be called on any thread.
      Parameters:
      newValue - the new value
    • getWorkDone

      public double getWorkDone()
      Gets the value of the workDone property.
      Specified by:
      getWorkDone in interface javafx.concurrent.Worker<V>
      Specified by:
      getWorkDone in interface WorkState<V>
      Property description:
      Returns:
      the value of the workDone property
      See Also:
    • workDoneProperty

      public javafx.beans.property.ReadOnlyDoubleProperty workDoneProperty()
      Specified by:
      workDoneProperty in interface javafx.concurrent.Worker<V>
      Specified by:
      workDoneProperty in interface WorkState<V>
      Returns:
      the workDone property
      See Also:
    • updateTotalWork

      public void updateTotalWork(double newValue)
      This method may be called on any thread.
      Parameters:
      newValue - the new value
    • getTotalWork

      public double getTotalWork()
      Gets the value of the totalWork property.
      Specified by:
      getTotalWork in interface javafx.concurrent.Worker<V>
      Specified by:
      getTotalWork in interface WorkState<V>
      Property description:
      Returns:
      the value of the totalWork property
      See Also:
    • totalWorkProperty

      public javafx.beans.property.ReadOnlyDoubleProperty totalWorkProperty()
      Specified by:
      totalWorkProperty in interface javafx.concurrent.Worker<V>
      Specified by:
      totalWorkProperty in interface WorkState<V>
      Returns:
      the totalWork property
      See Also:
    • updateProgress

      public void updateProgress(double newValue)
      This method may be called on any thread.
      Specified by:
      updateProgress in interface WorkState<V>
      Parameters:
      newValue - the new value
    • getProgress

      public double getProgress()
      Gets the value of the progress property.
      Specified by:
      getProgress in interface javafx.concurrent.Worker<V>
      Specified by:
      getProgress in interface WorkState<V>
      Property description:
      Returns:
      the value of the progress property
      See Also:
    • progressProperty

      public javafx.beans.property.ReadOnlyDoubleProperty progressProperty()
      Specified by:
      progressProperty in interface javafx.concurrent.Worker<V>
      Specified by:
      progressProperty in interface WorkState<V>
      Returns:
      the progress property
      See Also:
    • getMessage

      public @Nullable String getMessage()
      Gets the value of the message property.
      Specified by:
      getMessage in interface javafx.concurrent.Worker<V>
      Specified by:
      getMessage in interface WorkState<V>
      Property description:
      Returns:
      the value of the message property
      See Also:
    • messageProperty

      public javafx.beans.property.ReadOnlyStringProperty messageProperty()
      Specified by:
      messageProperty in interface javafx.concurrent.Worker<V>
      Specified by:
      messageProperty in interface WorkState<V>
      Returns:
      the message property
      See Also:
    • getTitle

      public @Nullable String getTitle()
      Gets the value of the title property.
      Specified by:
      getTitle in interface javafx.concurrent.Worker<V>
      Specified by:
      getTitle in interface WorkState<V>
      Property description:
      Returns:
      the value of the title property
      See Also:
    • titleProperty

      public javafx.beans.property.ReadOnlyStringProperty titleProperty()
      Specified by:
      titleProperty in interface javafx.concurrent.Worker<V>
      Specified by:
      titleProperty in interface WorkState<V>
      Returns:
      the title property
      See Also:
    • updateMessage

      public void updateMessage(@Nullable String value)
      Description copied from interface: WorkState
      Asynchronously updates the current message of the work state.

      Calls to this method are coalesced and run later on the FX application thread, so calls to this method, even from the FX Application thread, may not necessarily result in immediate updates to the property, and intermediate values may be coalesced to save on event notifications.

      Specified by:
      updateMessage in interface WorkState<V>
      Parameters:
      value - the new value
    • updateState

      public void updateState(@Nullable javafx.concurrent.Worker.State value)
      Description copied from interface: WorkState
      Asynchronously updates the current state of the work state.

      Calls to this method are coalesced as described in WorkState.updateMessage(String).

      Specified by:
      updateState in interface WorkState<V>
      Parameters:
      value - the new value
    • updateException

      public void updateException(@Nullable Throwable value)
      Description copied from interface: WorkState
      Asynchronously updates the current exception of the work state.

      Calls to this method are coalesced as described in WorkState.updateMessage(String).

      Specified by:
      updateException in interface WorkState<V>
      Parameters:
      value - the new value
    • updateRunning

      public void updateRunning(boolean value)
      Description copied from interface: WorkState
      Asynchronously updates the current running state of the work state.

      Calls to this method are coalesced as described in WorkState.updateMessage(String).

      Specified by:
      updateRunning in interface WorkState<V>
      Parameters:
      value - the new value
    • updateTitle

      public void updateTitle(String value)
      Description copied from interface: WorkState
      Asynchronously updates the current title of the work state.

      Calls to this method are coalesced as described in WorkState.updateMessage(String).

      Specified by:
      updateTitle in interface WorkState<V>
      Parameters:
      value - the new value
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: WorkState
      Returns true if the worker associated to this work state should cancel.
      Specified by:
      isCancelled in interface WorkState<V>
      Returns:
      true if cancelled
    • cancel

      public boolean cancel()
      Specified by:
      cancel in interface javafx.concurrent.Worker<V>
    • getState

      public javafx.concurrent.Worker.State getState()
      Gets the value of the state property.
      Specified by:
      getState in interface javafx.concurrent.Worker<V>
      Property description:
      Returns:
      the value of the state property
      See Also:
    • stateProperty

      public javafx.beans.property.ReadOnlyObjectProperty<javafx.concurrent.Worker.State> stateProperty()
      Specified by:
      stateProperty in interface javafx.concurrent.Worker<V>
      Returns:
      the state property
      See Also:
    • getException

      public Throwable getException()
      Gets the value of the exception property.
      Specified by:
      getException in interface javafx.concurrent.Worker<V>
      Property description:
      Returns:
      the value of the exception property
      See Also:
    • exceptionProperty

      public javafx.beans.property.ReadOnlyObjectProperty<Throwable> exceptionProperty()
      Specified by:
      exceptionProperty in interface javafx.concurrent.Worker<V>
      Returns:
      the exception property
      See Also:
    • isRunning

      public boolean isRunning()
      Gets the value of the running property.
      Specified by:
      isRunning in interface javafx.concurrent.Worker<V>
      Property description:
      Returns:
      the value of the running property
      See Also:
    • runningProperty

      public javafx.beans.property.ReadOnlyBooleanProperty runningProperty()
      Specified by:
      runningProperty in interface javafx.concurrent.Worker<V>
      Returns:
      the running property
      See Also: