All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.ibm.desktop.Command

java.lang.Object
   |
   +----COM.ibm.desktop.Command

public abstract class Command
extends Object
implements Serializable
Commands are objects that encapsulate a change to a target. A command is capabaple of making a change to the target object (do), reversing the change to the target (undo), and remaking the change to the target (redo).

A command has a label to identify the command to be undone or redone. Not all commands can be undone. Commands can be of one of the following types:

  • kNoChange - Does not modify the target, so it does not need to be undone
  • kCantUndo - Cannot be undone
  • kSerialUndo - Can be undone, but only in the reverse order of that in which they were done.

    Command is an abstract class. Concrete classes of Command implement the handleDo, handleUndo, and handleRedo methods to do, undo, and redo the command on the target. They implement the handleCanDo method to specify conditions that must be satisfied for a change to happen.

    The target object can be a Model or part of a Model which is often specified by a ModelSelection.

     Copyright (c) Taligent, Inc.  1996 - 1997.
     Copyright (c) IBM Corporation 1996 - 1997.
     All Rights Reserved.
     

    See Also:
    Model, ModelSelection

    Variable Index

     o kCantUndo
    Command cannot be undone.
     o kNoChange
    Command does not modify the target, so it does not need to be undone.
     o kSerialUndo
    Command can be undone, but only in the reverse order of that in which they were done.

    Constructor Index

     o Command()
    Construct a command of type kSerialUndo.
     o Command(int)
    Construct a command of the specified type.
     o Command(String)
    Construct a command with the specified label.
     o Command(String, int)
    Construct a command with the specified label and type.

    Method Index

     o getLabel()
    Get the command label
     o getType()
    Get the command type
     o handleCanDo()
    Can the command be done? Override this method to specify the conditions that must be satisfied before the command can be performed.
     o handleDo()
    Invoked by the framework to do the command.
     o handleRedo()
    Invoked by the framework to redo the command.
     o handleUndo()
    Invoked by the framework to undo the command.
     o setLabel(String)
    Set the command label
     o setType(int)
    Set the command type

    Variables

     o kNoChange
     public static final int kNoChange
    
    Command does not modify the target, so it does not need to be undone.

     o kCantUndo
     public static final int kCantUndo
    
    Command cannot be undone.

     o kSerialUndo
     public static final int kSerialUndo
    
    Command can be undone, but only in the reverse order of that in which they were done.

    Constructors

     o Command
     public Command()
    
    Construct a command of type kSerialUndo.

     o Command
     public Command(String label)
    
    Construct a command with the specified label.

    Parameters:
    label - command label
     o Command
     public Command(int type)
    
    Construct a command of the specified type.

    Parameters:
    type - command type, one of kNoChange, kCantUndo, and kSerialUndo
     o Command
     public Command(String label,
                    int type)
    
    Construct a command with the specified label and type.

    Parameters:
    label - command label
    type - command type, one of kNoChange, kCantUndo, and kSerialUndo

    Methods

     o getType
     public int getType()
    
    Get the command type

     o setType
     public void setType(int type)
    
    Set the command type

     o getLabel
     public String getLabel()
    
    Get the command label

     o setLabel
     public void setLabel(String label)
    
    Set the command label

     o handleCanDo
     public boolean handleCanDo()
    
    Can the command be done? Override this method to specify the conditions that must be satisfied before the command can be performed. Default implementation returns true.

     o handleDo
     protected abstract void handleDo()
    
    Invoked by the framework to do the command. Must override this method.

     o handleUndo
     protected void handleUndo()
    
    Invoked by the framework to undo the command. Override this method to reverse a change to the target. There is no default implementation.

     o handleRedo
     protected void handleRedo()
    
    Invoked by the framework to redo the command. Override this method to reapply a change to the target. There is no default implementation.


    All Packages  Class Hierarchy  This Package  Previous  Next  Index