org.jhotdraw.standard
Class AbstractCommand

java.lang.Object
  extended by org.jhotdraw.standard.AbstractCommand
All Implemented Interfaces:
FigureSelectionListener, Command
Direct Known Subclasses:
AlignCommand, BringToFrontCommand, ChangeAttributeCommand, FigureTransferCommand, GroupCommand, InsertImageCommand, RedoCommand, SelectAllCommand, SendToBackCommand, ToggleGridCommand, UndoCommand, UngroupCommand, ZoomCommand

public abstract class AbstractCommand
extends java.lang.Object
implements Command, FigureSelectionListener

Version:
<$CURRENT_VERSION$>
Author:
Helge Horch, Wolfram Kaiser

Nested Class Summary
static class AbstractCommand.EventDispatcher
           
 
Constructor Summary
AbstractCommand(java.lang.String newName, DrawingEditor newDrawingEditor)
          Constructs a command with the given name that applies to the given view.
AbstractCommand(java.lang.String newName, DrawingEditor newDrawingEditor, boolean newIsViewRequired)
           
 
Method Summary
 void addCommandListener(CommandListener newCommandListener)
           
 void dispose()
          Releases resources associated with this command
 void execute()
          Executes the command.
 void figureSelectionChanged(DrawingView view)
          Sent when the figure selection has changed.
 DrawingEditor getDrawingEditor()
           
 Undoable getUndoActivity()
           
 boolean isExecutable()
          Tests if the command can be executed.
 java.lang.String name()
          Gets the command name.
 void removeCommandListener(CommandListener oldCommandListener)
           
 void setName(java.lang.String newName)
           
 void setUndoActivity(Undoable newUndoableActivity)
           
 DrawingView view()
          Convenience method
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCommand

public AbstractCommand(java.lang.String newName,
                       DrawingEditor newDrawingEditor)
Constructs a command with the given name that applies to the given view.

Parameters:
newName - java.lang.String
newDrawingEditor - the DrawingEditor which manages the views

AbstractCommand

public AbstractCommand(java.lang.String newName,
                       DrawingEditor newDrawingEditor,
                       boolean newIsViewRequired)
Method Detail

figureSelectionChanged

public void figureSelectionChanged(DrawingView view)
Description copied from interface: FigureSelectionListener
Sent when the figure selection has changed.

Specified by:
figureSelectionChanged in interface FigureSelectionListener
Parameters:
view - a DrawingView

getDrawingEditor

public DrawingEditor getDrawingEditor()
Specified by:
getDrawingEditor in interface Command
Returns:
DrawingEditor associated with this command

view

public DrawingView view()
Convenience method

Returns:
DrawingView currently active in the editor

name

public java.lang.String name()
Gets the command name.

Specified by:
name in interface Command

setName

public void setName(java.lang.String newName)

dispose

public void dispose()
Releases resources associated with this command


execute

public void execute()
Executes the command.

Specified by:
execute in interface Command

isExecutable

public boolean isExecutable()
Tests if the command can be executed. The view must be valid when this is called. Per default, a command is executable if at least one figure is selected in the current activated view.

Specified by:
isExecutable in interface Command

getUndoActivity

public Undoable getUndoActivity()
Specified by:
getUndoActivity in interface Command

setUndoActivity

public void setUndoActivity(Undoable newUndoableActivity)
Specified by:
setUndoActivity in interface Command

addCommandListener

public void addCommandListener(CommandListener newCommandListener)
Specified by:
addCommandListener in interface Command

removeCommandListener

public void removeCommandListener(CommandListener oldCommandListener)
Specified by:
removeCommandListener in interface Command