org.eclipse.emf.ecore.change.util
Class ChangeRecorder

java.lang.Object
  extended by org.eclipse.emf.ecore.change.util.ListDifferenceAnalyzer
      extended by org.eclipse.emf.ecore.change.util.BasicChangeRecorder
          extended by org.eclipse.emf.ecore.change.util.ChangeRecorder
All Implemented Interfaces:
Adapter, Adapter.Internal

public class ChangeRecorder
extends BasicChangeRecorder
implements Adapter.Internal

A change recorder for the tree contents of a collection of EObjects. It monitors the specified objects and then produces a change model representing the changes needed to reverse (undo) all the model changes made while recording.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
Adapter.Internal
 
Field Summary
protected  boolean loadingTargets
           
protected  java.util.List<Notifier> originalTargetObjects
           
protected  boolean resolveProxies
           
protected  java.util.List<Notifier> targetObjects
           
 
Fields inherited from class org.eclipse.emf.ecore.change.util.BasicChangeRecorder
changeDescription, recording
 
Constructor Summary
ChangeRecorder()
           
ChangeRecorder(java.util.Collection<?> rootObjects)
           
ChangeRecorder(EObject rootObject)
           
ChangeRecorder(Resource resource)
           
ChangeRecorder(ResourceSet resourceSet)
           
 
Method Summary
protected  void addAdapter(Notifier notifier)
           
 void beginRecording(ChangeDescription changeDescription, java.util.Collection<?> rootObjects)
          Begins recording any changes made to the elements of the specified collection, adding the changes to and existing ChangeDescription.
 void beginRecording(java.util.Collection<?> rootObjects)
          Begins recording any changes made to the elements of the specified collection.
protected  void consolidateChanges()
          Consolidates the changes that have happen since the last consolidation.
 void dispose()
          Disposes this change recorder.
 Notifier getTarget()
          Returns the target from which the adapter receives notification.
protected  void handleFeature(EStructuralFeature feature, EReference containment, Notification notification, EObject eObject)
           
protected  void handleResource(Notification notification)
           
 boolean isAdapterForType(java.lang.Object type)
          Returns whether the adapter is of the given type.
protected  boolean isOrphan(EObject eObject)
           
 boolean isResolveProxies()
           
 void notifyChanged(Notification notification)
          Notifies that a change to some feature has occurred.
protected  void prepareChangeDescriptionForResume()
          Prepares this ChangeRecorder's BasicChangeRecorder.changeDescription for the scenarios where the user is resuming a previous recording.
protected  void removeAdapter(Notifier notifier)
           
 void setResolveProxies(boolean resolveProxies)
           
 void setTarget(Notifier target)
          Handles installation of the adapter by adding the adapter to each of the directly contained objects.
protected  boolean shouldRecord(EStructuralFeature feature, EReference containment, Notification notification, EObject eObject)
           
 void unsetTarget(Notifier oldTarget)
          Unsets the target from which the adapter will receive notification.
 
Methods inherited from class org.eclipse.emf.ecore.change.util.BasicChangeRecorder
createChangeDescription, createFeatureChange, createResourceChange, eliminateEmptyChanges, endRecording, finalizeChange, finalizeChange, getChangeDescription, getFeatureChange, getFeatureChanges, getResourceChange, getResourceChanges, isRecording, setChangeDescription, setRecording, shouldRecord, summarize
 
Methods inherited from class org.eclipse.emf.ecore.change.util.ListDifferenceAnalyzer
analyzeLists, analyzeLists, createAddListChange, createListChange, createListChanges, createMoveListChange, createRemoveListChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetObjects

protected java.util.List<Notifier> targetObjects

originalTargetObjects

protected java.util.List<Notifier> originalTargetObjects

loadingTargets

protected boolean loadingTargets

resolveProxies

protected boolean resolveProxies
Constructor Detail

ChangeRecorder

public ChangeRecorder()

ChangeRecorder

public ChangeRecorder(EObject rootObject)

ChangeRecorder

public ChangeRecorder(Resource resource)

ChangeRecorder

public ChangeRecorder(ResourceSet resourceSet)

ChangeRecorder

public ChangeRecorder(java.util.Collection<?> rootObjects)
Method Detail

isResolveProxies

public boolean isResolveProxies()

setResolveProxies

public void setResolveProxies(boolean resolveProxies)

dispose

public void dispose()
Description copied from class: BasicChangeRecorder
Disposes this change recorder. This method ends a recording without consolidating the changes.

Overrides:
dispose in class BasicChangeRecorder

removeAdapter

protected void removeAdapter(Notifier notifier)

beginRecording

public void beginRecording(java.util.Collection<?> rootObjects)
Begins recording any changes made to the elements of the specified collection.

Parameters:
rootObjects - A collection of instances of Notifier

beginRecording

public void beginRecording(ChangeDescription changeDescription,
                           java.util.Collection<?> rootObjects)
Begins recording any changes made to the elements of the specified collection, adding the changes to and existing ChangeDescription. This allows clients to resume a previous recording.

Unpredictable (and probably bad) results may happen if the change description is inconsistent with the current state of the application.

Parameters:
changeDescription - A change description with changes made during a previous recording or null if a new change description should be instantiated.
rootObjects - A collection of instances of Notifier
Since:
2.1.0

prepareChangeDescriptionForResume

protected void prepareChangeDescriptionForResume()
Prepares this ChangeRecorder's BasicChangeRecorder.changeDescription for the scenarios where the user is resuming a previous recording.

Since:
2.1.0
See Also:
beginRecording(ChangeDescription, Collection)

consolidateChanges

protected void consolidateChanges()
Description copied from class: BasicChangeRecorder
Consolidates the changes that have happen since the last consolidation.

Overrides:
consolidateChanges in class BasicChangeRecorder

isOrphan

protected boolean isOrphan(EObject eObject)

notifyChanged

public void notifyChanged(Notification notification)
Description copied from interface: Adapter
Notifies that a change to some feature has occurred.

Specified by:
notifyChanged in interface Adapter
Parameters:
notification - a description of the change.

shouldRecord

protected boolean shouldRecord(EStructuralFeature feature,
                               EReference containment,
                               Notification notification,
                               EObject eObject)

handleFeature

protected void handleFeature(EStructuralFeature feature,
                             EReference containment,
                             Notification notification,
                             EObject eObject)

handleResource

protected void handleResource(Notification notification)

setTarget

public void setTarget(Notifier target)
Handles installation of the adapter by adding the adapter to each of the directly contained objects.

Specified by:
setTarget in interface Adapter
Parameters:
target - the new notifier.
See Also:
Adapter.getTarget()

unsetTarget

public void unsetTarget(Notifier oldTarget)
Description copied from interface: Adapter.Internal
Unsets the target from which the adapter will receive notification. This method is only to be called by a notifier when this adapter is removed from its adapter list. In general, an adapter may be shared by more than one notifier, so this mechanism allows the adapter to know specifically which notifier will no longer be notifying.

Specified by:
unsetTarget in interface Adapter.Internal
Parameters:
oldTarget - the old notifier.
See Also:
Adapter.getTarget(), Adapter.setTarget(Notifier)

addAdapter

protected void addAdapter(Notifier notifier)

getTarget

public Notifier getTarget()
Description copied from interface: Adapter
Returns the target from which the adapter receives notification. In general, an adapter may be shared by more than one notifier.

Specified by:
getTarget in interface Adapter
Returns:
the target notifier.
See Also:
Adapter.setTarget(org.eclipse.emf.common.notify.Notifier)

isAdapterForType

public boolean isAdapterForType(java.lang.Object type)
Description copied from interface: Adapter
Returns whether the adapter is of the given type. In general, an adapter may be the adapter for many types.

Specified by:
isAdapterForType in interface Adapter
Parameters:
type - the type.
Returns:
whether the adapter is of the given type.
See Also:
AdapterFactory.isFactoryForType(java.lang.Object)

Copyright 2001-2006 IBM Corporation and others.
All Rights Reserved.