org.eclipse.emf.emfstore.internal.client.model.impl
Class OperationManager

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.impl.OperationManager
All Implemented Interfaces:
ESCommandObserver, ESObserver, OperationRecorderListener, ESDisposable, IdEObjectCollectionChangeObserver

public class OperationManager
extends Object
implements OperationRecorderListener, ESDisposable, ESCommandObserver, IdEObjectCollectionChangeObserver

This class acts as a simple wrapper around the operation recorder and provides convenience methods for undoing operations and handling composite operations.

Author:
koegel, emueller

Constructor Summary
OperationManager(ProjectSpaceBase projectSpace)
          Constructor.
 
Method Summary
 void abortCompositeOperation()
          Aborts the current composite operation.
 void addOperationObserver(OperationObserver operationObserver)
          Adds an operation observer that gets notified whenever an operation is either executed or undone.
 CompositeOperationHandle beginCompositeOperation()
          Opens up a handle for creating a composite operation.
 List<AbstractOperation> clearOperations()
          Clears all recorded operations.
 void collectionDeleted(IdEObjectCollection collection)
          If the IdEObjectCollection is deleted.
 void commandCompleted(org.eclipse.emf.common.command.Command command)
          Called to notify listener about the successful completion of the given command.
 void commandCompleted(org.eclipse.emf.common.command.Command command, boolean isNestedCommand)
          Notifies the manager that a command has been completed.
 void commandFailed(org.eclipse.emf.common.command.Command command, Exception exception)
          Called to notify listener about the failure of the given command.
 void commandStarted(org.eclipse.emf.common.command.Command command)
          Called to notify listener about the start of the given command.
 void dispose()
          Marker method for classes that need to perform clean-up tasks.
 void endCompositeOperation()
          Complete the current composite operation.
 void endCompositeOperation(SemanticCompositeOperation semanticCompositeOperation)
          Replace and complete the current composite operation.
 NotificationRecorder getNotificationRecorder()
          Returns the notification recorder.
 OperationRecorderConfig getRecorderConfig()
          Returns the configuration options for the operation recorder.
 boolean isCommandRunning()
          Whether the operation manager considers a command is being run.
 void modelElementAdded(IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
          Called when the eObject has been added to the collection.
 void modelElementRemoved(IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
          Called when the eObject and its siblings have been removed from the collection.
 void notify(org.eclipse.emf.common.notify.Notification notification, IdEObjectCollection collection, org.eclipse.emf.ecore.EObject modelElement)
          A notification on a model element of the collection occurred.
 void notifyOperationUndone(AbstractOperation operation)
          Notifies all operations observer that an operation has been undone.
 void operationsRecorded(List<? extends AbstractOperation> operations)
          Notify observer about recorded operations.
 void removeOperationListener(OperationObserver operationObserver)
          Removed the given operation observer from the list of operation observers.
 void startChangeRecording()
          Starts change recording.
 void stopChangeRecording()
          Stops change recording.
 void undoLastOperation()
          Undo the last operation of the projectSpace.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OperationManager

public OperationManager(ProjectSpaceBase projectSpace)
Constructor.

Parameters:
projectSpace - the project space the operation manager should be attached to
Method Detail

undoLastOperation

public void undoLastOperation()
Undo the last operation of the projectSpace.


addOperationObserver

public void addOperationObserver(OperationObserver operationObserver)
Adds an operation observer that gets notified whenever an operation is either executed or undone.

Parameters:
operationObserver - the operation observer to be added

removeOperationListener

public void removeOperationListener(OperationObserver operationObserver)
Removed the given operation observer from the list of operation observers.

Parameters:
operationObserver - the operation observer to be removed

notifyOperationUndone

public void notifyOperationUndone(AbstractOperation operation)
Notifies all operations observer that an operation has been undone.

Parameters:
operation - the operation that has been undone

abortCompositeOperation

public void abortCompositeOperation()
Aborts the current composite operation.


endCompositeOperation

public void endCompositeOperation()
Complete the current composite operation.


endCompositeOperation

public void endCompositeOperation(SemanticCompositeOperation semanticCompositeOperation)
Replace and complete the current composite operation.

Parameters:
semanticCompositeOperation - the semantic operation that replaces the composite operation

beginCompositeOperation

public CompositeOperationHandle beginCompositeOperation()
Opens up a handle for creating a composite operation.

Returns:
the handle for the composite operation

operationsRecorded

public void operationsRecorded(List<? extends AbstractOperation> operations)
Notify observer about recorded operations.

Specified by:
operationsRecorded in interface OperationRecorderListener
Parameters:
operations - a list of operations
See Also:
OperationRecorderListener.operationsRecorded(java.util.List)

clearOperations

public List<AbstractOperation> clearOperations()
Clears all recorded operations.

Returns:
the cleared operations

dispose

public void dispose()
Marker method for classes that need to perform clean-up tasks.

Specified by:
dispose in interface ESDisposable
See Also:
ESDisposable.dispose()

getNotificationRecorder

public NotificationRecorder getNotificationRecorder()
Returns the notification recorder.

Returns:
the notification recorder

commandStarted

public void commandStarted(org.eclipse.emf.common.command.Command command)
Called to notify listener about the start of the given command.

Specified by:
commandStarted in interface ESCommandObserver
Parameters:
command - the command
See Also:
ESCommandObserver.commandStarted(org.eclipse.emf.common.command.Command)

commandCompleted

public void commandCompleted(org.eclipse.emf.common.command.Command command)
Called to notify listener about the successful completion of the given command.

Specified by:
commandCompleted in interface ESCommandObserver
Parameters:
command - the command
See Also:
ESCommandObserver.commandCompleted(org.eclipse.emf.common.command.Command)

commandFailed

public void commandFailed(org.eclipse.emf.common.command.Command command,
                          Exception exception)
Called to notify listener about the failure of the given command.

Specified by:
commandFailed in interface ESCommandObserver
Parameters:
command - the command
exception - the exception that occurred
See Also:
ESCommandObserver.commandFailed(org.eclipse.emf.common.command.Command, java.lang.Exception)

notify

public void notify(org.eclipse.emf.common.notify.Notification notification,
                   IdEObjectCollection collection,
                   org.eclipse.emf.ecore.EObject modelElement)
A notification on a model element of the collection occurred. See Notification documentation for details on the notifications. This method will be called even if the given notification results from an add or remove of a model element of the project.

Specified by:
notify in interface IdEObjectCollectionChangeObserver
Parameters:
notification - the notification
collection - the collection holding the modelElement
modelElement - the model element the notification originates from
See Also:
IdEObjectCollectionChangeObserver.notify(org.eclipse.emf.common.notify.Notification, org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection, org.eclipse.emf.ecore.EObject)

modelElementAdded

public void modelElementAdded(IdEObjectCollection collection,
                              org.eclipse.emf.ecore.EObject modelElement)
Called when the eObject has been added to the collection.

Specified by:
modelElementAdded in interface IdEObjectCollectionChangeObserver
Parameters:
collection - the IdEObjectCollection to which the eObject was added
modelElement - the EObject that has been added to the collection
See Also:
IdEObjectCollectionChangeObserver.modelElementAdded(org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection, org.eclipse.emf.ecore.EObject)

modelElementRemoved

public void modelElementRemoved(IdEObjectCollection collection,
                                org.eclipse.emf.ecore.EObject modelElement)
Called when the eObject and its siblings have been removed from the collection. NOTE: Note that you will NOT receive a separate notification for each sibling.

Specified by:
modelElementRemoved in interface IdEObjectCollectionChangeObserver
Parameters:
collection - the IdEObjectCollection to which the eObject was added
modelElement - the EObject that has been added to the collection
See Also:
IdEObjectCollectionChangeObserver.modelElementRemoved(org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection, org.eclipse.emf.ecore.EObject)

collectionDeleted

public void collectionDeleted(IdEObjectCollection collection)
If the IdEObjectCollection is deleted.

Specified by:
collectionDeleted in interface IdEObjectCollectionChangeObserver
Parameters:
collection - the IdEObjectCollection that has been deleted
See Also:
IdEObjectCollectionChangeObserver.collectionDeleted(org.eclipse.emf.emfstore.internal.common.model.IdEObjectCollection)

startChangeRecording

public void startChangeRecording()
Starts change recording.


stopChangeRecording

public void stopChangeRecording()
Stops change recording.


getRecorderConfig

public OperationRecorderConfig getRecorderConfig()
Returns the configuration options for the operation recorder.

Returns:
the operation recorder configuration options

commandCompleted

public void commandCompleted(org.eclipse.emf.common.command.Command command,
                             boolean isNestedCommand)
Notifies the manager that a command has been completed.

Parameters:
command - the Command that has been completed
isNestedCommand - whether the completed command is a command inside another one. If the completed command is nested, the OperationRecorder's internal state maintains the state of a command still being run

isCommandRunning

public boolean isCommandRunning()
Whether the operation manager considers a command is being run.

Returns:
true if a command is being run, false otherwise


Copyright © 2015. All Rights Reserved.