Class FilteringTreeContentProvider
- java.lang.Object
-
- com._1c.g5.v8.dt.navigator.providers.FilteringTreeContentProvider
-
- All Implemented Interfaces:
IContentProvider
,IStructuredContentProvider
,ITreeContentProvider
- Direct Known Subclasses:
CommandFilteringTreeContentProvider
,ContainmentTreeContentProvider
,FormFilteringTreeContentProvider
,RoleFilteringTreeContentProvider
,SubsystemFilteringTreeContentProvider
public class FilteringTreeContentProvider extends Object implements ITreeContentProvider
The implementation ofITreeContentProvider
. When you call methodsgetElements(Object)
andgetChildren(Object)
to filter children it firstly tries to useISubtreeInducer
if possible, then usesTreeItemFilter
's.ISubtreeInducer
is needed in order to at first move quickly from the source tree to its subtree and then applyTreeItemFilter
's on its subtree.
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Object>
hasMatchingDescendants
The tree nodes having matching descendants.protected ITreeContentProvider
sourceProvider
The source provider.protected ISubtreeInducer
subtreeInducer
protected TreeItemFilter[]
treeItemFilters
-
Constructor Summary
Constructors Constructor Description FilteringTreeContentProvider(ITreeContentProvider sourceProvider, ISubtreeInducer subtreeInducer, TreeItemFilter... treeItemFilters)
Creates a new instance with the given parameters.FilteringTreeContentProvider(ITreeContentProvider sourceProvider, TreeItemFilter... treeItemFilters)
Creates a new instance with the given parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
protected void
dropCache()
Drops all collected cache.protected Object[]
filterChildren(Object[] children)
Filters the given children.protected Object[]
filterChildrenBySubtreeInducer(Object parent, Object[] children)
Filters children of the given parent element byISubtreeInducer
.Object[]
getChildren(Object parentElement)
Object[]
getElements(Object inputElement)
Object
getParent(Object element)
protected boolean
hasAnyMatchingChildren(Object element)
Determines if the given tree element has any matching children in its subtree, that is at least one matching child.boolean
hasChildren(Object element)
boolean
hasChildrenLightweight(Object element)
Returns whether the given element has children, no heavy calculations and no callinggetChildren(Object)
method.protected boolean
hasMatchingDescendants(Object element)
Determines if the given tree element has matching descendants in its subtree.protected boolean
hasOuterToSubtreeChildren(Object node)
Determines if the specified node may have children from the source tree that are not the induced subgraph nodes.void
inputChanged(Viewer viewer, Object oldInput, Object newInput)
protected boolean
inSubgraph(Object node)
Determines if the given node belongs to the induced subgraph.protected boolean
isSubgraphInnerNode(Object element)
Determines if the specified element is inner node in the induced subgraph.protected boolean
keepChild(Object child)
Determines if to keep the given child or filter it out.
-
-
-
Field Detail
-
hasMatchingDescendants
protected Set<Object> hasMatchingDescendants
The tree nodes having matching descendants.
-
sourceProvider
protected final ITreeContentProvider sourceProvider
The source provider.
-
subtreeInducer
protected final ISubtreeInducer subtreeInducer
-
treeItemFilters
protected final TreeItemFilter[] treeItemFilters
-
-
Constructor Detail
-
FilteringTreeContentProvider
public FilteringTreeContentProvider(ITreeContentProvider sourceProvider, TreeItemFilter... treeItemFilters)
Creates a new instance with the given parameters. Uses onlyTreeItemFilter
's to filter the tree nodes.- Parameters:
sourceProvider
- the source provider, can not benull
treeItemFilters
- theTreeItemFilter
's to apply, can not benull
-
FilteringTreeContentProvider
public FilteringTreeContentProvider(ITreeContentProvider sourceProvider, ISubtreeInducer subtreeInducer, TreeItemFilter... treeItemFilters)
Creates a new instance with the given parameters. UsesTreeItemFilter
's andISubtreeInducer
to filter the tree nodes.- Parameters:
sourceProvider
- the source provider, can not benull
subtreeInducer
- theISubtreeInducer
to apply, may benull
. If subtreeInducer is null then it uses onlyTreeItemFilter
's to filter the tree nodes.treeItemFilters
- theTreeItemFilter
's to apply, can not benull
-
-
Method Detail
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceIContentProvider
-
inputChanged
public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- Specified by:
inputChanged
in interfaceIContentProvider
-
getElements
public Object[] getElements(Object inputElement)
- Specified by:
getElements
in interfaceIStructuredContentProvider
- Specified by:
getElements
in interfaceITreeContentProvider
-
getChildren
public Object[] getChildren(Object parentElement)
- Specified by:
getChildren
in interfaceITreeContentProvider
-
getParent
public Object getParent(Object element)
- Specified by:
getParent
in interfaceITreeContentProvider
-
hasChildren
public boolean hasChildren(Object element)
- Specified by:
hasChildren
in interfaceITreeContentProvider
-
hasChildrenLightweight
public boolean hasChildrenLightweight(Object element)
Returns whether the given element has children, no heavy calculations and no callinggetChildren(Object)
method.- Parameters:
element
- the given element, can not benull
- Returns:
true
if the given element has children, andfalse
if it has no children
-
hasMatchingDescendants
protected boolean hasMatchingDescendants(Object element)
Determines if the given tree element has matching descendants in its subtree.- Parameters:
element
- the given tree element, can not benull
- Returns:
true
if the given tree element has matching descendants in its subtree andfalse
otherwise
-
hasAnyMatchingChildren
protected boolean hasAnyMatchingChildren(Object element)
Determines if the given tree element has any matching children in its subtree, that is at least one matching child.- Parameters:
element
- the given tree element, can not benull
- Returns:
true
if the given tree element has any matching children in its subtree andfalse
otherwise
-
filterChildrenBySubtreeInducer
protected Object[] filterChildrenBySubtreeInducer(Object parent, Object[] children)
Filters children of the given parent element byISubtreeInducer
. Keeps children that got into the set of vertices generated byISubtreeInducer
.- Parameters:
parent
- the parent element, can not benull
children
- the children elements, can not benull
- Returns:
- the filtered children, can not be
null
-
filterChildren
protected Object[] filterChildren(Object[] children)
Filters the given children.- Parameters:
children
- the given children elements, can not benull
- Returns:
- the filtered children, can not be
null
-
inSubgraph
protected boolean inSubgraph(Object node)
Determines if the given node belongs to the induced subgraph.- Parameters:
node
- the given node from the source tree, can not benull
- Returns:
true
the given node belongs to the induced subgraph andfalse
otherwise
-
isSubgraphInnerNode
protected boolean isSubgraphInnerNode(Object element)
Determines if the specified element is inner node in the induced subgraph.- Parameters:
element
- the specified node from the origin tree, can not benull
- Returns:
true
if the specified node is inner node in the induced subgraph andfalse
otherwise
-
hasOuterToSubtreeChildren
protected boolean hasOuterToSubtreeChildren(Object node)
Determines if the specified node may have children from the source tree that are not the induced subgraph nodes.- Parameters:
node
- the specified node from the origin tree, can not benull
- Returns:
true
if the specified node may have children from the source tree that are not the induced subgraph nodes andfalse
otherwise
-
dropCache
protected void dropCache()
Drops all collected cache.
-
keepChild
protected boolean keepChild(Object child)
Determines if to keep the given child or filter it out.- Parameters:
child
- the given child, can not benull
- Returns:
true
to keep the given child,false
to filter it out
-
-