Extension SDK 10.1.2

oracle.ide
Class CommandProcessor

java.lang.Object
  extended byoracle.ide.CommandProcessor

public final class CommandProcessor
extends java.lang.Object

The IdeCommandProcessor singleton class is responsible for managing the execution of the IDE commands and managing the undo stack. The IdeCommandProcessor provides methods for creating a new command, setting and getting the undo stack size, invoking a command action, and undoing a re-doing an executed command. In general, all controller implementation should use the IDE command processor to execute the commands that controller handles. For example, the Naviagator controller uses the IdeCommandProcessor) to handle its commands.

See Also:
Command, Controller, Ide

Method Summary
 boolean canRedo(Context context)
          Check if the last undone command can be redone.
 boolean canUndo(Context context)
          Check if the last command can be undone.
 Command createCommand(java.lang.String cmd, Context context)
          Creates and instance of the specified command.
 void flush(java.lang.Object object)
          Flush the undo stack associated with the specified object.
 void flush(java.lang.Object[] objects)
          Flush the undo stack of all the specified objects.
 Command getCommand(Context context)
           
static CommandProcessor getInstance()
          This is a singleton class.
 java.lang.String getRedoLabel(Context context)
           
 java.lang.String getUndoLabel(Context context)
           
 int getUndoStackSize()
          Get the current value of the undo stack size.
 int invoke(Command cmd)
          Executes the actions associated with a specific command.
 int redo()
          Redo the last undone command.
 void setUndoStackSize(int size)
          Set the current value of the undo stack size.
 int undo()
          Undo the last command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static CommandProcessor getInstance()
This is a singleton class. Use this methods to get at the only instance of this class. The getInstance method creates the instance if it has not yet been created.

Returns:
the only instance of the CommandProcessor

invoke

public final int invoke(Command cmd)
                 throws java.lang.Exception
Executes the actions associated with a specific command. A Controller uses this method to tell the CommandProcessor that a command should be executed.

Parameters:
cmd - the command to execute.
Throws:
java.lang.Exception

undo

public final int undo()
               throws java.lang.Exception
Undo the last command. This method should only be used by the Undo command.

Throws:
java.lang.Exception

redo

public final int redo()
               throws java.lang.Exception
Redo the last undone command. This method should only be used by the redo command.

Throws:
java.lang.Exception

getUndoStackSize

public final int getUndoStackSize()
Get the current value of the undo stack size. The larger the undo stack the more commands that can be undone.

Returns:
the currently set undo stack size.

setUndoStackSize

public final void setUndoStackSize(int size)
Set the current value of the undo stack size. The larger the undo stack the more commands that can be undone.

Parameters:
size - the size of the undo stack.

createCommand

public final Command createCommand(java.lang.String cmd,
                                   Context context)
Creates and instance of the specified command. The data specified is maintained by the newly created command. Returns null if command instance cannot be created.

Parameters:
cmd - the class name of the command, i.e., oracle.jdeveloper.cmd.CutCommand
context - the context to be associated with the command. This object is stored within the command an can be accessed later.
Returns:
the newly created command.

canUndo

public boolean canUndo(Context context)
Check if the last command can be undone. This method should only be used by the undo command.

Returns:
true if the last command can be undone.

getUndoLabel

public java.lang.String getUndoLabel(Context context)

getCommand

public Command getCommand(Context context)
Returns:
The Command the is to be undone

canRedo

public boolean canRedo(Context context)
Check if the last undone command can be redone. This method should only be used by the redo command.

Returns:
true if the last command can be redone.

getRedoLabel

public java.lang.String getRedoLabel(Context context)

flush

public void flush(java.lang.Object object)
Flush the undo stack associated with the specified object.


flush

public void flush(java.lang.Object[] objects)
Flush the undo stack of all the specified objects.


Extension SDK

 

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