Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

javax.ide.command
Class Command

java.lang.Object
  extended by javax.ide.command.Command
All Implemented Interfaces:
Identifiable

public abstract class Command
extends java.lang.Object
implements Identifiable

The Command interface defines the interface of all command objects. This interface consists of a procedure, doit, to execute a command. Concrete Command subclasses implement the necessary behavior to carry out a specific command.

This interface also provides additional methods necessary to implement the undo service provided by the CommandProcessor. For the undo mechanism it is necessary to distinguish three types of commands:

Commands are executed using the CommandProcessor. As NORMAL commands are executed, they are recorded by the command processor. This allows the command processor to perform undo and redo operations.

See Also:
CommandProcessor

Field Summary
static int CANCEL
          Command execution CANCEL status
static int NO_CHANGE
          Indicates a command that requires no undo.
static int NO_UNDO
          Indicates a command that cannot be undone, and which prevents the undo of previously performed normal commands.
static int NORMAL
          Indicates a command that can be undone.
static int OK
          Command execution OK status
 
Constructor Summary
protected Command()
           
protected Command(int type)
           
 
Method Summary
abstract  int doit()
          Executes the actions associated with a specific command.
 Document[] getAffectedDocuments()
          In general, the command processor manages undo stacks on a per Document basis.
protected  Context getContext()
          Gets the ide current Context.
abstract  java.lang.String getName()
          Gets the name of the command to display as the action to undo
 int getType()
          Gets the command type
 void setContext(Context context)
          Sets Context associated with command
abstract  int undo()
          Called by the CommandProcessor to undo a command When a command executes successfully, implementations should return OK, otherwise, return CANCEL or any other non-zero value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.ide.Identifiable
getID
 

Field Detail

NORMAL

public static final int NORMAL
Indicates a command that can be undone.

See Also:
Constant Field Values

NO_CHANGE

public static final int NO_CHANGE
Indicates a command that requires no undo.

See Also:
Constant Field Values

NO_UNDO

public static final int NO_UNDO
Indicates a command that cannot be undone, and which prevents the undo of previously performed normal commands.

See Also:
Constant Field Values

OK

public static final int OK
Command execution OK status

See Also:
Constant Field Values

CANCEL

public static final int CANCEL
Command execution CANCEL status

See Also:
Constant Field Values
Constructor Detail

Command

protected Command()

Command

protected Command(int type)
Method Detail

doit

public abstract int doit()
                  throws java.lang.Exception
Executes the actions associated with a specific command. When a command executes successfully, implementations should return OK, otherwise, return CANCEL or any other non-zero value.

Throws:
java.lang.Exception

undo

public abstract int undo()
                  throws java.lang.Exception
Called by the CommandProcessor to undo a command When a command executes successfully, implementations should return OK, otherwise, return CANCEL or any other non-zero value.

Throws:
java.lang.Exception

getName

public abstract java.lang.String getName()
Gets the name of the command to display as the action to undo


getType

public final int getType()
Gets the command type

Returns:
The command type. Can be one of the following values: NORMAL, NO_UNDO, or NO_CHANGE.

getContext

protected final Context getContext()
Gets the ide current Context.


setContext

public final void setContext(Context context)
Sets Context associated with command


getAffectedDocuments

public Document[] getAffectedDocuments()
In general, the command processor manages undo stacks on a per Document basis. When the execution of a command affects more than the target document, the other affected documents undo stacks must be be flushed in order to maintain document consistency. This method should be called by the command processor implementations after a command is executed to determine if that command affects other documents.

The CommandProcessor uses the return value to clear the undo stack of the affected documents.

For commands of the NORMAL and NO_UNDO type, this method should return an array of documents affected by the execution of this command. This array should not include the primary document on which this command is operating, it should only include other documents affected as a side effect of executing this command. The affected documents undo stack will be flushed.

Commands of type NO_CHANGE should return an empty array. The default implementation returns an empty array.

Returns:
the documents affected by this command, otherwise, an empty array. This method must not return null.

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.