org.jdesktop.application
Class Task.InputBlocker

java.lang.Object
  extended by org.jdesktop.application.AbstractBean
      extended by org.jdesktop.application.Task.InputBlocker
Enclosing class:
Task<T,V>

public abstract static class Task.InputBlocker
extends AbstractBean

Specifies to what extent input to the Application's GUI should be blocked while this Task is being executed and provides a pair of methods, block and unblock that do the work of blocking the GUI. For the sake of input blocking, a Task begins executing when it's submitted to a TaskService, and it finishes executing after the Task's completion methods have been called.

The InputBlocker's BlockingScope and the blocking target object define what part of the GUI's input will be blocked:

Task.BlockingScope.NONE
Don't block input. The blocking target is ignored in this case.

Task.BlockingScope.ACTION
Disable the target Action while the Task is executing.

Task.BlockingScope.COMPONENT
Disable the target Component Component while the Task is executing.

Task.BlockingScope.WINDOW
Block the Window ancestor of the target Component while the Task is executing.

Task.BlockingScope.Application
Block the entire Application while the Task is executing. The blocking target is ignored in this case.

Input blocking begins when the block method is called and ends when unblock is called. Each method is only called once, typically by the TaskService.

See Also:
Task.getInputBlocker(), Task.setInputBlocker(org.jdesktop.application.Task.InputBlocker), TaskService, Action

Constructor Summary
Task.InputBlocker(Task task, Task.BlockingScope scope, java.lang.Object target)
          Construct an InputBlocker.
Task.InputBlocker(Task task, Task.BlockingScope scope, java.lang.Object target, ApplicationAction action)
          Construct an InputBlocker with four immutable properties.
 
Method Summary
protected abstract  void block()
          Block input to the GUI per the scope and target properties.
 ApplicationAction getAction()
          The ApplicationAction (@Action) that caused the task to be executed.
 Task.BlockingScope getScope()
          Defines the extent to which the GUI is blocked while the task is being executed.
 java.lang.Object getTarget()
          Specifies the GUI element that will be blocked while the task is being executed.
 Task getTask()
          The block method will block input while this Task is being executed by a TaskService.
protected abstract  void unblock()
          Unblock input to the GUI by undoing whatever the block method did.
 
Methods inherited from class org.jdesktop.application.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Task.InputBlocker

public Task.InputBlocker(Task task,
                         Task.BlockingScope scope,
                         java.lang.Object target,
                         ApplicationAction action)
Construct an InputBlocker with four immutable properties. If the Task is null or if the Task has already been executed by a TaskService, then an exception is thrown. If scope is BlockingScope.ACTION then target must be a Action. If scope is BlockingScope.WINDOW or BlockingScope.COMPONENT then target must be a Component.

Parameters:
task - block input while this Task is executing
scope - how much of the GUI will be blocked
target - the GUI element that will be blocked
action - the @Action that triggered running the task, or null
See Also:
TaskService.execute(org.jdesktop.application.Task)

Task.InputBlocker

public Task.InputBlocker(Task task,
                         Task.BlockingScope scope,
                         java.lang.Object target)
Construct an InputBlocker. If target is an ApplicationAction, it becomes the InputBlocker's action. If the Task is null or if the Task has already been executed by a TaskService, then an exception is thrown.

Parameters:
task - block input while this Task is executing
scope - how much of the GUI will be blocked
target - the GUI element that will be blocked
See Also:
TaskService.execute(org.jdesktop.application.Task)
Method Detail

getTask

public final Task getTask()
The block method will block input while this Task is being executed by a TaskService.

Returns:
the value of the read-only Task property
See Also:
block(), unblock()

getScope

public final Task.BlockingScope getScope()
Defines the extent to which the GUI is blocked while the task is being executed.

Returns:
the value of the read-only blockingScope property
See Also:
block(), unblock()

getTarget

public final java.lang.Object getTarget()
Specifies the GUI element that will be blocked while the task is being executed.

This property may be null.

Returns:
the value of the read-only target property
See Also:
getScope(), block(), unblock()

getAction

public final ApplicationAction getAction()
The ApplicationAction (@Action) that caused the task to be executed. The DefaultInputBlocker uses the action's name and resourceMap to configure its blocking dialog if scope is BlockingScope.WINDOW.

This property may be null.

Returns:
the value of the read-only action property
See Also:
getScope(), block(), unblock(), ApplicationAction.getName(), ApplicationAction.getResourceMap()

block

protected abstract void block()
Block input to the GUI per the scope and target properties. This method will only be called once.

See Also:
unblock(), TaskService.execute(org.jdesktop.application.Task)

unblock

protected abstract void unblock()
Unblock input to the GUI by undoing whatever the block method did. This method will only be called once.

See Also:
block(), TaskService.execute(org.jdesktop.application.Task)