org.eclipse.emf.workspace
Class EMFOperationCommand

java.lang.Object
  extended byorg.eclipse.emf.workspace.EMFOperationCommand

public class EMFOperationCommand
extends Object

An implementation of the EMF Command API that wraps an IUndoableOperation. It is particularly useful for returning triggers from a ResourceSetListener that perform non-EMF changes. An EMFOperationCommand, when executed, automatically inserts itself into the change description of the active transaction to support the inclusion of these non-EMF changes in:


Constructor Summary
EMFOperationCommand(TransactionalEditingDomain domain, org.eclipse.core.commands.operations.IUndoableOperation operation)
          Initializes me with the undoable operation that I wrap.
EMFOperationCommand(TransactionalEditingDomain domain, org.eclipse.core.commands.operations.IUndoableOperation operation, org.eclipse.core.runtime.IAdaptable adaptable)
          Initializes me with the undoable operation that I wrap and an adaptable to pass to it when I execute/undo/redo.
 
Method Summary
 boolean canExecute()
          I can execute if my wrapped operation can execute.
 boolean canRedo()
          I can redo if my wrapped operation can redo.
 boolean canUndo()
          I can undo if my wrapped operation can undo.
 org.eclipse.emf.common.command.Command chain(org.eclipse.emf.common.command.Command command)
           
 void dispose()
          Forgets my operation and the adaptable with which I was initialized, if any.
 void execute()
          Executes my wrapped operation and inserts it into the active transaction's change description for rollback and undo/redo support.
 Collection getAffectedObjects()
          Obtains the affected objects from my wrapped operation, if it is an IAdvancedUndoableOperation.
 String getDescription()
          My description is my wrapped operation's label.
 String getLabel()
          My label is my wrapped operation's label.
 Collection getResult()
           
 void redo()
          I redo my wrapped operation.
 void undo()
          I undo my wrapped operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EMFOperationCommand

public EMFOperationCommand(TransactionalEditingDomain domain,
                           org.eclipse.core.commands.operations.IUndoableOperation operation)
Initializes me with the undoable operation that I wrap.

Parameters:
domain - the editing domain in which I will be executed
operation - my operation
Throws:
IllegalArgumentException - if either the domain or operation is null

EMFOperationCommand

public EMFOperationCommand(TransactionalEditingDomain domain,
                           org.eclipse.core.commands.operations.IUndoableOperation operation,
                           org.eclipse.core.runtime.IAdaptable adaptable)
Initializes me with the undoable operation that I wrap and an adaptable to pass to it when I execute/undo/redo.

Parameters:
domain - the editing domain in which I will be executed
operation - my operation
adaptable - the adaptable to provide UI context to the operation
Throws:
IllegalArgumentException - if either the domain or operation is null
Method Detail

canExecute

public boolean canExecute()
I can execute if my wrapped operation can execute.


execute

public void execute()
Executes my wrapped operation and inserts it into the active transaction's change description for rollback and undo/redo support.

Throws:
IllegalStateException - if I am being executed outside of a read/write transaction context

canUndo

public boolean canUndo()
I can undo if my wrapped operation can undo.


undo

public void undo()
I undo my wrapped operation. If an adaptable was initially provided to me and it is still available, then it is passed along to the operation.

Throws:
IllegalStateException - if I am being undone outside of a read/write transaction context

canRedo

public boolean canRedo()
I can redo if my wrapped operation can redo.


redo

public void redo()
I redo my wrapped operation. If an adaptable was initially provided to me and it is still available, then it is passed along to the operation.

Throws:
IllegalStateException - if I am being redone outside of a read/write transaction context

getResult

public Collection getResult()

getAffectedObjects

public Collection getAffectedObjects()
Obtains the affected objects from my wrapped operation, if it is an IAdvancedUndoableOperation.


getLabel

public String getLabel()
My label is my wrapped operation's label.


getDescription

public String getDescription()
My description is my wrapped operation's label.


dispose

public void dispose()
Forgets my operation and the adaptable with which I was initialized, if any.


chain

public org.eclipse.emf.common.command.Command chain(org.eclipse.emf.common.command.Command command)

Copyright 2002, 2006 IBM Corporation and others.
All Rights Reserved.