Search in sources :

Example 1 with IInteractionElement

use of org.eclipse.mylyn.context.core.IInteractionElement in project mylyn.docs by eclipse.

the class ActiveFoldingListener method updateFolding.

private void updateFolding(boolean elementsDeleted) {
    if (!foldingStructure.isFoldingEnabled()) {
        return;
    }
    if (!foldingEnabled || !ContextCore.getContextManager().isContextActive()) {
        foldingStructure.expandAll();
    } else {
        OutlineItem outline = (OutlineItem) part.getAdapter(OutlineItem.class);
        if (outline != null) {
            final List<OutlineItem> toExpand = new ArrayList<OutlineItem>();
            outline.accept(new Visitor() {

                public boolean visit(OutlineItem item) {
                    String identifier = bridge.getHandleIdentifier(item);
                    IInteractionElement element = ContextCore.getContextManager().getElement(identifier);
                    if (element != null && element.getInterest().isInteresting()) {
                        toExpand.add(item);
                    }
                    return true;
                }
            });
            if (toExpand.isEmpty()) {
                foldingStructure.collapseAll(elementsDeleted);
            } else {
                foldingStructure.expandElementsExclusive(toExpand, elementsDeleted);
            }
        }
    }
}
Also used : Visitor(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem.Visitor) ArrayList(java.util.ArrayList) IInteractionElement(org.eclipse.mylyn.context.core.IInteractionElement) OutlineItem(org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)

Aggregations

ArrayList (java.util.ArrayList)1 IInteractionElement (org.eclipse.mylyn.context.core.IInteractionElement)1 OutlineItem (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem)1 Visitor (org.eclipse.mylyn.wikitext.parser.outline.OutlineItem.Visitor)1