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

java.lang.Object
  extended by org.eclipse.emf.emfstore.internal.client.model.impl.OperationRecorder
All Implemented Interfaces:
ESCommandObserver, ESCommitObserver, ESShareObserver, ESUpdateObserver, ESObserver, IdEObjectCollectionChangeObserver

public class OperationRecorder
extends Object
implements ESCommandObserver, ESCommitObserver, ESUpdateObserver, ESShareObserver, IdEObjectCollectionChangeObserver

Tracks changes on any given IdEObjectCollection.

Author:
koegel, emueller

Field Summary
static String UNKOWN_CREATOR
          Name of unknown creator.
 
Constructor Summary
OperationRecorder(ProjectSpaceBase projectSpace)
          Constructor.
 
Method Summary
 void abortCompositeOperation()
          Aborts the current composite operation.
 void addOperationRecorderListener(OperationRecorderListener observer)
          Adds an operation recorder observer.
 CompositeOperationHandle beginCompositeOperation()
          Begins a composite operation.
 List<AbstractOperation> clearOperations()
          Clears the operations list.
 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)
          Called to notify listener about the successful completion of the given command.
 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 commitCompleted(ESLocalProject project, ESPrimaryVersionSpec newRevision, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called after the commit is completed.
 void endCompositeOperation()
          Complete the current composite operation.
 void endCompositeOperation(SemanticCompositeOperation semanticCompositeOperation)
          Replace and complete the current composite operation.
 IdEObjectCollection getCollection()
          Returns the collection the operation recorder is operation on.
 CompositeOperation getCompositeOperation()
          Returns the composite operation.
 OperationRecorderConfig getConfig()
          Returns the configuration options for the operation recorder.
 NotificationRecorder getNotificationRecorder()
          Returns the notification recorder of the project space.
 ProjectSpace getProjectSpace()
          Returns the project space this operation recorder is attached to.
 boolean inspectChanges(ESLocalProject project, ESChangePackage changePackage, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called before the commit proceeds.
 boolean inspectChanges(ESLocalProject project, List<ESChangePackage> changePackages, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called to notify the observer about the changes that will be merged into the project space.
 boolean isCommandRunning()
          Whether the operation recorder considers a command is being run.
 void modelElementAdded(IdEObjectCollection project, org.eclipse.emf.ecore.EObject modelElement)
          Called when the eObject has been added to the collection.
 void modelElementRemoved(IdEObjectCollection project, 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 removeOperationRecorderListener(OperationRecorderListener observer)
          Removes an operation recorder observer.
 void shareDone(ESLocalProject localProject)
          Called when the share of the passed ESLocalProject completed successfully.
 void startChangeRecording()
          Starts change recording on this workspace, resumes previous recordings if there are any.
 void stopChangeRecording()
          Stops current recording of changes and adds recorded changes to this project spaces changes.
 void updateCompleted(ESLocalProject project, org.eclipse.core.runtime.IProgressMonitor monitor)
          Called after the changes have been applied to the project and the update is completed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKOWN_CREATOR

public static final String UNKOWN_CREATOR
Name of unknown creator.

Constructor Detail

OperationRecorder

public OperationRecorder(ProjectSpaceBase projectSpace)
Constructor.

Parameters:
projectSpace - the ProjectSpaceBase the recorder should be attached to
Method Detail

clearOperations

public List<AbstractOperation> clearOperations()
Clears the operations list.

Returns:
the list of cleared operations

getConfig

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

Returns:
the operation recorder configuration options

getCollection

public IdEObjectCollection getCollection()
Returns the collection the operation recorder is operation on.

Returns:
the collection the operation recorder is operation on

modelElementAdded

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

Specified by:
modelElementAdded in interface IdEObjectCollectionChangeObserver
Parameters:
project - 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)

addOperationRecorderListener

public void addOperationRecorderListener(OperationRecorderListener observer)
Adds an operation recorder observer.

Parameters:
observer - the observer to be added

removeOperationRecorderListener

public void removeOperationRecorderListener(OperationRecorderListener observer)
Removes an operation recorder observer.

Parameters:
observer - the observer to be removed

startChangeRecording

public void startChangeRecording()
Starts change recording on this workspace, resumes previous recordings if there are any.


stopChangeRecording

public void stopChangeRecording()
Stops current recording of changes and adds recorded changes to this project spaces changes.


getNotificationRecorder

public NotificationRecorder getNotificationRecorder()
Returns the notification recorder of the project space.

Returns:
the notification recorder

modelElementRemoved

public void modelElementRemoved(IdEObjectCollection project,
                                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:
project - 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)

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)

commandCompleted

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

Parameters:
command - the completed command
isNestedCommand - whether the completed command is a command inside another one

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)

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)

getCompositeOperation

public CompositeOperation getCompositeOperation()
Returns the composite operation.

Returns:
the composite operation

beginCompositeOperation

public CompositeOperationHandle beginCompositeOperation()
Begins a composite operation.

Returns:
the handle to the newly created 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

endCompositeOperation

public void endCompositeOperation()
Complete the current composite operation.


abortCompositeOperation

public void abortCompositeOperation()
Aborts the current composite operation.


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)

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)

getProjectSpace

public ProjectSpace getProjectSpace()
Returns the project space this operation recorder is attached to.

Returns:
the project space this operation recorder is attached to

inspectChanges

public boolean inspectChanges(ESLocalProject project,
                              List<ESChangePackage> changePackages,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
Called to notify the observer about the changes that will be merged into the project space.

Specified by:
inspectChanges in interface ESUpdateObserver
Parameters:
project - the ESLocalProject that should be updated
changePackages - a list of ESChangePackages containing the update changes
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
Returns:
false if the observer wants to cancel the update, true otherwise
See Also:
ESUpdateObserver.inspectChanges(org.eclipse.emf.emfstore.client.ESLocalProject, java.util.List, org.eclipse.core.runtime.IProgressMonitor)

inspectChanges

public boolean inspectChanges(ESLocalProject project,
                              ESChangePackage changePackage,
                              org.eclipse.core.runtime.IProgressMonitor monitor)
Called before the commit proceeds. A callback method to initiate the commit dialog and allow the user to confirm the changes.

Specified by:
inspectChanges in interface ESCommitObserver
Parameters:
project - the project the commit occurs on
changePackage - the ESChangePackage
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
Returns:
true if the changes have been confirmed, false - otherwise.
See Also:
ESCommitObserver.inspectChanges(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.emf.emfstore.server.model.ESChangePackage, org.eclipse.core.runtime.IProgressMonitor)

updateCompleted

public void updateCompleted(ESLocalProject project,
                            org.eclipse.core.runtime.IProgressMonitor monitor)
Called after the changes have been applied to the project and the update is completed.

Specified by:
updateCompleted in interface ESUpdateObserver
Parameters:
project - the ESLocalProject whose update has been completed
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
See Also:
ESUpdateObserver.updateCompleted(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.core.runtime.IProgressMonitor)

shareDone

public void shareDone(ESLocalProject localProject)
Called when the share of the passed ESLocalProject completed successfully.

Specified by:
shareDone in interface ESShareObserver
Parameters:
localProject - the local project that has been shared
See Also:
ESShareObserver.shareDone(org.eclipse.emf.emfstore.client.ESLocalProject)

commitCompleted

public void commitCompleted(ESLocalProject project,
                            ESPrimaryVersionSpec newRevision,
                            org.eclipse.core.runtime.IProgressMonitor monitor)
Called after the commit is completed.

Specified by:
commitCompleted in interface ESCommitObserver
Parameters:
project - the project on which the commit has completed
newRevision - the new revision that was created by the commit
monitor - an IProgressMonitor instance that may be used by clients to inform about progress
See Also:
ESCommitObserver.commitCompleted(org.eclipse.emf.emfstore.client.ESLocalProject, org.eclipse.emf.emfstore.server.model.versionspec.ESPrimaryVersionSpec, org.eclipse.core.runtime.IProgressMonitor)

isCommandRunning

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

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


Copyright © 2015. All Rights Reserved.