JHotDraw 6.0b1

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


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)
           
protected  AbstractCommand.EventDispatcher createEventDispatcher()
           
protected  ViewChangeListener createViewChangeListener()
           
 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()
           
protected  AbstractCommand.EventDispatcher getEventDispatcher()
           
 Undoable getUndoActivity()
           
 boolean isExecutable()
          Tests if the command can be executed.
protected  boolean isExecutableWithView()
           
protected  boolean isViewRequired()
           
 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
protected  void viewCreated(DrawingView view)
          Sent when a new view is created
protected  void viewDestroying(DrawingView view)
          Send when an existing view is about to be destroyed.
protected  void viewSelectionChanged(DrawingView oldView, DrawingView newView)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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

viewSelectionChanged

protected void viewSelectionChanged(DrawingView oldView,
                                    DrawingView newView)

viewCreated

protected void viewCreated(DrawingView view)
Sent when a new view is created


viewDestroying

protected void viewDestroying(DrawingView view)
Send when an existing view is about to be destroyed.


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

isViewRequired

protected boolean isViewRequired()

isExecutableWithView

protected boolean isExecutableWithView()

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

getEventDispatcher

protected AbstractCommand.EventDispatcher getEventDispatcher()

createEventDispatcher

protected AbstractCommand.EventDispatcher createEventDispatcher()

createViewChangeListener

protected ViewChangeListener createViewChangeListener()

JHotDraw 6.0b1