/** @param children list of elements to be expand with their children */ private void expandChildrenElements(Object[] children, boolean fullExpand) { for (int i = 0; i < children.length; i++) { Object child = children[i]; if (child instanceof PluginParentNode) { PluginParentNode node = (PluginParentNode) child; if (node.getChildCount() > 0 && fullExpand) { boolean furtherExpanding = !(node instanceof PluginExtensionNode && !fExtensionTree.getExpandedState(node)); expandChildrenElements(node.getChildren(), furtherExpanding); } else { fExtensionTree.expandToLevel(node, 0); } } } }
/** * Determines whether the selected leafs are expandable * * @param selection selection to test each item with * @return whether the selection can be expanded */ public static boolean isExpandable(IStructuredSelection selection) { boolean isExpandable = false; if (selection != null) { if (!selection.isEmpty()) { for (Iterator<?> iterator = selection.iterator(); iterator.hasNext(); ) { Object element = iterator.next(); if (element instanceof PluginParentNode) { PluginParentNode node = (PluginParentNode) element; if (node.getChildCount() > 0) { isExpandable = true; break; } } } } } return isExpandable; }