org.bs.mdi.swing
Class SwingCommand

java.lang.Object
  extended byorg.bs.mdi.Command
      extended byorg.bs.mdi.swing.SwingCommand
All Implemented Interfaces:
MessageProcessor
Direct Known Subclasses:
SwingCommandAdapter

public abstract class SwingCommand
extends Command

SwingCommand is basically a Command with icon support.


Constructor Summary
SwingCommand()
          Creates a new SwingCommand.
 
Method Summary
protected abstract  void doExecute()
          Executes this command.
abstract  KeyStroke getAccelerator()
          Gets the "accelerator" for this action.
 String getDescription()
          Gets the description of this command, e.g.
abstract  Icon getIcon(int size)
          Gets an icon representing this command.
 String getName()
          Gets the name of this command, e.g.
abstract  void processMessage(Object source, int type, Object argument)
          Processes messages.
 void removeFrom(Container container)
          Removes all triggers of this command from the specified container.
 void setDescription(String description)
          Sets the description of this command and updates all associated triggers.
 void setName(String name)
          Sets the name of this command and updates all associated triggers.
 
Methods inherited from class org.bs.mdi.Command
addTrigger, countTriggers, execute, getLocalizedDescription, getLocalizedName, getTriggers, isAvailable, removeAllTriggers, removeTrigger, setAvailable, updateTriggers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingCommand

public SwingCommand()
Creates a new SwingCommand.

Method Detail

doExecute

protected abstract void doExecute()
Description copied from class: Command
Executes this command.

Specified by:
doExecute in class Command

processMessage

public abstract void processMessage(Object source,
                                    int type,
                                    Object argument)
Description copied from class: Command
Processes messages. Using these messages, this method should try to determine if the command should be available or not and set the available status using Command.setAvailable(boolean). See: MessageProcessor.processMessage(Object, int, Object)

Specified by:
processMessage in interface MessageProcessor
Specified by:
processMessage in class Command

getName

public String getName()
Description copied from class: Command
Gets the name of this command, e.g. "Undo".

Specified by:
getName in class Command
Returns:
the command's name

getDescription

public String getDescription()
Description copied from class: Command
Gets the description of this command, e.g. "undoes the last modification".

Specified by:
getDescription in class Command
Returns:
the command's description

setName

public void setName(String name)
Sets the name of this command and updates all associated triggers.

Parameters:
name - the new name of this command

setDescription

public void setDescription(String description)
Sets the description of this command and updates all associated triggers.

Parameters:
description - the new description of this command

getIcon

public abstract Icon getIcon(int size)
Gets an icon representing this command.

Parameters:
size - the requested size of the icon
Returns:
the icon, or null if no icon is available

getAccelerator

public abstract KeyStroke getAccelerator()
Gets the "accelerator" for this action. This is the key combination which is supposed to trigger the event.

Returns:
the accelerator

removeFrom

public void removeFrom(Container container)
Removes all triggers of this command from the specified container. This is the preferred way of doing thing like removing commands from menus ans the like.

Parameters:
container - the container which is supposed to contain menu items associated with this command