Class BasicDifferenceGroupImpl
java.lang.Object
org.eclipse.emf.common.notify.impl.AdapterImpl
org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl.BasicDifferenceGroupImpl
- All Implemented Interfaces:
Adapter
,Adapter.Internal
,IDifferenceGroup
- Direct Known Subclasses:
ByResourceGroupProvider.ResourceGroup
,ThreeWayComparisonGroupProvider.ConflictsGroupImpl
This implementation of a
IDifferenceGroup
uses a predicate to filter the whole list of differences.
This can be subclasses or used directly instead of IDifferenceGroup
.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.emf.common.notify.Adapter
Adapter.Internal
-
Field Summary
Modifier and TypeFieldDescriptionThe list of children of this group.Function that returns all contents of the given EObject.protected final com.google.common.base.Predicate<? super Diff>
The filter we'll use in order to filter the differences that are part of this group.protected final org.eclipse.swt.graphics.Image
The icon that the EMF Compare UI will display for this group.protected final String
The name that the EMF Compare UI will display for this group.Fields inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
target
Fields inherited from interface org.eclipse.emf.compare.rcp.ui.structuremergeviewer.groups.IDifferenceGroup
TREE_NODE_DATA
-
Constructor Summary
ConstructorDescriptionBasicDifferenceGroupImpl
(Comparison comparison, com.google.common.base.Predicate<? super Diff> filter, String name, ECrossReferenceAdapter crossReferenceAdapter) Instantiates this group given the comparison and filter that should be used in order to determine its list of differences.BasicDifferenceGroupImpl
(Comparison comparison, com.google.common.base.Predicate<? super Diff> filter, String name, org.eclipse.swt.graphics.Image image, ECrossReferenceAdapter crossReferenceAdapter) Instantiates this group given the comparison and filter that should be used in order to determine its list of differences.BasicDifferenceGroupImpl
(Comparison comparison, com.google.common.base.Predicate<? super Diff> filter, ECrossReferenceAdapter crossReferenceAdapter) Instantiates this group given the comparison and filter that should be used in order to determine its list of differences. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addDiffNode
(MatchNode matchNode, Diff diff) Add the diff in the given match.Compute a subTree for each root match of the comparison.void
Builds the sub tree for this group.protected MatchResourceNode
buildSubTree
(MatchResource matchResource, Set<ResourceAttachmentChange> attachmentChanges) Build the sub tree of the givenMatchResource
.protected MatchNode
Compute a tree for the given match.This creates the root-level children of the group.protected ConflictNode
createConflictNode
(Conflict conflict) Create a conflict node.protected DiffNode
createDiffNode
(Diff diff) Create a diff node.protected MatchNode
createMatchNode
(Match match) Create a match node.protected MatchResourceNode
createMatchResourceNode
(MatchResource matchResource) Create a matchResource node.protected void
Walk the given trees and customize each node in the tree, starting by the deeper nodes all the way up to the root nodes.protected void
Allow extenders to customize a TreeNode.void
dispose()
Dispose this group provider.protected void
Perform the creation of the sub-trees of the group.The list of TreeNode containded in this group.protected final Comparison
Returns the comparison object.org.eclipse.swt.graphics.Image
getImage()
The icon that is to be used for this group in the compare UI.getName()
A human-readable label for this group.The styled label for the this group.protected Match
getTargetMatch
(Diff diff) Provide the Match that should directly contain the given diff.protected void
handleRefiningDiffs
(DiffNode diffNode) Handle the diffs that refine the given diff.boolean
isAdapterForType
(Object type) protected boolean
isContainmentRefChange
(Diff diff) Is it a containment reference change?protected boolean
Does the given difference have to be displayed as direct child of a Match?protected void
populateMatchNode
(MatchNode matchNode) Build the subtree for the given match.protected final void
registerCrossReferenceAdapter
(List<? extends Notifier> notifiers) Registers the CrossReferenceAdapter to all given notifiers.protected final void
unregisterCrossReferenceAdapter
(List<? extends Notifier> notifiers) Unregisters the CrossReferenceAdapter from all given notifiers.Methods inherited from class org.eclipse.emf.common.notify.impl.AdapterImpl
getTarget, notifyChanged, setTarget, unsetTarget
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.emf.common.notify.Adapter
getTarget, notifyChanged, setTarget
-
Field Details
-
E_ALL_CONTENTS
Function that returns all contents of the given EObject. -
filter
The filter we'll use in order to filter the differences that are part of this group. -
name
The name that the EMF Compare UI will display for this group. -
image
protected final org.eclipse.swt.graphics.Image imageThe icon that the EMF Compare UI will display for this group. -
children
The list of children of this group.
-
-
Constructor Details
-
BasicDifferenceGroupImpl
public BasicDifferenceGroupImpl(Comparison comparison, com.google.common.base.Predicate<? super Diff> filter, ECrossReferenceAdapter crossReferenceAdapter) Instantiates this group given the comparison and filter that should be used in order to determine its list of differences.This will use the default name and icon for the group.
- Parameters:
comparison
- The comparison that is the parent of this group.filter
- The filter we'll use in order to filter the differences that are part of this group.crossReferenceAdapter
- The cross reference adapter that will be added to this group's children.
-
BasicDifferenceGroupImpl
public BasicDifferenceGroupImpl(Comparison comparison, com.google.common.base.Predicate<? super Diff> filter, String name, ECrossReferenceAdapter crossReferenceAdapter) Instantiates this group given the comparison and filter that should be used in order to determine its list of differences. It will be displayed in the UI with the default icon and the given name.- Parameters:
comparison
- The comparison that is the parent of this group.filter
- The filter we'll use in order to filter the differences that are part of this group.name
- The name that the EMF Compare UI will display for this group.crossReferenceAdapter
- The cross reference adapter that will be added to this group's children.
-
BasicDifferenceGroupImpl
public BasicDifferenceGroupImpl(Comparison comparison, com.google.common.base.Predicate<? super Diff> filter, String name, org.eclipse.swt.graphics.Image image, ECrossReferenceAdapter crossReferenceAdapter) Instantiates this group given the comparison and filter that should be used in order to determine its list of differences. It will be displayed in the UI with the given icon and name.- Parameters:
comparison
- The comparison that is the parent of this group.filter
- The filter we'll use in order to filter the differences that are part of this group.name
- The name that the EMF Compare UI will display for this group.image
- The icon that the EMF Compare UI will display for this group.crossReferenceAdapter
- Updated upstream The cross reference adapter that will be added to this group's children.
-
-
Method Details
-
getComparison
Returns the comparison object.- Returns:
- the comparison object.
-
isAdapterForType
- Specified by:
isAdapterForType
in interfaceAdapter
- Overrides:
isAdapterForType
in classAdapterImpl
- See Also:
-
getName
A human-readable label for this group.- Specified by:
getName
in interfaceIDifferenceGroup
- Returns:
- A human-readable label for this group that can be displayed to the user.
- See Also:
-
getStyledName
The styled label for the this group. This will be displayed in the EMF Compare UI.- Specified by:
getStyledName
in interfaceIDifferenceGroup
- Returns:
- A human-readable styled label for this group that can be displayed to the user.
- See Also:
-
getImage
public org.eclipse.swt.graphics.Image getImage()The icon that is to be used for this group in the compare UI.- Specified by:
getImage
in interfaceIDifferenceGroup
- Returns:
- Icon that is to be used for this group in the compare UI. If
null
, a default image will be used instead. - See Also:
-
getChildren
The list of TreeNode containded in this group.- Specified by:
getChildren
in interfaceIDifferenceGroup
- Returns:
- the list of TreeNode containded in this group.
- See Also:
-
registerCrossReferenceAdapter
Registers the CrossReferenceAdapter to all given notifiers.- Parameters:
notifiers
- the list of notifiers.
-
unregisterCrossReferenceAdapter
Unregisters the CrossReferenceAdapter from all given notifiers.- Parameters:
notifiers
- the list of notifiers.
-
dispose
public void dispose()Dispose this group provider.- Specified by:
dispose
in interfaceIDifferenceGroup
- See Also:
-
buildSubTree
public void buildSubTree()Builds the sub tree for this group. -
doBuildSubTrees
protected void doBuildSubTrees()Perform the creation of the sub-trees of the group. -
createChildren
This creates the root-level children of the group.- Returns:
- This default implementation returns a new ArrayList. It may be overridden by sub-classes.
-
buildMatchTrees
Compute a subTree for each root match of the comparison.- Returns:
- the list of matchSubTrees
-
buildTree
Compute a tree for the given match.- Parameters:
match
- The given match- Returns:
- a list of subTree for this match, must not be
null
-
populateMatchNode
Build the subtree for the given match.- Parameters:
matchNode
- The root matchNode
-
getTargetMatch
Provide the Match that should directly contain the given diff. If the given diff should not be a direct child of a Match, the method must returnnull
. For a given strategy, a diff should only be displayed in the same Match (i.e. theDiffNode
s that represent the diff should always be children of theMatchNode
s that represent the returned Match.- Parameters:
diff
- The difference- Returns:
- The Match that is a direct parent of the given diff, can be
null
.
-
mustDisplayAsDirectChildOfMatch
Does the given difference have to be displayed as direct child of a Match?- Parameters:
diff
- The diff- Returns:
true
if the diff's node should be a child of a MatchNode.
-
isContainmentRefChange
Is it a containment reference change?- Parameters:
diff
- The diff- Returns:
true
if the diff is aReferenceChange
whoseEReference
is a containment reference.
-
buildMatchResourceTrees
-
buildSubTree
protected MatchResourceNode buildSubTree(MatchResource matchResource, Set<ResourceAttachmentChange> attachmentChanges) Build the sub tree of the givenMatchResource
.- Parameters:
matchResource
- the given MatchResource.- Returns:
- the sub tree of the given MatchResource.
-
addDiffNode
Add the diff in the given match. This method handles refined diffs and allows to customize the result.- Parameters:
matchNode
- The given match nodediff
- The diff to add
-
createDiffNode
Create a diff node.- Parameters:
diff
- The given diff- Returns:
- the DiffNode
-
createMatchNode
Create a match node.- Parameters:
match
- The given match- Returns:
- the MatchNode
-
createConflictNode
Create a conflict node.- Parameters:
conflict
- The given conflict- Returns:
- the ConflictNode
-
createMatchResourceNode
Create a matchResource node.- Parameters:
matchResource
- The given matchResource- Returns:
- the MatchResourceNode
-
customize
Walk the given trees and customize each node in the tree, starting by the deeper nodes all the way up to the root nodes. This method calls itself recursively.- Parameters:
nodes
- The list of nodes to customize.
-
customize
Allow extenders to customize a TreeNode.- Parameters:
treeNode
- the TreeNode to customize.
-
handleRefiningDiffs
Handle the diffs that refine the given diff. Refining diffs are added as children of the given diff, and so on recursively.- Parameters:
diffNode
- The diff node to handle, which is not necessarily a child of a MatchNode since this method is called recursively.
-