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:
-
Field Summary
Fields inherited from interface org.eclipse.ui.IContainmentAdapter
CHECK_CONTEXT, CHECK_IF_ANCESTOR, CHECK_IF_CHILD, CHECK_IF_DESCENDANT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleancheckContext(int flags) Returns whether theCHECK_CONTEXTflag is set.protected static booleancheckIfAncestor(int flags) Returns whether theCHECK_IF_ANCESTORflag is set.protected static booleancheckIfChild(int flags) Returns whether theCHECK_IF_CHILDflag is set.protected static booleancheckIfDescendant(int flags) Returns whether theCHECK_IF_DESCENDANTflag is set.booleanprotected booleanReturns whether the given resource is considered contained in the given containment context or if it corresponds to the context itself.protected booleanReturns whether the given element is considered contained in the given containment context or if it is the context itself.protected IContentAdapterReturns the content adapter that defines a mapping between elements of a Handly-based model and the working set's content.protected abstract IElementgetElementFor(org.eclipse.core.resources.IResource resource) Returns the model element corresponding to the given resource, ornullif no such element can be found.protected booleanisAncestorOf(org.eclipse.core.resources.IResource resource, org.eclipse.core.resources.IResource other) Returns whether the resource is an ancestor of the other resource.protected booleanisAncestorOf(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
falseif the specified containment context could not be adapted to anIElementthrough thecontent adapter. Otherwise, it attempts to adapt the given element to anIElementeither via the content adapter or, failing that, by first attempting to adapt it to anIResourceand 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 anIResourcebut not to anIElement, this implementation delegates tocontains(IElement, IResource, int). Otherwise,falseis returned.- Specified by:
containsin interfaceorg.eclipse.ui.IContainmentAdapter
-
getElementFor
Returns the model element corresponding to the given resource, ornullif no such element can be found.- Parameters:
resource- nevernull- Returns:
- the model element corresponding to the given resource,
or
nullif 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- nevernullelement- nevernullflags- one or more ofCHECK_CONTEXT,CHECK_IF_CHILD,CHECK_IF_ANCESTOR,CHECK_IF_DESCENDENTlogically ORed together- Returns:
trueif the given element is considered contained in the given containment context or if it is context itself, andfalseotherwise
-
isAncestorOf
Returns whether the element is an ancestor of the other element. Does not include the other element itself.- Parameters:
element- nevernullother- nevernull- Returns:
trueif the element is an ancestor of the other element, andfalseotherwise
-
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- nevernullresource- nevernullflags- one or more ofCHECK_CONTEXT,CHECK_IF_CHILD,CHECK_IF_ANCESTOR,CHECK_IF_DESCENDENTlogically ORed together- Returns:
trueif the given resource is considered contained in the given containment context or if it corresponds to the context itself, andfalseotherwise
-
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- nevernullother- nevernull- Returns:
trueif the resource is an ancestor of the other resource, andfalseotherwise
-
checkContext
protected static boolean checkContext(int flags) Returns whether theCHECK_CONTEXTflag is set.- Parameters:
flags- one or more ofCHECK_CONTEXT,CHECK_IF_CHILD,CHECK_IF_ANCESTOR,CHECK_IF_DESCENDENTlogically ORed together- Returns:
trueif theCHECK_CONTEXTflag is set, andfalseotherwise
-
checkIfChild
protected static boolean checkIfChild(int flags) Returns whether theCHECK_IF_CHILDflag is set.- Parameters:
flags- one or more ofCHECK_CONTEXT,CHECK_IF_CHILD,CHECK_IF_ANCESTOR,CHECK_IF_DESCENDENTlogically ORed together- Returns:
trueif theCHECK_IF_CHILDflag is set, andfalseotherwise
-
checkIfAncestor
protected static boolean checkIfAncestor(int flags) Returns whether theCHECK_IF_ANCESTORflag is set.- Parameters:
flags- one or more ofCHECK_CONTEXT,CHECK_IF_CHILD,CHECK_IF_ANCESTOR,CHECK_IF_DESCENDENTlogically ORed together- Returns:
trueif theCHECK_IF_ANCESTORflag is set, andfalseotherwise
-
checkIfDescendant
protected static boolean checkIfDescendant(int flags) Returns whether theCHECK_IF_DESCENDANTflag is set.- Parameters:
flags- one or more ofCHECK_CONTEXT,CHECK_IF_CHILD,CHECK_IF_ANCESTOR,CHECK_IF_DESCENDENTlogically ORed together- Returns:
trueif theCHECK_IF_DESCENDANTflag is set, andfalseotherwise
-