Class AbstractContainmentAdapter
- All Implemented Interfaces:
org.eclipse.ui.IContainmentAdapter
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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
protected boolean
Returns whether the given resource is considered contained in the given containment context or if it corresponds to the context itself.protected boolean
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, 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.
-
Constructor Details
-
AbstractContainmentAdapter
public AbstractContainmentAdapter()
-
-
Method Details
-
contains
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
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
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
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
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
-