Package org.eclipse.emf.compare.rcp.ui.internal.structuremergeviewer.groups.impl

# 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`

public class BasicDifferenceGroupImpl extends AdapterImpl implements IDifferenceGroup
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

Fields
Modifier and Type
Field
Description
`protected List<TreeNode>`
`children`
The list of children of this group.
`protected static final com.google.common.base.Function<EObject,Iterator<EObject>>`
`E_ALL_CONTENTS`
Function that returns all contents of the given EObject.
`protected final com.google.common.base.Predicate<? super Diff>`
`filter`
The filter we'll use in order to filter the differences that are part of this group.
`protected final org.eclipse.swt.graphics.Image`
`image`
The icon that the EMF Compare UI will display for this group.
`protected final String`
`name`
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

Constructors
Constructor
Description
`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.
`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 Type
Method
Description
`protected void`
`addDiffNode(MatchNode matchNode, Diff diff)`
Add the diff in the given match.
`protected List<TreeNode>`
`buildMatchResourceTrees()`
`protected List<TreeNode>`
`buildMatchTrees()`
Compute a subTree for each root match of the comparison.
`void`
`buildSubTree()`
Builds the sub tree for this group.
`protected MatchResourceNode`
`buildSubTree(MatchResource matchResource, Set<ResourceAttachmentChange> attachmentChanges)`
Build the sub tree of the given `MatchResource`.
`protected MatchNode`
`buildTree(Match match)`
Compute a tree for the given match.
`protected List<TreeNode>`
`createChildren()`
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`
`customize(List<? extends TreeNode> nodes)`
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`
`customize(TreeNode treeNode)`
Allow extenders to customize a TreeNode.
`void`
`dispose()`
Dispose this group provider.
`protected void`
`doBuildSubTrees()`
Perform the creation of the sub-trees of the group.
`List<? extends TreeNode>`
`getChildren()`
The list of TreeNode containded in this group.
`protected final Comparison`
`getComparison()`
Returns the comparison object.
`org.eclipse.swt.graphics.Image`
`getImage()`
The icon that is to be used for this group in the compare UI.
`String`
`getName()`
A human-readable label for this group.
`IStyledString.IComposedStyledString`
`getStyledName()`
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`
`mustDisplayAsDirectChildOfMatch(Diff diff)`
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

protected static final com.google.common.base.Function<EObject,Iterator<EObject>> E_ALL_CONTENTS
Function that returns all contents of the given EObject.

### filter

protected final com.google.common.base.Predicate<? super Diff> filter
The filter we'll use in order to filter the differences that are part of this group.

### name

protected final String name
The name that the EMF Compare UI will display for this group.

### image

protected final org.eclipse.swt.graphics.Image image
The icon that the EMF Compare UI will display for this group.

### children

protected List<TreeNode> 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

protected final Comparison getComparison()
Returns the comparison object.

Returns:
  the comparison object.

### isAdapterForType

public boolean isAdapterForType(Object type)

Specified by:
  `isAdapterForType` in interface `Adapter`
Overrides:
  `isAdapterForType` in class `AdapterImpl`
See Also:
  - `AdapterImpl.isAdapterForType(java.lang.Object)`

### getName

public String getName()
A human-readable label for this group.

Specified by:
  `getName` in interface `IDifferenceGroup`
Returns:
  A human-readable label for this group that can be displayed to the user.
See Also:
  - `IDifferenceGroup.getName()`

### getStyledName

public IStyledString.IComposedStyledString getStyledName()
The styled label for the this group. This will be displayed in the EMF Compare UI.

Specified by:
  `getStyledName` in interface `IDifferenceGroup`
Returns:
  A human-readable styled label for this group that can be displayed to the user.
See Also:
  - `IDifferenceGroup.getStyledName()`

### 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 interface `IDifferenceGroup`
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:
  - `IDifferenceGroup.getImage()`

### getChildren

public List<? extends TreeNode> getChildren()
The list of TreeNode containded in this group.

Specified by:
  `getChildren` in interface `IDifferenceGroup`
Returns:
  the list of TreeNode containded in this group.
See Also:
  - `IDifferenceGroup.getChildren()`

### registerCrossReferenceAdapter

protected final void registerCrossReferenceAdapter(List<? extends Notifier> notifiers)
Registers the CrossReferenceAdapter to all given notifiers.

Parameters:
  `notifiers` - the list of notifiers.

### unregisterCrossReferenceAdapter

protected final void unregisterCrossReferenceAdapter(List<? extends Notifier> notifiers)
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 interface `IDifferenceGroup`
See Also:
  - `IDifferenceGroup.dispose()`

### 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

protected List<TreeNode> 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

protected List<TreeNode> buildMatchTrees()
Compute a subTree for each root match of the comparison.

Returns:
  the list of matchSubTrees

### buildTree

protected MatchNode buildTree(Match match)
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

protected void populateMatchNode(MatchNode matchNode)
Build the subtree for the given match.

Parameters:
  `matchNode` - The root matchNode

### getTargetMatch

protected Match getTargetMatch(Diff diff)
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 return `null`. For a given strategy, a diff should only be displayed in the same Match (i.e. the `DiffNode`s that represent the diff should always be children of the `MatchNode`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

protected boolean mustDisplayAsDirectChildOfMatch(Diff diff)
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

protected boolean isContainmentRefChange(Diff diff)
Is it a containment reference change?

Parameters:
  `diff` - The diff
Returns:
  `true` if the diff is a `ReferenceChange` whose `EReference` is a containment reference.

### buildMatchResourceTrees

protected List<TreeNode> buildMatchResourceTrees()

### buildSubTree

protected MatchResourceNode buildSubTree(MatchResource matchResource, Set<ResourceAttachmentChange> attachmentChanges)
Build the sub tree of the given `MatchResource`.

Parameters:
  `matchResource` - the given MatchResource.
Returns:
  the sub tree of the given MatchResource.

### addDiffNode

protected void addDiffNode(MatchNode matchNode, Diff diff)
Add the diff in the given match. This method handles refined diffs and allows to customize the result.

Parameters:
  `matchNode` - The given match node
  `diff` - The diff to add

### createDiffNode

protected DiffNode createDiffNode(Diff diff)
Create a diff node.

Parameters:
  `diff` - The given diff
Returns:
  the DiffNode

### createMatchNode

protected MatchNode createMatchNode(Match match)
Create a match node.

Parameters:
  `match` - The given match
Returns:
  the MatchNode

### createConflictNode

protected ConflictNode createConflictNode(Conflict conflict)
Create a conflict node.

Parameters:
  `conflict` - The given conflict
Returns:
  the ConflictNode

### createMatchResourceNode

protected MatchResourceNode createMatchResourceNode(MatchResource matchResource)
Create a matchResource node.

Parameters:
  `matchResource` - The given matchResource
Returns:
  the MatchResourceNode

### customize

protected void customize(List<? extends TreeNode> nodes)
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

protected void customize(TreeNode treeNode)
Allow extenders to customize a TreeNode.

Parameters:
  `treeNode` - the TreeNode to customize.

### handleRefiningDiffs

protected void handleRefiningDiffs(DiffNode diffNode)
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.