org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.tree.provider

## Class TreeMergeViewerItemContentProvider

- java.lang.Object
- - org.eclipse.emf.compare.ide.ui.internal.contentmergeviewer.tree.provider.TreeMergeViewerItemContentProvider

All Implemented Interfaces:
  IMergeViewerItemContentProvider, IOptionalProvider

    public class TreeMergeViewerItemContentProvider
    extends Object
    implements IMergeViewerItemContentProvider

ContentProvider for `IMergeViewerItem`s which uses their 'left', 'right' and 'ancestor' sides in combination with the given `AdapterFactory` to create the children and parent `IMergeViewerItem`s.

### Constructor Summary

Constructors
Constructor and Description
`TreeMergeViewerItemContentProvider()`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `canHandle(Object object)` Indicates whether this provider wants to handle the given `object`.
`protected List<? extends Diff>` `collectAndFilterDifferences(Iterable<Object> objects, IMergeViewerItemProviderConfiguration configuration)` Determines the differences related to the given objects and filters them according to the `visibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration)`.
`protected IMergeViewerItem` `createBasicContainer(ResourceAttachmentChange diff, IMergeViewerItem mergeViewerItem, AdapterFactory adapterFactory)` Create an IMergeViewerItem for the parent of the given `ResourceAttachmentChange`.
`protected List<IMergeViewerItem>` `createInsertionPoints(IMergeViewerItem parent, List<IMergeViewerItem> values, List<? extends Diff> differences, IMergeViewerItemProviderConfiguration configuration)` Creates and inserts the insertion points for the given `values`.
`protected List<IMergeViewerItem>` `createInsertionPoints(IMergeViewerItem parent, List<Object> sideContent, List<Object> oppositeContent, List<Object> ancestorContent, List<? extends IMergeViewerItem> values, List<? extends Diff> differences, IMergeViewerItemProviderConfiguration configuration)` Creates the insertion points for the given `values` based on the children of each side.
`protected IMergeViewerItem` `createMergeViewerItem(Comparison comparison, Diff diff, Match match, IMergeViewer.MergeViewerSide side, AdapterFactory adapterFactory)` Creates the `IMergeViewerItem` from the given data.
`protected IMergeViewerItem` `createMergeViewerItem(Comparison comparison, Diff diff, Object left, Object right, Object ancestor, IMergeViewer.MergeViewerSide side, AdapterFactory adapterFactory)` Creates the `IMergeViewerItem` from the given data.
`protected IMergeViewerItem` `createMergeViewerItemFrom(EObject eObject, IMergeViewerItem parent, IMergeViewerItemProviderConfiguration configuration)` Creates an IMergeViewerItem from an EObject.
`protected List<IMergeViewerItem>` `createMergeViewerItemsFrom(Collection<?> values, IMergeViewerItem parent, IMergeViewerItemProviderConfiguration configuration)` Creates the Merge Viewer Items for the given `values`.
`protected Object` `getBestSideValue(IMergeViewerItem mergeViewerItem, IMergeViewer.MergeViewerSide side)` Get a non-null side of the the given `IMergeViewerItem`, preferring but not limited to the given side.
`Object[]` `getChildren(Object object, IMergeViewerItemProviderConfiguration configuration)` Determine the children of the given `object`
`protected List<Object>` `getChildrenFromContentProvider(Object object, AdapterFactory adapterFactory)` Adapts to `ITreeItemMergeViewerContentProvider` or `ITreeItemContentProvider` and calls getChildren.
`protected Object` `getDiffValue(Diff diff)` Determines the value of the given diff.
`protected Object` `getFirstValue(Iterable<Diff> diffs)` Determines the first non-null value of the given diffs.
`Object` `getParent(Object object, IMergeViewerItemProviderConfiguration configuration)` Determine the parent of the given `object`.
`protected Object` `getSideValue(IMergeViewerItem mergeViewerItem, IMergeViewer.MergeViewerSide side)`
`protected Iterable<? extends Diff>` `getVisibleContainmentDiffs(EObject object, IMergeViewerItemProviderConfiguration configuration)` Determines all differences regarding the given `object` which are related to a containment reference change and are visible in the viewer.
`boolean` `hasChildren(Object object, IMergeViewerItemProviderConfiguration configuration)` Indicates whether the given `object` has children.
`protected com.google.common.base.Predicate<Diff>` `visibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration configuration)` Predicate for checking if the given `diff` is visible and itself (or any of its 'refining' diffs) is a containment reference change.
`protected com.google.common.base.Predicate<Diff>` `visibleInMergeViewerPredicate(com.google.common.base.Predicate<? super EObject> predicate, IDifferenceGroupProvider groupProvider)` Predicate for checking if the given `diff` is visible in the merge viewer.
`protected boolean` `yieldsInsertionPoint(IMergeViewerItem parent, Iterable<? extends Diff> diffs, IMergeViewerItemProviderConfiguration configuration)` Indicates whether for the given diffs at least one `IMergeViewerItem` insertion point should be created.
`protected boolean` `yieldsMergeViewerItem(Comparison comparison, Diff diff, Collection<?> values)` Indicates whether for the given values at least one `IMergeViewerItem` should be created.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### TreeMergeViewerItemContentProvider

    public TreeMergeViewerItemContentProvider()

### Method Detail

#### canHandle

    public boolean canHandle(Object object)

Indicates whether this provider wants to handle the given `object`.

Specified by:
  `canHandle` in interface `IOptionalProvider`
Parameters:
  `object` - the `Object`.
Returns:
  `true` if the provider wants to handle the given `object`, `false` otherwise.

#### getParent

    public Object getParent(Object object,
                            IMergeViewerItemProviderConfiguration configuration)

Determine the parent of the given `object`.

Specified by:
  `getParent` in interface `IMergeViewerItemContentProvider`
Parameters:
  `object` - the `Object` for which the parent is to be determined.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  the determined parent object, `null` if there is none.

#### hasChildren

    public boolean hasChildren(Object object,
                               IMergeViewerItemProviderConfiguration configuration)

Indicates whether the given `object` has children.

Specified by:
  `hasChildren` in interface `IMergeViewerItemContentProvider`
Parameters:
  `object` - the `Object` for which it is indicated whether it has children.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  `true` if the given object has children, `false` otherwise.

#### getChildren

    public Object[] getChildren(Object object,
                                IMergeViewerItemProviderConfiguration configuration)

Determine the children of the given `object`

Specified by:
  `getChildren` in interface `IMergeViewerItemContentProvider`
Parameters:
  `object` - the `Object` for which the children are to be determined.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  an array with the determined children, an empty array if there are none.

#### collectAndFilterDifferences

    protected List<? extends Diff> collectAndFilterDifferences(Iterable<Object> objects,
                                                               IMergeViewerItemProviderConfiguration configuration)

Determines the differences related to the given objects and filters them according to the `visibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration)`.

Parameters:
  `objects` - the objects.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  the determined differences.

#### createInsertionPoints

    protected List<IMergeViewerItem> createInsertionPoints(IMergeViewerItem parent,
                                                           List<IMergeViewerItem> values,
                                                           List<? extends Diff> differences,
                                                           IMergeViewerItemProviderConfiguration configuration)

Creates and inserts the insertion points for the given `values`.

Parameters:
  `parent` - the `IMergeViewerItem` parent.
  `values` - the list of `IMergeViewerItem` children for which insertion points are to be created.
  `differences` - the list of relevant differences.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  the list of `values` containing the created insertion points.

#### createInsertionPoints

    protected List<IMergeViewerItem> createInsertionPoints(IMergeViewerItem parent,
                                                           List<Object> sideContent,
                                                           List<Object> oppositeContent,
                                                           List<Object> ancestorContent,
                                                           List<? extends IMergeViewerItem> values,
                                                           List<? extends Diff> differences,
                                                           IMergeViewerItemProviderConfiguration configuration)

Creates the insertion points for the given `values` based on the children of each side.

Parameters:
  `parent` - the `IMergeViewerItem` parent.
  `sideContent` - the object for 'this' side.
  `oppositeContent` - the object for the 'other' side.
  `ancestorContent` - the objects for the 'origin' side-
  `values` - the `IMergeViewerItem`s for which the insertion points are to be created.
  `differences` - the list of relevant differences.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  the list of `values` containing the created insertion points.

#### getDiffValue

    protected Object getDiffValue(Diff diff)

Determines the value of the given diff. If the diff has no "value", its prime refining or refined-by counterparts are also checked.

Parameters:
  `diff` - the `Diff` to check.
Returns:
  the value of the given diff. If no value exists `null` will be returned.

#### getFirstValue

    protected Object getFirstValue(Iterable<Diff> diffs)

Determines the first non-null value of the given diffs.

Parameters:
  `diffs` - the `Diff`s to check.
Returns:
  the first non-null value if it exists, `null` otherwise.

#### getChildrenFromContentProvider

    protected List<Object> getChildrenFromContentProvider(Object object,
                                                          AdapterFactory adapterFactory)

Adapts to `ITreeItemMergeViewerContentProvider` or `ITreeItemContentProvider` and calls getChildren. Also unwraps `FeatureMap.Entry`.

Parameters:
  `object` - The object for which the children are to be determined.
Returns:
  A list of all children of the given `object`.

#### yieldsInsertionPoint

    protected boolean yieldsInsertionPoint(IMergeViewerItem parent,
                                           Iterable<? extends Diff> diffs,
                                           IMergeViewerItemProviderConfiguration configuration)

Indicates whether for the given diffs at least one `IMergeViewerItem` insertion point should be created.

Parameters:
  `comparison` - the `Comparison`.
  `diffs` - the `Diff`s.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  `true` if at least one `IMergeViewerItem` should be created, `false` otherwise.

#### yieldsMergeViewerItem

    protected boolean yieldsMergeViewerItem(Comparison comparison,
                                            Diff diff,
                                            Collection<?> values)

Indicates whether for the given values at least one `IMergeViewerItem` should be created.

Parameters:
  `comparison` - the `Comparison`.
  `diff` - the `Diff`.
  `values` - the values.
Returns:
  `true` if at least one `IMergeViewerItem` should be created, `false` otherwise.

#### getVisibleContainmentDiffs

    protected Iterable<? extends Diff> getVisibleContainmentDiffs(EObject object,
                                                                  IMergeViewerItemProviderConfiguration configuration)

Determines all differences regarding the given `object` which are related to a containment reference change and are visible in the viewer.

Parameters:
  `object` - the `EObject`.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  all visible diffs regarding `object` related to containment differences.

#### getBestSideValue

    protected Object getBestSideValue(IMergeViewerItem mergeViewerItem,
                                      IMergeViewer.MergeViewerSide side)

Get a non-null side of the the given `IMergeViewerItem`, preferring but not limited to the given side.

Parameters:
  `mergeViewerItem` - the `IMergeViewerItem`.
  `side` - `IMergeViewer.MergeViewerSide`
Returns:
  the side object. May be null if all sides are null.

#### getSideValue

    protected Object getSideValue(IMergeViewerItem mergeViewerItem,
                                  IMergeViewer.MergeViewerSide side)

Parameters:
  `mergeViewerItem` -
See Also:
  `org.eclipse.emf.compare.rcp.ui.mergeviewer.item.ide.ui.internal.contentmergeviewer.IMergeViewerItem#getSideValue(org.eclipse.emf.compare.rcp.ui.mergeviewer.ide.ui.internal.contentmergeviewer.IMergeViewer.MergeViewerSide)`

#### createBasicContainer

    protected IMergeViewerItem createBasicContainer(ResourceAttachmentChange diff,
                                                    IMergeViewerItem mergeViewerItem,
                                                    AdapterFactory adapterFactory)

Create an IMergeViewerItem for the parent of the given `ResourceAttachmentChange`.

Parameters:
  `diff` - the given `ResourceAttachmentChange`.
Returns:
  an IMergeViewerItem.

#### visibleContainmentDiffPredicate

    protected com.google.common.base.Predicate<Diff> visibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration configuration)

Predicate for checking if the given `diff` is visible and itself (or any of its 'refining' diffs) is a containment reference change.

Parameters:
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  the `Predicate`.

#### visibleInMergeViewerPredicate

    protected com.google.common.base.Predicate<Diff> visibleInMergeViewerPredicate(com.google.common.base.Predicate<? super EObject> predicate,
                                                                                   IDifferenceGroupProvider groupProvider)

Predicate for checking if the given `diff` is visible in the merge viewer.

Parameters:
  `predicate` - the filtering `Predicate`.
  `groupProvider` - the active `IDifferenceGroupProvider`.
Returns:
  the `Predicate`.

#### createMergeViewerItemsFrom

    protected List<IMergeViewerItem> createMergeViewerItemsFrom(Collection<?> values,
                                                                IMergeViewerItem parent,
                                                                IMergeViewerItemProviderConfiguration configuration)

Creates the Merge Viewer Items for the given `values`.

Parameters:
  `values` - the object for which `IMergeViewerItem`s shall be created.
  `parent` - the `IMergeViewerItem` parent of the children to create
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:

#### createMergeViewerItemFrom

    protected IMergeViewerItem createMergeViewerItemFrom(EObject eObject,
                                                         IMergeViewerItem parent,
                                                         IMergeViewerItemProviderConfiguration configuration)

Creates an IMergeViewerItem from an EObject.

Parameters:
  `eObject` - the given eObject.
  `parent` - the `IMergeViewerItem` parent of the child to create.
  `configuration` - the `IMergeViewerItemProviderConfiguration`.
Returns:
  an IMergeViewerItem.

#### createMergeViewerItem

    protected IMergeViewerItem createMergeViewerItem(Comparison comparison,
                                                     Diff diff,
                                                     Object left,
                                                     Object right,
                                                     Object ancestor,
                                                     IMergeViewer.MergeViewerSide side,
                                                     AdapterFactory adapterFactory)

Creates the `IMergeViewerItem` from the given data.

Parameters:
  `comparison` - the `Comparison`.
  `diff` - the `Diff`. May be null.
  `left` - the left object. May be null. (One of left, right, ancestor should be non-null).
  `right` - the right object. May be null. (One of left, right, ancestor should be non-null).
  `ancestor` - the ancestor object. May be null. (One of left, right, ancestor should be non-null).
  `side` - the `IMergeViewer.MergeViewerSide`.
  `adapterFactory` - the `AdapterFactory`.
Returns:
  the created `IMergeViewerItem`.

#### createMergeViewerItem

    protected IMergeViewerItem createMergeViewerItem(Comparison comparison,
                                                     Diff diff,
                                                     Match match,
                                                     IMergeViewer.MergeViewerSide side,
                                                     AdapterFactory adapterFactory)

Creates the `IMergeViewerItem` from the given data.

Parameters:
  `comparison` - the `Comparison`.
  `diff` - the `Diff`. May be null.
  `match` - the `Match`.
  `side` - the `IMergeViewer.MergeViewerSide`.
  `adapterFactory` - the `AdapterFactory`.
Returns:
  the created `IMergeViewerItem`.