Class AbstractContainmentAdapter
- java.lang.Object
-
- org.eclipse.handly.ui.workingset.AbstractContainmentAdapter
-
- All Implemented Interfaces:
org.eclipse.ui.IContainmentAdapter
public abstract class AbstractContainmentAdapter extends java.lang.Object implements org.eclipse.ui.IContainmentAdapter
A partial implementation ofIContainmentAdapter
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
-
-
Constructor Summary
Constructors Constructor Description AbstractContainmentAdapter()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static boolean
checkContext(int flags)
Returns whether theCHECK_CONTEXT
flag is set.protected static boolean
checkIfAncestor(int flags)
Returns whether theCHECK_IF_ANCESTOR
flag is set.protected static boolean
checkIfChild(int flags)
Returns whether theCHECK_IF_CHILD
flag is set.protected static boolean
checkIfDescendant(int flags)
Returns whether theCHECK_IF_DESCENDANT
flag is set.boolean
contains(java.lang.Object containmentContext, java.lang.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
getContentAdapter()
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, ornull
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.
-
-
-
Method Detail
-
contains
public boolean contains(java.lang.Object containmentContext, java.lang.Object element, int flags)
This implementation returns
false
if the specified containment context could not be adapted to anIElement
through thecontent adapter
. Otherwise, it attempts to adapt the given element to anIElement
either via the content adapter or, failing that, by first attempting to adapt it to anIResource
and then callinggetElementFor(IResource)
. If the given element could be adapted to anIElement
, this implementation delegates tocontains(IElement, IElement, int)
. If the given element could be adapted to anIResource
but not to anIElement
, this implementation delegates tocontains(IElement, IResource, int)
. Otherwise,false
is returned.- Specified by:
contains
in interfaceorg.eclipse.ui.IContainmentAdapter
-
getElementFor
protected abstract IElement getElementFor(org.eclipse.core.resources.IResource resource)
Returns the model element corresponding to the given resource, ornull
if no such element can be found.- Parameters:
resource
- nevernull
- 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
(nevernull
)
-
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
- nevernull
element
- nevernull
flags
- one or more ofCHECK_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, andfalse
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
- nevernull
other
- nevernull
- Returns:
true
if the element is an ancestor of the other element, andfalse
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
- nevernull
resource
- nevernull
flags
- one or more ofCHECK_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, andfalse
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
- nevernull
other
- nevernull
- Returns:
true
if the resource is an ancestor of the other resource, andfalse
otherwise
-
checkContext
protected static boolean checkContext(int flags)
Returns whether theCHECK_CONTEXT
flag is set.- Parameters:
flags
- one or more ofCHECK_CONTEXT
,CHECK_IF_CHILD
,CHECK_IF_ANCESTOR
,CHECK_IF_DESCENDENT
logically ORed together- Returns:
true
if theCHECK_CONTEXT
flag is set, andfalse
otherwise
-
checkIfChild
protected static boolean checkIfChild(int flags)
Returns whether theCHECK_IF_CHILD
flag is set.- Parameters:
flags
- one or more ofCHECK_CONTEXT
,CHECK_IF_CHILD
,CHECK_IF_ANCESTOR
,CHECK_IF_DESCENDENT
logically ORed together- Returns:
true
if theCHECK_IF_CHILD
flag is set, andfalse
otherwise
-
checkIfAncestor
protected static boolean checkIfAncestor(int flags)
Returns whether theCHECK_IF_ANCESTOR
flag is set.- Parameters:
flags
- one or more ofCHECK_CONTEXT
,CHECK_IF_CHILD
,CHECK_IF_ANCESTOR
,CHECK_IF_DESCENDENT
logically ORed together- Returns:
true
if theCHECK_IF_ANCESTOR
flag is set, andfalse
otherwise
-
checkIfDescendant
protected static boolean checkIfDescendant(int flags)
Returns whether theCHECK_IF_DESCENDANT
flag is set.- Parameters:
flags
- one or more ofCHECK_CONTEXT
,CHECK_IF_CHILD
,CHECK_IF_ANCESTOR
,CHECK_IF_DESCENDENT
logically ORed together- Returns:
true
if theCHECK_IF_DESCENDANT
flag is set, andfalse
otherwise
-
-