/** * @param element must be an instance of <code>IPreferenceNode</code>. * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) */ @Override public String getText(Object element) { return ((IPreferenceNode) element).getLabelText(); }
/** * 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); } }
@Override void add(Object parent, Object node) { ((IPreferenceNode) parent).add((IPreferenceNode) node); }
/** * 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; }
/** * 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; }
@Override public String getId() { return preferenceNode.getId(); }
@Override protected boolean showPage(IPreferenceNode node) { final boolean success = super.showPage(node); if (success) { history.addHistoryEntry(new PreferenceHistoryEntry(node.getId(), node.getLabelText(), null)); } return success; }
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); } } }
/** * Get the page for the node. * @param node * @return IPreferencePage * * @since 3.1 */ protected IPreferencePage getPage(IPreferenceNode node) { return node.getPage(); }
@Override public Object[] getChildren(Object parentElement) {//must be an instance of <code>IPreferenceNode</code>. return ((IPreferenceNode) parentElement).getSubNodes(); }
while (nodes.hasNext()) { IPreferenceNode node = nodes.next(); IPreferencePage page = node.getPage(); if (page instanceof PropertyPreferencePage) { PropertyPreferencePage preferencePage = (PropertyPreferencePage) page; preferencePage.showAdvanced(show); if (show || showIfNoAdvanced(node)) { idsToShow.add(node.getId());
/** * 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; }
/** * 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; } }
/** * @param element must be an instance of <code>IPreferenceNode</code>. * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) */ public Image getImage(Object element) { return ((IPreferenceNode) element).getLabelImage(); } }
@Override public void run() throws Exception { List<IPreferenceNode> nodes = preferenceManager.getElements(PreferenceManager.PRE_ORDER); for (int i = 0; i < nodes.size(); i++) { IPreferenceNode node = nodes.get(i); node.disposeResources(); } }
/** * Removes the preference node at the given path. * * @param path * the path * @return the node that was removed, or <code>null</code> if there was no * node at the given path */ public IPreferenceNode remove(String path) { Assert.isNotNull(path); int index = path.lastIndexOf(separator); if (index == -1) { return root.remove(path); } // Make sure that the last character in the string isn't the "." Assert.isTrue(index < path.length() - 1, "Path can not end with a dot");//$NON-NLS-1$ String parentPath = path.substring(0, index); String id = path.substring(index + 1); IPreferenceNode parentNode = find(parentPath); if (parentNode == null) { return null; } return parentNode.remove(id); }
/** * Create the page for the node. * @param node * * @since 3.1 */ protected void createPage(IPreferenceNode node) { node.createPage(); }
@Override public String getId() { return preferenceNode.getId(); }
/** * 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; }