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
IMergeViewerItems which uses their 'left', 'right' and 'ancestor' sides in
combination with the given AdapterFactory to create the children and parent
IMergeViewerItems.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether this provider wants to handle the givenobject.collectAndFilterDifferences(Iterable<Object> objects, IMergeViewerItemProviderConfiguration configuration) Determines the differences related to the given objects and filters them according to thevisibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration).protected IMergeViewerItemcreateBasicContainer(ResourceAttachmentChange diff, IMergeViewerItem mergeViewerItem, AdapterFactory adapterFactory) Create an IMergeViewerItem for the parent of the givenResourceAttachmentChange.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 givenvaluesbased on the children of each side.protected List<IMergeViewerItem> createInsertionPoints(IMergeViewerItem parent, List<IMergeViewerItem> values, List<? extends Diff> differences, IMergeViewerItemProviderConfiguration configuration) Creates and inserts the insertion points for the givenvalues.protected IMergeViewerItemcreateMergeViewerItem(Comparison comparison, Diff diff, Object left, Object right, Object ancestor, IMergeViewer.MergeViewerSide side, AdapterFactory adapterFactory) Creates theIMergeViewerItemfrom the given data.protected IMergeViewerItemcreateMergeViewerItem(Comparison comparison, Diff diff, Match match, IMergeViewer.MergeViewerSide side, AdapterFactory adapterFactory) Creates theIMergeViewerItemfrom the given data.protected IMergeViewerItemcreateMergeViewerItemFrom(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 givenvalues.protected ObjectgetBestSideValue(IMergeViewerItem mergeViewerItem, IMergeViewer.MergeViewerSide side) Get a non-null side of the the givenIMergeViewerItem, preferring but not limited to the given side.Object[]getChildren(Object object, IMergeViewerItemProviderConfiguration configuration) Determine the children of the givenobjectgetChildrenFromContentProvider(Object object, AdapterFactory adapterFactory) Adapts toorinvalid reference
ITreeItemMergeViewerContentProviderITreeItemContentProviderand calls getChildren.protected ObjectgetDiffValue(Diff diff) Determines the value of the given diff.protected ObjectgetFirstValue(Iterable<Diff> diffs) Determines the first non-null value of the given diffs.getParent(Object object, IMergeViewerItemProviderConfiguration configuration) Determine the parent of the givenobject.protected ObjectgetSideValue(IMergeViewerItem mergeViewerItem, IMergeViewer.MergeViewerSide side) getVisibleContainmentDiffs(EObject object, IMergeViewerItemProviderConfiguration configuration) Determines all differences regarding the givenobjectwhich are related to a containment reference change and are visible in the viewer.booleanhasChildren(Object object, IMergeViewerItemProviderConfiguration configuration) Indicates whether the givenobjecthas children.protected com.google.common.base.Predicate<Diff> Predicate for checking if the givendiffis 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 givendiffis visible in the merge viewer.protected booleanyieldsInsertionPoint(IMergeViewerItem parent, Iterable<? extends Diff> diffs, IMergeViewerItemProviderConfiguration configuration) Indicates whether for the given diffs at least oneIMergeViewerIteminsertion point should be created.protected booleanyieldsMergeViewerItem(Comparison comparison, Diff diff, Collection<?> values) Indicates whether for the given values at least oneIMergeViewerItemshould be created.
-
Constructor Details
-
TreeMergeViewerItemContentProvider
public TreeMergeViewerItemContentProvider()
-
-
Method Details
-
canHandle
Indicates whether this provider wants to handle the givenobject.- Specified by:
canHandlein interfaceIOptionalProvider- Parameters:
object- theObject.- Returns:
trueif the provider wants to handle the givenobject,falseotherwise.
-
getParent
Determine the parent of the givenobject.- Specified by:
getParentin interfaceIMergeViewerItemContentProvider- Parameters:
object- theObjectfor which the parent is to be determined.configuration- theIMergeViewerItemProviderConfiguration.- Returns:
- the determined parent object,
nullif there is none.
-
hasChildren
Indicates whether the givenobjecthas children.- Specified by:
hasChildrenin interfaceIMergeViewerItemContentProvider- Parameters:
object- theObjectfor which it is indicated whether it has children.configuration- theIMergeViewerItemProviderConfiguration.- Returns:
trueif the given object has children,falseotherwise.
-
getChildren
Determine the children of the givenobject- Specified by:
getChildrenin interfaceIMergeViewerItemContentProvider- Parameters:
object- theObjectfor which the children are to be determined.configuration- theIMergeViewerItemProviderConfiguration.- 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 thevisibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration).- Parameters:
objects- the objects.configuration- theIMergeViewerItemProviderConfiguration.- 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 givenvalues.- Parameters:
parent- theIMergeViewerItemparent.values- the list ofIMergeViewerItemchildren for which insertion points are to be created.differences- the list of relevant differences.configuration- theIMergeViewerItemProviderConfiguration.- Returns:
- the list of
valuescontaining 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 givenvaluesbased on the children of each side.- Parameters:
parent- theIMergeViewerItemparent.sideContent- the object for 'this' side.oppositeContent- the object for the 'other' side.ancestorContent- the objects for the 'origin' side-values- theIMergeViewerItems for which the insertion points are to be created.differences- the list of relevant differences.configuration- theIMergeViewerItemProviderConfiguration.- Returns:
- the list of
valuescontaining the created insertion points.
-
getDiffValue
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- theDiffto check.- Returns:
- the value of the given diff. If no value exists
nullwill be returned.
-
getFirstValue
Determines the first non-null value of the given diffs.- Parameters:
diffs- theDiffs to check.- Returns:
- the first non-null value if it exists,
nullotherwise.
-
getChildrenFromContentProvider
Adapts toorinvalid reference
ITreeItemMergeViewerContentProviderITreeItemContentProviderand calls getChildren. Also unwrapsFeatureMap.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 oneIMergeViewerIteminsertion point should be created.- Parameters:
diffs- theDiffs.configuration- theIMergeViewerItemProviderConfiguration.comparison- theComparison.- Returns:
trueif at least oneIMergeViewerItemshould be created,falseotherwise.
-
yieldsMergeViewerItem
Indicates whether for the given values at least oneIMergeViewerItemshould be created.- Parameters:
comparison- theComparison.diff- theDiff.values- the values.- Returns:
trueif at least oneIMergeViewerItemshould be created,falseotherwise.
-
getVisibleContainmentDiffs
protected Iterable<? extends Diff> getVisibleContainmentDiffs(EObject object, IMergeViewerItemProviderConfiguration configuration) Determines all differences regarding the givenobjectwhich are related to a containment reference change and are visible in the viewer.- Parameters:
object- theEObject.configuration- theIMergeViewerItemProviderConfiguration.- Returns:
- all visible diffs regarding
objectrelated to containment differences.
-
getBestSideValue
protected Object getBestSideValue(IMergeViewerItem mergeViewerItem, IMergeViewer.MergeViewerSide side) Get a non-null side of the the givenIMergeViewerItem, preferring but not limited to the given side.- Parameters:
mergeViewerItem- theIMergeViewerItem.side-IMergeViewer.MergeViewerSide- Returns:
- the side object. May be null if all sides are null.
-
getSideValue
- Parameters:
mergeViewerItem-- See Also:
-
createBasicContainer
protected IMergeViewerItem createBasicContainer(ResourceAttachmentChange diff, IMergeViewerItem mergeViewerItem, AdapterFactory adapterFactory) Create an IMergeViewerItem for the parent of the givenResourceAttachmentChange.- Parameters:
diff- the givenResourceAttachmentChange.- Returns:
- an IMergeViewerItem.
-
visibleContainmentDiffPredicate
protected com.google.common.base.Predicate<Diff> visibleContainmentDiffPredicate(IMergeViewerItemProviderConfiguration configuration) Predicate for checking if the givendiffis visible and itself (or any of its 'refining' diffs) is a containment reference change.- Parameters:
configuration- theIMergeViewerItemProviderConfiguration.- 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 givendiffis visible in the merge viewer.- Parameters:
predicate- the filteringPredicate.groupProvider- the activeIDifferenceGroupProvider.- Returns:
- the
Predicate.
-
createMergeViewerItemsFrom
protected List<IMergeViewerItem> createMergeViewerItemsFrom(Collection<?> values, IMergeViewerItem parent, IMergeViewerItemProviderConfiguration configuration) Creates the Merge Viewer Items for the givenvalues.- Parameters:
values- the object for whichIMergeViewerItems shall be created.parent- theIMergeViewerItemparent of the children to createconfiguration- theIMergeViewerItemProviderConfiguration.- Returns:
-
createMergeViewerItemFrom
protected IMergeViewerItem createMergeViewerItemFrom(EObject eObject, IMergeViewerItem parent, IMergeViewerItemProviderConfiguration configuration) Creates an IMergeViewerItem from an EObject.- Parameters:
eObject- the given eObject.parent- theIMergeViewerItemparent of the child to create.configuration- theIMergeViewerItemProviderConfiguration.- Returns:
- an IMergeViewerItem.
-
createMergeViewerItem
protected IMergeViewerItem createMergeViewerItem(Comparison comparison, Diff diff, Object left, Object right, Object ancestor, IMergeViewer.MergeViewerSide side, AdapterFactory adapterFactory) Creates theIMergeViewerItemfrom the given data.- Parameters:
comparison- theComparison.diff- theDiff. 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- theIMergeViewer.MergeViewerSide.adapterFactory- theAdapterFactory.- Returns:
- the created
IMergeViewerItem.
-
createMergeViewerItem
protected IMergeViewerItem createMergeViewerItem(Comparison comparison, Diff diff, Match match, IMergeViewer.MergeViewerSide side, AdapterFactory adapterFactory) Creates theIMergeViewerItemfrom the given data.- Parameters:
comparison- theComparison.diff- theDiff. May be null.match- theMatch.side- theIMergeViewer.MergeViewerSide.adapterFactory- theAdapterFactory.- Returns:
- the created
IMergeViewerItem.
-