01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.dialogs;
11:
12: import org.eclipse.jface.preference.IPreferenceNode;
13: import org.eclipse.jface.preference.PreferenceManager;
14: import org.eclipse.ui.internal.WorkbenchPlugin;
15:
16: /**
17: * This class is created to avoid mentioning preferences
18: * in this context. Ideally, JFace preference classes should be
19: * renamed into something more generic (for example,
20: * 'TreeNavigationDialog').
21: */
22:
23: public class PropertyPageManager extends PreferenceManager {
24: /**
25: * The constructor.
26: */
27: public PropertyPageManager() {
28: super (WorkbenchPlugin.PREFERENCE_PAGE_CATEGORY_SEPARATOR);
29: }
30:
31: /**
32: * Given a category search he entire tree and add the node. This
33: * is to handle the case of categories beyond the first level.
34: * @param category
35: * @param node
36: * @see #addTo(String, PropertyPageNode)
37: * @return boolean <code>true</code> if it was added/
38: */
39: public boolean addToDeep(String category, PropertyPageNode node) {
40:
41: return addToDeep(category, node, getRoot());
42: }
43:
44: /**
45: * Given a category search the entire tree and add the node. This
46: * is to handle the case of categories beyond the first level.
47: * @param category
48: * @param node
49: * @param top the node to add to if it is found.
50: * @see #addTo(String, PropertyPageNode)
51: * @return boolean <code>true</code> if it was added somewhere
52: */
53: public boolean addToDeep(String category, PropertyPageNode node,
54: IPreferenceNode top) {
55:
56: IPreferenceNode target = find(category, top);
57: if (target != null) {
58: target.add(node);
59: return true;
60: }
61:
62: IPreferenceNode[] subNodes = top.getSubNodes();
63: for (int i = 0; i < subNodes.length; i++) {
64: if (addToDeep(category, node, subNodes[i])) {
65: return true;
66: }
67: }
68:
69: return false;
70: }
71: }
|