Class AbstractContainmentAdapter

java.lang.Object
org.eclipse.handly.ui.workingset.AbstractContainmentAdapter
All Implemented Interfaces:
org.eclipse.ui.IContainmentAdapter

public abstract class AbstractContainmentAdapter extends Object implements org.eclipse.ui.IContainmentAdapter
A partial implementation of IContainmentAdapter for Handly-based models.

Containment adapters provide a way to test element containment in a model-independent way. Each model may contribute a containment adapter via an adapter factory. The workbench will use the containment adapter to test if a given resource is part of a working set for the model.

See Also:
  • ResourceWorkingSetFilter
  • Field Summary

    Fields inherited from interface org.eclipse.ui.IContainmentAdapter

    CHECK_CONTEXT, CHECK_IF_ANCESTOR, CHECK_IF_CHILD, CHECK_IF_DESCENDANT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static boolean
    checkContext(int flags)
    Returns whether the CHECK_CONTEXT flag is set.
    protected static boolean
    checkIfAncestor(int flags)
    Returns whether the CHECK_IF_ANCESTOR flag is set.
    protected static boolean
    checkIfChild(int flags)
    Returns whether the CHECK_IF_CHILD flag is set.
    protected static boolean
    checkIfDescendant(int flags)
    Returns whether the CHECK_IF_DESCENDANT flag is set.
    boolean
    contains(Object containmentContext, Object element, int flags)
    protected boolean
    contains(IElement containmentContext, org.eclipse.core.resources.IResource resource, int flags)
    Returns whether the given resource is considered contained in the given containment context or if it corresponds to the context itself.
    protected boolean
    contains(IElement containmentContext, IElement element, int flags)
    Returns whether the given element is considered contained in the given containment context or if it is the context itself.
    protected IContentAdapter
    Returns the content adapter that defines a mapping between elements of a Handly-based model and the working set's content.
    protected abstract IElement
    getElementFor(org.eclipse.core.resources.IResource resource)
    Returns the model element corresponding to the given resource, or null if no such element can be found.
    protected boolean
    isAncestorOf(org.eclipse.core.resources.IResource resource, org.eclipse.core.resources.IResource other)
    Returns whether the resource is an ancestor of the other resource.
    protected boolean
    isAncestorOf(IElement element, IElement other)
    Returns whether the element is an ancestor of the other element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractContainmentAdapter

      public AbstractContainmentAdapter()
  • Method Details

    • contains

      public boolean contains(Object containmentContext, Object element, int flags)

      This implementation returns false if the specified containment context could not be adapted to an IElement through the content adapter. Otherwise, it attempts to adapt the given element to an IElement either via the content adapter or, failing that, by first attempting to adapt it to an IResource and then calling getElementFor(IResource). If the given element could be adapted to an IElement, this implementation delegates to contains(IElement, IElement, int). If the given element could be adapted to an IResource but not to an IElement, this implementation delegates to contains(IElement, IResource, int). Otherwise, false is returned.

      Specified by:
      contains in interface org.eclipse.ui.IContainmentAdapter
    • getElementFor

      protected abstract IElement getElementFor(org.eclipse.core.resources.IResource resource)
      Returns the model element corresponding to the given resource, or null if no such element can be found.
      Parameters:
      resource - never null
      Returns:
      the model element corresponding to the given resource, or null if no such element can be found
    • getContentAdapter

      protected IContentAdapter getContentAdapter()
      Returns the content adapter that defines a mapping between elements of a Handly-based model and the working set's content.

      Default implementation returns a NullContentAdapter. Subclasses may override.

      Returns:
      an IContentAdapter (never null)
    • contains

      protected boolean contains(IElement containmentContext, IElement element, int flags)
      Returns whether the given element is considered contained in the given containment context or if it is the context itself.
      Parameters:
      containmentContext - never null
      element - never null
      flags - one or more of CHECK_CONTEXT, CHECK_IF_CHILD, CHECK_IF_ANCESTOR, CHECK_IF_DESCENDENT logically ORed together
      Returns:
      true if the given element is considered contained in the given containment context or if it is context itself, and false otherwise
    • isAncestorOf

      protected boolean isAncestorOf(IElement element, IElement other)
      Returns whether the element is an ancestor of the other element. Does not include the other element itself.
      Parameters:
      element - never null
      other - never null
      Returns:
      true if the element is an ancestor of the other element, and false otherwise
    • contains

      protected boolean contains(IElement containmentContext, org.eclipse.core.resources.IResource resource, int flags)
      Returns whether the given resource is considered contained in the given containment context or if it corresponds to the context itself.
      Parameters:
      containmentContext - never null
      resource - never null
      flags - one or more of CHECK_CONTEXT, CHECK_IF_CHILD, CHECK_IF_ANCESTOR, CHECK_IF_DESCENDENT logically ORed together
      Returns:
      true if the given resource is considered contained in the given containment context or if it corresponds to the context itself, and false otherwise
    • isAncestorOf

      protected boolean isAncestorOf(org.eclipse.core.resources.IResource resource, org.eclipse.core.resources.IResource other)
      Returns whether the resource is an ancestor of the other resource. Does not include the other resource itself.
      Parameters:
      resource - never null
      other - never null
      Returns:
      true if the resource is an ancestor of the other resource, and false otherwise
    • checkContext

      protected static boolean checkContext(int flags)
      Returns whether the CHECK_CONTEXT flag is set.
      Parameters:
      flags - one or more of CHECK_CONTEXT, CHECK_IF_CHILD, CHECK_IF_ANCESTOR, CHECK_IF_DESCENDENT logically ORed together
      Returns:
      true if the CHECK_CONTEXT flag is set, and false otherwise
    • checkIfChild

      protected static boolean checkIfChild(int flags)
      Returns whether the CHECK_IF_CHILD flag is set.
      Parameters:
      flags - one or more of CHECK_CONTEXT, CHECK_IF_CHILD, CHECK_IF_ANCESTOR, CHECK_IF_DESCENDENT logically ORed together
      Returns:
      true if the CHECK_IF_CHILD flag is set, and false otherwise
    • checkIfAncestor

      protected static boolean checkIfAncestor(int flags)
      Returns whether the CHECK_IF_ANCESTOR flag is set.
      Parameters:
      flags - one or more of CHECK_CONTEXT, CHECK_IF_CHILD, CHECK_IF_ANCESTOR, CHECK_IF_DESCENDENT logically ORed together
      Returns:
      true if the CHECK_IF_ANCESTOR flag is set, and false otherwise
    • checkIfDescendant

      protected static boolean checkIfDescendant(int flags)
      Returns whether the CHECK_IF_DESCENDANT flag is set.
      Parameters:
      flags - one or more of CHECK_CONTEXT, CHECK_IF_CHILD, CHECK_IF_ANCESTOR, CHECK_IF_DESCENDENT logically ORed together
      Returns:
      true if the CHECK_IF_DESCENDANT flag is set, and false otherwise