public class ResourceAttachmentChangeMerger extends AbstractMerger
AbstractMerger
will be used to merge resource attachment changes.IMerger.Registry, IMerger.Registry2, IMerger.RegistryImpl
mergeOptions, SUB_DIFF_AWARE_OPTION
Constructor and Description |
---|
ResourceAttachmentChangeMerger() |
Modifier and Type | Method and Description |
---|---|
protected void |
accept(Diff diff,
boolean rightToLeft)
Accept the given difference.
|
protected void |
addInTarget(ResourceAttachmentChange diff,
boolean rightToLeft)
This will be called when we need to create an element in the target side.
|
boolean |
apply(IMergeCriterion criterion)
Default implementation of apply for mergers that extends this class.
|
protected URI |
computeTargetURI(Match match,
boolean rightToLeft)
Computes the URI of the "target" resource.
|
protected void |
deleteFormerResourceIfNecessary(Comparison comparison,
Resource oldResource,
boolean rightToLeft)
Deprecated.
Use
ResourceAttachmentChangeMerger#deleteFormerResourceIfNecessary(ResourceAttachmentChange, Resource, boolean)
instead. |
protected void |
deleteResource(Resource resource)
Deprecated.
Not used anymore, it's not the responsibility of the ResourceAttachmentChangeMerger to
delete resources. This is now achieved by installing a
ResourceChangeAdapter on
comparisons. |
protected <E> int |
findInsertionIndex(Comparison comparison,
List<E> source,
List<E> target,
E newElement)
This will be used by the distinct merge actions in order to find the index at which a value should be
inserted in its target list.
|
protected Resource |
findOrCreateTargetResource(Match match,
boolean rightToLeft)
This will try and locate the "target" resource of this merge in the current comparison.
|
protected MatchResource |
getMatchResource(Comparison comparison,
Resource resource)
Returns the MatchResource corresponding to the given
resource . |
boolean |
isMergerFor(Diff target)
Check if the merger is a good candidate to merge the given difference.
|
protected void |
move(ResourceAttachmentChange diff,
boolean rightToLeft)
Handle moves of
ResourceAttachmentChange s. |
protected boolean |
mustDelete(Resource resource,
ResourceAttachmentChange diff,
boolean rightToLeft)
Deprecated.
Don't use this method.
|
protected void |
reject(Diff diff,
boolean rightToLeft)
Reject the given difference.
|
protected void |
removeFromTarget(ResourceAttachmentChange diff,
boolean rightToLeft)
This will be called when we need to remove an element from the target side.
|
addAt, copyDiff, copyLeftToRight, copyRightToLeft, createCopy, getDirectMergeDependencies, getDirectResultingMerges, getDirectResultingRejections, getImpliedMerges, getLogicallyResultingMerges, getMergeOptions, getMergerDelegate, getMergerDelegate, getRanking, getRegistry, isAccepting, isAdd, isInTerminalState, isSet, isUnset, mergeDiff, setMergeOptions, setRanking, setRegistry
public boolean isMergerFor(Diff target)
target
- The given target difference.IMerger.isMergerFor(org.eclipse.emf.compare.Diff)
public boolean apply(IMergeCriterion criterion)
AbstractMerger
null
or
AdditiveMergeCriterion.INSTANCE.apply
in interface IMergeCriterionAware
apply
in class AbstractMerger
criterion
- The merge criteriontrue
if the given criterion is null or is AdditiveMergeCriterion.INSTANCE.protected void accept(Diff diff, boolean rightToLeft)
accept
in class AbstractMerger
diff
- the difference to mergerightToLeft
- the direction of the mergeAbstractMerger.accept(org.eclipse.emf.compare.Diff, boolean)
protected void reject(Diff diff, boolean rightToLeft)
reject
in class AbstractMerger
diff
- the difference to mergerightToLeft
- the direction of the mergeAbstractMerger.reject(org.eclipse.emf.compare.Diff, boolean)
protected void move(ResourceAttachmentChange diff, boolean rightToLeft)
ResourceAttachmentChange
s.diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.@Deprecated protected void deleteFormerResourceIfNecessary(Comparison comparison, Resource oldResource, boolean rightToLeft)
ResourceAttachmentChangeMerger#deleteFormerResourceIfNecessary(ResourceAttachmentChange, Resource, boolean)
instead.comparison
- The comparisonoldResource
- The resource from where the EObject has been movedrightToLeft
- The direction of the change@Deprecated protected boolean mustDelete(Resource resource, ResourceAttachmentChange diff, boolean rightToLeft)
resource
- The resource candidate for deletiondiff
- The ResourceAttachmentChange that's just been mergedrightToLeft
- The direction of the mergetrue
if the given resource must be deleted.@Deprecated protected void deleteResource(Resource resource)
ResourceChangeAdapter
on
comparisons.resource
- The resource to deleteprotected void addInTarget(ResourceAttachmentChange diff, boolean rightToLeft)
All necessary sanity checks have been made to ensure that the current operation is one that should create an object in its side. In other words, either :
diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected Resource findOrCreateTargetResource(Match match, boolean rightToLeft)
match
- Match of the root which resource we need to find or create.rightToLeft
- Direction of the merge. This will tell us which side we are to look up for the target
resource.null
if no
valid target resource can be created.protected URI computeTargetURI(Match match, boolean rightToLeft)
match
- Match of the root for which we need a resource URI.rightToLeft
- Direction of the merge.null
if we cannot compute a
valid target URI.protected MatchResource getMatchResource(Comparison comparison, Resource resource)
resource
.comparison
- The current comparison.resource
- Resource for which we need a MatchResource.resource
.protected void removeFromTarget(ResourceAttachmentChange diff, boolean rightToLeft)
All necessary sanity checks have been made to ensure that the current operation is one that should delete an object. In other words, we are :
diff
- The difference we are to merge.rightToLeft
- Tells us whether we are to add an object on the left or right side.protected <E> int findInsertionIndex(Comparison comparison, List<E> source, List<E> target, E newElement)
DiffUtil.findInsertionIndex(Comparison, Diff, boolean)
for
more on this.
Sub-classes can override this if the insertion order is irrelevant. A return value of -1
will
be considered as "no index" and the value will be inserted at the end of its target list.
E
- Type of the sequences content.comparison
- This will be used in order to retrieve the Match for EObjects when comparing them.source
- The List from which one element has to be added to the target
list.target
- The List into which one element from source
has to be added.newElement
- The element from source
that needs to be added into target
.source
. -1
if the value should be inserted at the end of its
target list.DiffUtil.findInsertionIndex(Comparison, Diff, boolean)
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.