com.mindfusion.diagramming
Class Command

java.lang.Object
  extended by com.mindfusion.diagramming.Command
Direct Known Subclasses:
AddGroupCmd, AddItemCmd, AddToContainerCmd, ChangeItemCmd, CompositeCmd, ExpandHeaderRowCmd, ExpandItemCmd, ExpandTreeViewItemCmd, FoldContainerCmd, GroupAttachCmd, GroupDetachCmd, ModifyItemCmd, RedimTableCmd, RemoveFromContainerCmd, RemoveGroupCmd, RemoveItemCmd, ScrollTableCmd, ScrollTreeViewCmd

public abstract class Command
extends java.lang.Object

Represents an action that can be undone or redone.


Constructor Summary
Command(java.lang.String title)
          Initializes a new Command instance.
 
Method Summary
 void addSubCmd(Command cmd)
          Adds a command object to a compound command.
protected  boolean adopt(Command command)
          Merges adjacent commands in the history queue if they are related.
abstract  void execute(boolean undoEnabled)
          This method is called internally by JDiagram when performing the action.
protected  CommandContext getContext()
           
 CommandList getSubCommands()
          Gets a collection of all command objects contained within the composite one.
 java.lang.String getTitle()
          Gets the title of this command.
protected  boolean isContainerOf(Command command)
          Determines whether a command has been initiated by this command and should be treated as a derivative.
 void redo()
          This method is called by the UndoManager when redoing actions.
 void setTitle(java.lang.String value)
          Sets the command title.
 void undo()
          This method is called by the UndoManager when undoing actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command(java.lang.String title)
Initializes a new Command instance.

Parameters:
title - A String containing the command title.
Method Detail

execute

public abstract void execute(boolean undoEnabled)
This method is called internally by JDiagram when performing the action.

Parameters:
undoEnabled - true if the undo manager is enabled at this time, otherwise false.

undo

public void undo()
This method is called by the UndoManager when undoing actions.


redo

public void redo()
This method is called by the UndoManager when redoing actions.


getContext

protected CommandContext getContext()

addSubCmd

public void addSubCmd(Command cmd)
Adds a command object to a compound command.

Parameters:
cmd - A subordinate action that should be executed, undone or redone together with this command.

isContainerOf

protected boolean isContainerOf(Command command)
Determines whether a command has been initiated by this command and should be treated as a derivative.

Parameters:
command - The Command for which to determine whether it is a derivative.
Returns:
true if the specified command should be considered a derivative; otherwise, false.

adopt

protected boolean adopt(Command command)
Merges adjacent commands in the history queue if they are related.

Parameters:
command - The Command that might be adopted by this command.
Returns:
true if the specified command has been adopted; otherwise, false.

getTitle

public java.lang.String getTitle()
Gets the title of this command.

Returns:
A String containing the command's title.

setTitle

public void setTitle(java.lang.String value)
Sets the command title.

Parameters:
value - A String containing the command's title.

getSubCommands

public CommandList getSubCommands()
Gets a collection of all command objects contained within the composite one.

Returns:
A CommandList containing the child commands.