org.pietschy.command.interceptor

Class GlassPaneInterceptor

Implemented Interfaces:
ActionCommandInterceptor

public class GlassPaneInterceptor
extends java.lang.Object
implements ActionCommandInterceptor

GlassPaneInterceptor provides a simple interceptor that activates the glass pane before a command executes and deactivates it afterward. This makes it easy block user interaction while the command is executing making it easy to use libraries like Foxtrot.

Generally this interceptor would be shared by all commands that need it. To this end the static methods install(ActionCommand) and uninstall(ActionCommand) are provided for your convenience.

 public class FoxtrotCommand extends ActionCommand
 {
    public FoxtrotCommand(CommandManager cm, String id)
    {
       super(cm, id);
       GlassPaneInterceptor.install(this);
    }

    public void handleExecute()
    {
       // the glass pane will be activated by the interceptor...

       Worker.post(...);

       // ..and removed when we're finished.
    }
 }
 

You can configure appearance of the glass pane by installing a custom instance of GlassPaneHandler.

Version:
$Revision: 1.5 $
Author:
andrewp

Field Summary

static org.pietschy.command.interceptor.GlassPaneInterceptorStrategy
COUNTER_STRATEGY
static GlassPaneInterceptor
SHARED_INSTANCE
static org.pietschy.command.interceptor.GlassPaneInterceptorStrategy
STACK_STRATEGY

Constructor Summary

GlassPaneInterceptor(Component glassPane)
Creates a new interceptor that uses the specified component as the glass pane.

Method Summary

void
afterExecute(ActionCommand command)
Get the commands invoking window and deactivates its glass pane.
boolean
beforeExecute(ActionCommand command)
Get the commands invoking window and activates its glass pane.
static void
install(ActionCommand command)
A convenience method for adding the shared interceptor to the specified command.
void
setGlassPaneHandler(GlassPaneHandler glassPaneHandler)
void
setStrategy(org.pietschy.command.interceptor.GlassPaneInterceptorStrategy modalstrategy)
Sets the GlassPaneInterceptorStrategy this interceptor is to use.
static GlassPaneInterceptor
sharedInstance()
Gets the shared instance of this interceptor.
static void
uninstall(ActionCommand command)
A convenience method for removing the shared interceptor from the specified command.

Field Details

COUNTER_STRATEGY

public static final org.pietschy.command.interceptor.GlassPaneInterceptorStrategy COUNTER_STRATEGY

SHARED_INSTANCE

public static GlassPaneInterceptor SHARED_INSTANCE

STACK_STRATEGY

public static final org.pietschy.command.interceptor.GlassPaneInterceptorStrategy STACK_STRATEGY

Constructor Details

GlassPaneInterceptor

public GlassPaneInterceptor(Component glassPane)
Creates a new interceptor that uses the specified component as the glass pane.
Parameters:
glassPane - the glass pane to use.

Method Details

afterExecute

public void afterExecute(ActionCommand command)
Get the commands invoking window and deactivates its glass pane.
Specified by:
afterExecute in interface ActionCommandInterceptor
Parameters:
command - the command whose window is to be unblocked.

beforeExecute

public boolean beforeExecute(ActionCommand command)
Get the commands invoking window and activates its glass pane.
Specified by:
beforeExecute in interface ActionCommandInterceptor
Parameters:
command - the command whose window is to be blocked.
Returns:
true.

install

public static void install(ActionCommand command)
A convenience method for adding the shared interceptor to the specified command.
Parameters:
command - the command to which the interceptor is to be added.

setGlassPaneHandler

public void setGlassPaneHandler(GlassPaneHandler glassPaneHandler)

setStrategy

public void setStrategy(org.pietschy.command.interceptor.GlassPaneInterceptorStrategy modalstrategy)
Sets the GlassPaneInterceptorStrategy this interceptor is to use.
Parameters:
modalstrategy - the GlassPaneInterceptorStrategy this interceptor is to use.

sharedInstance

public static GlassPaneInterceptor sharedInstance()
Gets the shared instance of this interceptor.
Returns:
the shared instance of this interceptor.

uninstall

public static void uninstall(ActionCommand command)
A convenience method for removing the shared interceptor from the specified command.
Parameters:
command - the command from which the interceptor is to be removed.