All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.util
Class CommandDispatcher

    com.sas.util.CommandDispatcher

All Implemented Interfaces:
  com.sas.lang.ObjectDataInterface, SupportsErrorHandlerInterface, SupportsGenericErrorHandlerInterface, java.awt.event.ActionListener, java.awt.event.ItemListener, java.util.EventListener

    public class CommandDispatcher

implements java.awt.event.ActionListener, java.awt.event.ItemListener, com.sas.lang.ObjectDataInterface, SupportsErrorHandlerInterface, SupportsGenericErrorHandlerInterface

CommandDispatcher is a class to execute a specified Command when an event is fired. It implements the ItemListener and the ActionListener interfaces to handle ItemEvents and ActionEvents. When an event is fired that the CommandDispatcher is registered as a listener on, it will call the execute(Object) method on its command property passing in the objectData as the parameter. This dispatcher can be used with Buttons, PopupMenus or any other component which fires an ItemEvent or ActionEvent to cause a Command to be executed.

Field Summary
`protected com.sas.util.Command` | `command`
`protected java.lang.Object` | `commandData`
`protected ErrorHandlerInterface` | `errHandler`
`protected GenericErrorHandlerInterface` | `genericErrHandler`

Constructor Summary
`CommandDispatcher()` Default Constructor.
`CommandDispatcher(com.sas.util.Command cmd)` Constructor that sets the Command to execute.
`CommandDispatcher(com.sas.util.Command cmd, java.lang.Object cmdData)` Constructor that sets the Command to execute and the data to send to that command in the execute() method.

Method Summary
`void` | `actionPerformed(java.awt.event.ActionEvent e)` ActionListener method to handle ActionEvent.
`void` | `executeCommand()` Execute the command associated with this dispatcher.
`com.sas.util.Command` | `getCommand()` Get the command to be executed when an event is received.
`ErrorHandlerInterface` | `getErrorHandler()` Get the error handler that is set on the command if it implements the SupportsErrorHandlerInterface.
`GenericErrorHandlerInterface` | `getGenericErrorHandler()` Get the generic error handler that is set on the command if it implements the SupportsGenericErrorHandlerInterface.
`java.lang.Object` | `getObjectData()` Get the object passed to the execute(Object) method when the Command is executed.
`void` | `itemStateChanged(java.awt.event.ItemEvent e)` ItemListener method to handle ItemEvents.
`void` | `setCommand(com.sas.util.Command cmd)` Set the command to be executed when an event is received.
`void` | `setErrorHandler(ErrorHandlerInterface errorHandler)` Set the error handler that is set on the command if it implements the SupportsErrorHandlerInterface.
`void` | `setGenericErrorHandler(GenericErrorHandlerInterface genericErrorHandler)` Set the generic error handler that is set on the command if it implements the SupportsGenericErrorHandlerInterface.
`void` | `setObjectData(java.lang.Object cmdData)` Set the object passed to the execute(Object) method when the Command is executed.

Field Detail

### command

    protected com.sas.util.Command command

### commandData

    protected java.lang.Object commandData

### errHandler

    protected ErrorHandlerInterface errHandler

### genericErrHandler

    protected GenericErrorHandlerInterface genericErrHandler

Constructor Detail

### CommandDispatcher

    public CommandDispatcher()

  Default Constructor.

### CommandDispatcher

    public CommandDispatcher(com.sas.util.Command cmd)

  Constructor that sets the Command to execute.

### CommandDispatcher

    public CommandDispatcher(com.sas.util.Command cmd,
                             java.lang.Object cmdData)

  Constructor that sets the Command to execute and the data to send to that command in the execute() method.

Method Detail

### itemStateChanged

    public void itemStateChanged(java.awt.event.ItemEvent e)

  ItemListener method to handle ItemEvents. This method calls executeCommand().

  Specified by:
    `itemStateChanged` in interface `java.awt.event.ItemListener`

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent e)

  ActionListener method to handle ActionEvent. This method calls executeCommand().

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`

### executeCommand

    public void executeCommand()

  Execute the command associated with this dispatcher. This is called by the event handler methods to execute the command. If the command implements the SupportsErrorHandlerInterface, the errorHandler will be set on the command.

### getObjectData

    public java.lang.Object getObjectData()

  Get the object passed to the execute(Object) method when the Command is executed.

  Specified by:
    `getObjectData` in interface `com.sas.lang.ObjectDataInterface`

### setObjectData

    public void setObjectData(java.lang.Object cmdData)

  Set the object passed to the execute(Object) method when the Command is executed.

  Specified by:
    `setObjectData` in interface `com.sas.lang.ObjectDataInterface`

### getCommand

    public com.sas.util.Command getCommand()

  Get the command to be executed when an event is received.

### setCommand

    public void setCommand(com.sas.util.Command cmd)

  Set the command to be executed when an event is received.

### setErrorHandler

    public void setErrorHandler(ErrorHandlerInterface errorHandler)

  Set the error handler that is set on the command if it implements the SupportsErrorHandlerInterface.

  Specified by:
    `setErrorHandler` in interface `SupportsErrorHandlerInterface`
  Parameters:
    `errorHandler` - The error handler.

### getErrorHandler

    public ErrorHandlerInterface getErrorHandler()

  Get the error handler that is set on the command if it implements the SupportsErrorHandlerInterface.

  Specified by:
    `getErrorHandler` in interface `SupportsErrorHandlerInterface`
  Returns:
    The error handler.

### setGenericErrorHandler

    public void setGenericErrorHandler(GenericErrorHandlerInterface genericErrorHandler)

  Set the generic error handler that is set on the command if it implements the SupportsGenericErrorHandlerInterface.

  Specified by:
    `setGenericErrorHandler` in interface `SupportsGenericErrorHandlerInterface`
  Parameters:
    `errorHandler` - The generic error handler.

### getGenericErrorHandler

    public GenericErrorHandlerInterface getGenericErrorHandler()

  Get the generic error handler that is set on the command if it implements the SupportsGenericErrorHandlerInterface.

  Specified by:
    `getGenericErrorHandler` in interface `SupportsGenericErrorHandlerInterface`
  Returns:
    The generic error handler.

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.