public class ResourceChangeAdapter extends AdapterImpl
Comparison
's ResourceSet
s and their
Resource
s to react to content changes. Participants can then react to such changes to jointly
decide whether a resource must be marked for deletion. The same instance of adapter should be used for all
the resources of a comparison's ResourceSet
s. EMFCompare installs such an adapter on the comparison
to make it easy to retrieve.Modifier and Type | Class and Description |
---|---|
static interface |
ResourceChangeAdapter.IResourceChangeParticipant
A participant in a Resource content change, useful to indicate whether an empty resource must actually
be deleted or not, and which other resources need to be deleted/undeleted along.
|
Adapter.Internal
target
Constructor and Description |
---|
ResourceChangeAdapter(Comparison comparison,
IComparisonScope scope)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addParticipant(ResourceChangeAdapter.IResourceChangeParticipant participant)
Register the given participant.
|
protected org.eclipse.emf.compare.merge.ResourceChangeAdapter.ResourceMatch |
getResourceMatch(Resource resource)
Returns the MatchResource corresponding to the given
resource . |
protected ResourceSet |
getResourceSetOnOtherSide(Resource r)
Get the resource set on the other side of the given resource.
|
boolean |
isAdapterForType(Object type) |
boolean |
isEmptyAndMissingOnOtherSide(Resource resource)
Indicate whether a resource is empty and is only on its side of the comparison (i.e. if it should be
deleted unless a special restriction prevents it).
|
boolean |
mustDelete(Resource r)
Indicate whether a given Resource needs to be deleted.
|
void |
notifyChanged(Notification msg) |
void |
removeParticipant(ResourceChangeAdapter.IResourceChangeParticipant participant)
Unregister the given participant, has no action if the participant was not previously registered.
|
protected void |
resourceAdded(Resource resource)
Callback invoked when a resource has just been added to a resource set.
|
protected void |
resourceContentsChanged(Resource resource,
Notification msg)
React to a Resource contents change to determine if this change involves the deletion of one or several
resources.
|
getTarget, setTarget, unsetTarget
public ResourceChangeAdapter(Comparison comparison, IComparisonScope scope)
comparison
- The comparison, cannot be null
.scope
- The scope, cannot be null
. Moreover, the left and right notifiers of the scope
must be ResourceSet
s.public void notifyChanged(Notification msg)
notifyChanged
in interface Adapter
notifyChanged
in class AdapterImpl
public boolean isAdapterForType(Object type)
isAdapterForType
in interface Adapter
isAdapterForType
in class AdapterImpl
public void addParticipant(ResourceChangeAdapter.IResourceChangeParticipant participant)
participant
- The participant, must not be null
public void removeParticipant(ResourceChangeAdapter.IResourceChangeParticipant participant)
participant
- The participant to unregisterpublic boolean mustDelete(Resource r)
r
- The resourcetrue
if the given resource has been marked for deletion.protected void resourceAdded(Resource resource)
resource
- The newly added resourceprotected ResourceSet getResourceSetOnOtherSide(Resource r)
r
- The resource, which must be either on the left or on the right of the comparison.null
.IllegalArgumentException
- If the given resource is neither on the left nor on the right.protected void resourceContentsChanged(Resource resource, Notification msg)
null
or empty;resource
- The resource the contents of which have changedmsg
- The notification of the changepublic boolean isEmptyAndMissingOnOtherSide(Resource resource)
resource
- The resourcetrue
if the resource is empty and is not matched on the other side of the
comparison.protected org.eclipse.emf.compare.merge.ResourceChangeAdapter.ResourceMatch getResourceMatch(Resource resource)
resource
.resource
- Resource for which we need a MatchResource.resource
, null
if the
resource is not in any side of this comparison (package, profiles, ...).
Copyright (c) 2006, 2015 Obeo and others. All rights reserved.