org.pietschy.command.interceptor
Class GlassPaneInterceptor

java.lang.Object
  extended by org.pietschy.command.interceptor.GlassPaneInterceptor
All 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(org.pietschy.command.ActionCommand) and uninstall(org.pietschy.command.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(java.awt.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STACK_STRATEGY

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

COUNTER_STRATEGY

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

SHARED_INSTANCE

public static GlassPaneInterceptor SHARED_INSTANCE
Constructor Detail

GlassPaneInterceptor

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

Parameters:
glassPane - the glass pane to use.
Method Detail

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.

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.

sharedInstance

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

Returns:
the shared instance of this interceptor.

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.

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.

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.

setGlassPaneHandler

public void setGlassPaneHandler(GlassPaneHandler glassPaneHandler)