Skip navigation links

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

E13403-06


oracle.ide.controller
Class CommandProcessor

java.lang.Object
  extended by oracle.ide.controller.CommandProcessor

All Implemented Interfaces:
Observer

public final class CommandProcessor
extends java.lang.Object
implements Observer

The CommandProcessor singleton class is responsible for managing the execution of the IDE commands and managing the undo stack.

In general, all controller implementations should use the IDE command processor to execute the commands that controller handles. For example, the Navigator controller uses the IdeCommandProcessor) to handle its commands. Since Command implementations may involve Swing interaction, all operations upon CommandProcessor must be made using the event thread.

See Also:
Command, Controller, Ide

Method Summary
 void abortTrans()
          Abort a multi Command batch operation, calling undo on any Command instances already invoked as part of the current batch operation.
 void beginTrans(java.lang.String label)
          Begin a multi Command batch operation.
 boolean canRedo(Context context)
          Check if the last Command associated with the Node of the given Context can be redone.
 boolean canUndo(Context context)
          Check if the last Command associated with the Node of the given Context can be undone.
static Command createCommand(java.lang.String cmd, Context context)
          Creates and instance of the specified command.
static Command createCommandFromMeta(MetaClass commandMeta, Context context)
           
 void endTrans()
          Commit a multi Command batch operation.
 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)
          Get the name of the last redoable Command associated with the Node of the given Context.
 java.lang.String getUndoLabel(Context context)
          Get the name of the last undoable Command associated with the Node of the given Context.
 int invoke(Command cmd)
          Executes the actions associated with a specific command.
 boolean isTransactionActive()
           
 int redo(Context context)
          Redo the last Command associated with the Node of the given Context.
 int undo(Context context)
          Undo the last Command associated with the Node of the given Context.
 void update(java.lang.Object observed, UpdateMessage change)
          Respond to applicable UpdateMessages.

 

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(Context context)
               throws java.lang.Exception
Undo the last Command associated with the Node of the given Context. If the Node of the given Context is null, then Command.CANCEL will be returned. If the given Context itself is null, then an attempt will be made to undo the last global Command.
Parameters:
context - a Context describing a Node, else null.
Returns:
oracle.ide.addin.Command.OK on success, oracle.ide.addin.Command on failure.
Throws:
java.lang.Exception

redo

public final int redo(Context context)
               throws java.lang.Exception
Redo the last Command associated with the Node of the given Context. If the Node of the given Context is null, then Command.CANCEL will be returned. If the given Context itself is null, then an attempt will be made to redo the last global Command.
Parameters:
context - a Context describing a Node, else null.
Returns:
oracle.ide.addin.Command.OK on success, oracle.ide.addin.Command on failure.
Throws:
java.lang.Exception

canUndo

public boolean canUndo(Context context)
Check if the last Command associated with the Node of the given Context can be undone. If the Node of the given Context is null, then false will be returned. If the given Context itself is null, then a check will be done to see if the last global Command can be undone.
Parameters:
context - a Context describing a Node, else null.
Returns:
true if the last applicable Command can be undone.

getUndoLabel

public java.lang.String getUndoLabel(Context context)
Get the name of the last undoable Command associated with the Node of the given Context. If the Node of the given Context is null, then null will be returned. If the given Context itself is null, then the name of the last undoable global Command will be returned.
Parameters:
context - a Context describing a Node, else null.
Returns:
The name of the last applicable Command available for undo.

getCommand

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

canRedo

public boolean canRedo(Context context)
Check if the last Command associated with the Node of the given Context can be redone. If the Node of the given Context is null, then false will be returned. If the given Context itself is null, then a check will be done to see if the last global Command can be redone.
Parameters:
context - a Context describing a Node, else null.
Returns:
true if the last applicable Command can be redone.

getRedoLabel

public java.lang.String getRedoLabel(Context context)
Get the name of the last redoable Command associated with the Node of the given Context. If the Node of the given Context is null, then null will be returned. If the given Context itself is null, then the name of the last redoable global Command will be returned.
Parameters:
context - a Context describing a Node, else null.
Returns:
The name of the last applicable Command available for redo.

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.

beginTrans

public void beginTrans(java.lang.String label)
Begin a multi Command batch operation. All calls to invoke occuring between a preceding call to beginTrans and a succeding call to endTrans will be treated as parts of a single undoable operation.
Parameters:
label - summary label for use in undo/redo menu item.

endTrans

public void endTrans()
Commit a multi Command batch operation. All calls to invoke occuring between a preceding call to beginTrans and a succeding call to endTrans will be treated as parts of a single undoable operation.

abortTrans

public void abortTrans()
Abort a multi Command batch operation, calling undo on any Command instances already invoked as part of the current batch operation.

isTransactionActive

public boolean isTransactionActive()

update

public void update(java.lang.Object observed,
                   UpdateMessage change)
Respond to applicable UpdateMessages.
Specified by:
update in interface Observer
Parameters:
observed - the subject whose state has changed.
change - what has changed.

createCommand

public static 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.

createCommandFromMeta

public static Command createCommandFromMeta(MetaClass commandMeta,
                                            Context context)

Skip navigation links

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

E13403-06


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