@Override public Object[] getChildren(Object parentElement) {//must be an instance of <code>IPreferenceNode</code>. return ((IPreferenceNode) parentElement).getSubNodes(); }
@Override public Object[] getChildren(Object parentElement) {//must be an instance of <code>IPreferenceNode</code>. return ((IPreferenceNode) parentElement).getSubNodes(); }
public Object[] getChildren(Object parentElement) {//must be an instance of <code>IPreferenceNode</code>. return ((IPreferenceNode) parentElement).getSubNodes(); }
/** * Returns the root level nodes of this preference manager. * * @return an array containing the root nodes * @since 3.2 */ public final IPreferenceNode[] getRootSubNodes() { return getRoot().getSubNodes(); }
/** * Returns the root level nodes of this preference manager. * * @return an array containing the root nodes * @since 3.2 */ public final IPreferenceNode[] getRootSubNodes() { return getRoot().getSubNodes(); }
/** * Returns the root level nodes of this preference manager. * * @return an array containing the root nodes * @since 1.0 */ public final IPreferenceNode[] getRootSubNodes() { return getRoot().getSubNodes(); }
/** * Recursively enumerates all nodes at or below the given node * and adds them to the given list in the given order. * * @param node the starting node * @param sequence a read-write list of preference nodes * (element type: <code>IPreferenceNode</code>) * in the given order * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> */ protected void buildSequence(IPreferenceNode node, List<IPreferenceNode> sequence, int order) { if (order == PRE_ORDER) { sequence.add(node); } IPreferenceNode[] subnodes = node.getSubNodes(); for (IPreferenceNode subnode : subnodes) { buildSequence(subnode, sequence, order); } if (order == POST_ORDER) { sequence.add(node); } }
/** * Recursively enumerates all nodes at or below the given node * and adds them to the given list in the given order. * * @param node the starting node * @param sequence a read-write list of preference nodes * (element type: <code>IPreferenceNode</code>) * in the given order * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> */ protected void buildSequence(IPreferenceNode node, List<IPreferenceNode> sequence, int order) { if (order == PRE_ORDER) { sequence.add(node); } IPreferenceNode[] subnodes = node.getSubNodes(); for (int i = 0; i < subnodes.length; i++) { buildSequence(subnodes[i], sequence, order); } if (order == POST_ORDER) { sequence.add(node); } }
/** * Recursively enumerates all nodes at or below the given node * and adds them to the given list in the given order. * * @param node the starting node * @param sequence a read-write list of preference nodes * (element type: <code>IPreferenceNode</code>) * in the given order * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> */ protected void buildSequence(IPreferenceNode node, List sequence, int order) { if (order == PRE_ORDER) { sequence.add(node); } IPreferenceNode[] subnodes = node.getSubNodes(); for (int i = 0; i < subnodes.length; i++) { buildSequence(subnodes[i], sequence, order); } if (order == POST_ORDER) { sequence.add(node); } }
/** * Check to see if the node or any of its children * have an id in the ids. * @param node WorkbenchPreferenceNode * @return boolean <code>true</code> if node or oe of its children * has an id in the ids. */ private boolean checkNodeAndChildren(IPreferenceNode node) { if(ids.contains(node.getId())) { return true; } for (IPreferenceNode subNode : node.getSubNodes()) { if(checkNodeAndChildren(subNode)) { return true; } } return false; }
/** * Returns all preference nodes managed by this * manager. * * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> * @return a list of preference nodes * (element type: <code>IPreferenceNode</code>) * in the given order */ public List<IPreferenceNode> getElements(int order) { Assert.isTrue(order == PRE_ORDER || order == POST_ORDER, "invalid traversal order");//$NON-NLS-1$ ArrayList<IPreferenceNode> sequence = new ArrayList<>(); IPreferenceNode[] subnodes = getRoot().getSubNodes(); for (int i = 0; i < subnodes.length; i++) { buildSequence(subnodes[i], sequence, order); } return sequence; }
private void collectElements(String prefix, IPreferenceNode[] subNodes, List<PreferenceElement> result) { for (int i = 0; i < subNodes.length; i++) { if (!WorkbenchActivityHelper.filterItem(subNodes[i])) { PreferenceElement preferenceElement = new PreferenceElement(subNodes[i], prefix, this); result.add(preferenceElement); String nestedPrefix = prefix.length() == 0 ? subNodes[i].getLabelText() : (prefix + "/" + subNodes[i].getLabelText()); //$NON-NLS-1$ collectElements(nestedPrefix, subNodes[i].getSubNodes(), result); } } }
/** * Returns all preference nodes managed by this * manager. * * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> * @return a list of preference nodes * (element type: <code>IPreferenceNode</code>) * in the given order */ public List<IPreferenceNode> getElements(int order) { Assert.isTrue(order == PRE_ORDER || order == POST_ORDER, "invalid traversal order");//$NON-NLS-1$ ArrayList<IPreferenceNode> sequence = new ArrayList<>(); IPreferenceNode[] subnodes = getRoot().getSubNodes(); for (IPreferenceNode subnode : subnodes) { buildSequence(subnode, sequence, order); } return sequence; }
/** * Returns all preference nodes managed by this * manager. * * @param order the traversal order, one of * <code>PRE_ORDER</code> and <code>POST_ORDER</code> * @return a list of preference nodes * (element type: <code>IPreferenceNode</code>) * in the given order */ public List getElements(int order) { Assert.isTrue(order == PRE_ORDER || order == POST_ORDER, "invalid traversal order");//$NON-NLS-1$ ArrayList sequence = new ArrayList(); IPreferenceNode[] subnodes = getRoot().getSubNodes(); for (int i = 0; i < subnodes.length; i++) { buildSequence(subnodes[i], sequence, order); } return sequence; }
/** * Defines if node should be displayed if no advanced is selected. This method is recursive. * * @param node * Node to check. * @return <code>true</code> this node should be displayed if only normal properties are * defined. */ private boolean showIfNoAdvanced(IPreferenceNode node) { if (node.getPage() instanceof PropertyPreferencePage) { if (!((PropertyPreferencePage) node.getPage()).isAllAdvancedProperties()) { return true; } } if (ArrayUtils.isNotEmpty(node.getSubNodes())) { for (IPreferenceNode subNode : node.getSubNodes()) { if (showIfNoAdvanced(subNode)) { return true; } } } return false; }
/** * Iterate through the preference page and build the map of preference page * names to ids. * * @param values * The Map being populated with parameter values. * @param preferenceNodes * An array of <code>IPreferenceNode</code> to process. * @param namePrefix * A string incorporating the names of each parent * <code>IPreferenceNode</code> up to the root of the * preference page tree. This will be <code>null</code> for the * root level preference page nodes. */ private void collectParameterValues(final Map values, final IPreferenceNode[] preferenceNodes, final String namePrefix) { for (final IPreferenceNode preferenceNode : preferenceNodes) { final String name; if (namePrefix == null) { name = preferenceNode.getLabelText(); } else { name = namePrefix + WorkbenchMessages.PreferencePageParameterValues_pageLabelSeparator + preferenceNode.getLabelText(); } final String value = preferenceNode.getId(); values.put(name, value); collectParameterValues(values, preferenceNode.getSubNodes(), name); } }
/** * Find the parent of the provided node. Will search recursivly through the * preference tree. * * @param parent the possible parent node. * @param target the target child node. * @return the parent node of the child node. */ private IPreferenceNode findParent(IPreferenceNode parent, IPreferenceNode target) { if (parent.getId().equals(target.getId())) { return null; } IPreferenceNode found = parent.findSubNode(target.getId()); if (found != null) { return parent; } IPreferenceNode[] children = parent.getSubNodes(); for (IPreferenceNode element : children) { found = findParent(element, target); if (found != null) { return found; } } return null; }
/** * Find the parent of the provided node. Will search recursivly through the * preference tree. * * @param parent the possible parent node. * @param target the target child node. * @return the parent node of the child node. */ private IPreferenceNode findParent(IPreferenceNode parent, IPreferenceNode target) { if (parent.getId().equals(target.getId())) { return null; } IPreferenceNode found = parent.findSubNode(target.getId()); if (found != null) { return parent; } IPreferenceNode[] children = parent.getSubNodes(); for (int i = 0; i < children.length; i++) { found = findParent(children[i], target); if (found != null) { return found; } } return null; }
/** * Find the parent of the provided node. Will search recursivly through the * preference tree. * * @param parent the possible parent node. * @param target the target child node. * @return the parent node of the child node. */ private IPreferenceNode findParent(IPreferenceNode parent, IPreferenceNode target) { if (parent.getId().equals(target.getId())) { return null; } IPreferenceNode found = parent.findSubNode(target.getId()); if (found != null) { return parent; } IPreferenceNode[] children = parent.getSubNodes(); for (int i = 0; i < children.length; i++) { found = findParent(children[i], target); if (found != null) { return found; } } return null; }
/** * Removes the node from the manager, searching through all subnodes. * * @param parent * the node to search * @param nodeToRemove * the node to remove * @return whether the node was removed */ private boolean deepRemove(IPreferenceNode parent, IPreferenceNode nodeToRemove) { if (parent == nodeToRemove) { if (parent == getRoot()) { removeAll(); // we're removing the root return true; } } if (parent.remove(nodeToRemove)) { return true; } for (IPreferenceNode subNode : parent.getSubNodes()) { if (deepRemove(subNode, nodeToRemove)) { return true; } } return false; } }