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
  • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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 DiffNodes that represent the diff should always be children of the MatchNodes 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.