public class DeltaResolver
extends java.lang.Object
implements java.beans.PropertyChangeListener
DeltaResolver
is responsible for creating a merged resource
then maintaining its integrity by accepting requests to accept and reject
deltas.Modifier and Type | Class and Description |
---|---|
protected static class |
DeltaResolver.SilentGroup
Helper class to group deltas for silent merge
|
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.emf.ecore.resource.Resource |
base |
protected java.util.List |
conflicts |
protected DeltaContainer[] |
contributorDeltas |
protected IContributorProvider |
contributorProvider |
protected org.eclipse.emf.ecore.resource.Resource[] |
contributors |
protected EntriesTable |
featureToIndexListTable |
protected com.ibm.xtools.comparemerge.emf.delta.deltagenerator.matcher.Matcher |
matcher |
protected boolean |
outOfBoundsRecoveryEnable |
protected java.beans.PropertyChangeSupport |
propertyChangeSupport |
protected ResourceModifier |
resourceModifier |
protected SilentMergeOptions |
silentMergeOptions |
static boolean |
TRACE_INDEX_OUT_OF_BOUNDS |
protected int |
unresolvedConflictCount |
protected int |
unresolvedDeltaCount |
Constructor and Description |
---|
DeltaResolver() |
Modifier and Type | Method and Description |
---|---|
protected Resolution |
accept(Delta delta) |
protected void |
acceptAllNonconflictingDeltas()
Apply all the non-conflicting deltas to the merged resource.
|
protected void |
addDestinationContainer(org.eclipse.emf.ecore.resource.Resource resource,
Location destinationLocation,
Delta delta)
Adds a suitable destination container in the base resource.
|
protected void |
addIds(org.eclipse.emf.ecore.EObject value,
ChangeDelta changeDelta)
Add IDs for copied EObject which are used in change deltas
TODO: Test in the context of logical merge
|
protected void |
addIds(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.xmi.XMLResource xmlResource,
ListDelta listDelta) |
void |
addObject(ListDelta listDelta) |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a property change listener that may be interested in
Delta.RESOLVED_PROPERTY and/or Conflict.RESOLVED_PROPERTY change events.
|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a property change listener that may be interested in
Delta.RESOLVED_PROPERTY or Conflict.RESOLVED_PROPERTY change events.
|
void |
apply(Resolution resolution) |
protected org.eclipse.emf.ecore.EObject |
applyMorfDelta(MorphDelta delta)
Object morphing is metamodel specific - should be overridden by subclasses
|
void |
changeObject(ChangeDelta changeDelta,
boolean isSet,
java.lang.Object changeValue) |
protected void |
combine(DeltaResolver.SilentGroup group,
java.util.Set<Delta> leftDeltas,
java.util.Set<Delta> rightDeltas)
Split deltas into groups for silent merge
|
protected org.eclipse.emf.ecore.EAnnotation |
createEAnnotation(java.lang.String source) |
protected void |
deleteIds(org.eclipse.emf.ecore.EObject eObject,
org.eclipse.emf.ecore.xmi.XMLResource xmlResource,
ListDelta listDelta) |
void |
deleteObject(ListDelta listDelta) |
protected void |
deleteSourceContainer(Location sourceLocation)
Delete any unnecessary source container from the base resource.
|
protected org.eclipse.emf.ecore.EAnnotation |
findAnnotation(EAnnotationLocation annotationLocation,
org.eclipse.emf.ecore.resource.Resource resource) |
protected void |
findConflictingResources() |
protected org.eclipse.emf.ecore.EObject |
findEObjectInResource(org.eclipse.emf.ecore.xmi.XMLResource xmlResource,
java.lang.String id) |
org.eclipse.emf.common.command.Command |
getAcceptCommand(Delta delta)
Returns a command that will accept a delta in the merged resource.
|
protected java.util.List |
getAllDeltasWithinCollection(Location location) |
org.eclipse.emf.common.command.Command |
getApplyResolutionCommand(java.util.List<Delta> deltas,
ResolutionType type) |
int |
getCalculatedBaseIndex(ListDelta listDelta)
Return an index for a location of a delta calculated to the base resource.
|
int |
getCalculatedBaseIndex(Location location,
Delta inputDelta)
Return an index for a location of a delta calculated to the base resource.
|
int |
getCalculatedContributorIndex(ListDelta listDelta,
org.eclipse.emf.ecore.resource.Resource contributor)
Return an index for a location of a delta calculated to a contributor
resource.
|
int |
getCalculatedContributorIndex(Location location,
Delta inputDelta,
org.eclipse.emf.ecore.resource.Resource contributor)
Return an index for a location of a delta calculated to a contributor
resource.
|
int |
getCalculatedMergedIndex(ListDelta listDelta)
Return an index for a location of a delta calculated to the merged resource.
|
int |
getCalculatedMergedIndex(Location location,
Delta inputDelta)
Return an index for a location of a delta calculated to the merged resource.
|
DeltaContainer |
getDeltaContainer(org.eclipse.emf.ecore.resource.Resource contributor) |
java.util.Set |
getNonconflictingDeltas(org.eclipse.emf.ecore.resource.Resource contributor)
Return all non-conflicting deltas a contributor.
|
org.eclipse.emf.common.command.Command |
getRejectCommand(Delta delta)
Returns a command that will reject a delta in the merged resource.
|
int |
getUnresolvedConflictCount()
Returns the number of unresolved conflicts
|
int |
getUnresolvedDeltaCount()
Returns the number of unresolved deltas
|
protected void |
ignoreConflicts() |
void |
init(java.lang.String newResourceType,
com.ibm.xtools.comparemerge.emf.delta.deltagenerator.matcher.Matcher newMatcher,
org.eclipse.emf.ecore.resource.Resource newBase,
IContributorProvider provider,
java.util.List newConflicts)
Init this delta resolver with a new base and contributor resources,
contributor deltas and conflicts.
|
void |
propertyChange(java.beans.PropertyChangeEvent event) |
protected Resolution |
reject(Delta delta) |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a property change listener.
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Removes a property change listener.
|
protected void |
resolveAllAutoResolvableConflicts()
Resolve as many conflicts as possible.
|
void |
run()
Run this delta resolver.
|
void |
setResourceModifier(ResourceModifier modifier) |
void |
setSilentMergeOptions(SilentMergeOptions options) |
void |
unapply(Resolution resolution) |
protected org.eclipse.emf.ecore.EObject |
unapplyMorfDelta(MorphDelta delta)
Object morphing is metamodel specific - should be overridden by subclasses
|
public static final boolean TRACE_INDEX_OUT_OF_BOUNDS
protected com.ibm.xtools.comparemerge.emf.delta.deltagenerator.matcher.Matcher matcher
protected org.eclipse.emf.ecore.resource.Resource base
protected org.eclipse.emf.ecore.resource.Resource[] contributors
protected DeltaContainer[] contributorDeltas
protected java.util.List conflicts
protected int unresolvedDeltaCount
protected int unresolvedConflictCount
protected java.beans.PropertyChangeSupport propertyChangeSupport
protected EntriesTable featureToIndexListTable
protected ResourceModifier resourceModifier
protected boolean outOfBoundsRecoveryEnable
protected IContributorProvider contributorProvider
protected SilentMergeOptions silentMergeOptions
public void init(java.lang.String newResourceType, com.ibm.xtools.comparemerge.emf.delta.deltagenerator.matcher.Matcher newMatcher, org.eclipse.emf.ecore.resource.Resource newBase, IContributorProvider provider, java.util.List newConflicts)
newResourceType
- type of resourcesnewMatcher
- a matchernewBase
- base resourceprovider
- contributors providernewConflicts
- conflictspublic void setResourceModifier(ResourceModifier modifier)
public void run()
protected void findConflictingResources()
protected void ignoreConflicts()
public DeltaContainer getDeltaContainer(org.eclipse.emf.ecore.resource.Resource contributor)
public void apply(Resolution resolution)
protected org.eclipse.emf.ecore.EObject applyMorfDelta(MorphDelta delta)
delta
- protected org.eclipse.emf.ecore.EObject unapplyMorfDelta(MorphDelta delta)
delta
- public void unapply(Resolution resolution)
protected void combine(DeltaResolver.SilentGroup group, java.util.Set<Delta> leftDeltas, java.util.Set<Delta> rightDeltas)
group
- leftDeltas
- rightDeltas
- protected void acceptAllNonconflictingDeltas()
protected Resolution accept(Delta delta)
protected Resolution reject(Delta delta)
public java.util.Set getNonconflictingDeltas(org.eclipse.emf.ecore.resource.Resource contributor)
protected void resolveAllAutoResolvableConflicts()
public void addObject(ListDelta listDelta)
protected void addIds(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.xmi.XMLResource xmlResource, ListDelta listDelta)
protected void addDestinationContainer(org.eclipse.emf.ecore.resource.Resource resource, Location destinationLocation, Delta delta)
destinationLocation
- destinationLocationpublic void deleteObject(ListDelta listDelta)
protected void deleteIds(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.ecore.xmi.XMLResource xmlResource, ListDelta listDelta)
protected void deleteSourceContainer(Location sourceLocation)
sourceLocation
- sourceLocationpublic int getCalculatedMergedIndex(Location location, Delta inputDelta)
location
- Location containing index to calculatedinputDelta
- deltapublic int getCalculatedBaseIndex(Location location, Delta inputDelta)
location
- Location containing index to calculatedinputDelta
- deltapublic int getCalculatedContributorIndex(Location location, Delta inputDelta, org.eclipse.emf.ecore.resource.Resource contributor)
location
- Location containing index to calculatedinputDelta
- deltapublic int getCalculatedMergedIndex(ListDelta listDelta)
listDelta
- public int getCalculatedBaseIndex(ListDelta listDelta)
listDelta
- public int getCalculatedContributorIndex(ListDelta listDelta, org.eclipse.emf.ecore.resource.Resource contributor)
listDelta
- protected java.util.List getAllDeltasWithinCollection(Location location)
public void changeObject(ChangeDelta changeDelta, boolean isSet, java.lang.Object changeValue)
protected void addIds(org.eclipse.emf.ecore.EObject value, ChangeDelta changeDelta)
value
- changeDelta
- protected org.eclipse.emf.ecore.EObject findEObjectInResource(org.eclipse.emf.ecore.xmi.XMLResource xmlResource, java.lang.String id)
public org.eclipse.emf.common.command.Command getAcceptCommand(Delta delta)
delta
- a deltapublic org.eclipse.emf.common.command.Command getApplyResolutionCommand(java.util.List<Delta> deltas, ResolutionType type)
public org.eclipse.emf.common.command.Command getRejectCommand(Delta delta)
delta
- a deltapublic int getUnresolvedDeltaCount()
public int getUnresolvedConflictCount()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Delta
or a Conflict
.
The event's old and new values are always null, but can be queried with
Delta.isResolved()
and Delta.isAccepted()
or
Conflict.isResolved
.listener
- a property change listenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- a property change listenerpublic void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Delta
or a Conflict
.
The event's old and new values are always null, but can be queried with
Delta.isResolved()
and Delta.isAccepted()
or
Conflict.isResolved
.propertyName
- a property namelistener
- a property change listenerpublic void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
propertyName
- a property namelistener
- a property change listenerpublic void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
protected org.eclipse.emf.ecore.EAnnotation createEAnnotation(java.lang.String source)
protected org.eclipse.emf.ecore.EAnnotation findAnnotation(EAnnotationLocation annotationLocation, org.eclipse.emf.ecore.resource.Resource resource)
public void setSilentMergeOptions(SilentMergeOptions options)