KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > dialogs > PropertyPageManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal.dialogs;
12
13 import org.eclipse.jface.preference.IPreferenceNode;
14 import org.eclipse.jface.preference.PreferenceManager;
15 import org.eclipse.ui.internal.WorkbenchPlugin;
16
17 /**
18  * This class is created to avoid mentioning preferences
19  * in this context. Ideally, JFace preference classes should be
20  * renamed into something more generic (for example,
21  * 'TreeNavigationDialog').
22  */

23
24 public class PropertyPageManager extends PreferenceManager {
25     /**
26      * The constructor.
27      */

28     public PropertyPageManager() {
29         super(WorkbenchPlugin.PREFERENCE_PAGE_CATEGORY_SEPARATOR);
30     }
31
32     /**
33      * Given a category search he entire tree and add the node. This
34      * is to handle the case of categories beyond the first level.
35      * @param category
36      * @param node
37      * @see #addTo(String, PropertyPageNode)
38      * @return boolean <code>true</code> if it was added/
39      */

40     public boolean addToDeep(String JavaDoc category, PropertyPageNode node) {
41
42         return addToDeep(category, node, getRoot());
43     }
44
45     /**
46      * Given a category search the entire tree and add the node. This
47      * is to handle the case of categories beyond the first level.
48      * @param category
49      * @param node
50      * @param top the node to add to if it is found.
51      * @see #addTo(String, PropertyPageNode)
52      * @return boolean <code>true</code> if it was added somewhere
53      */

54     public boolean addToDeep(String JavaDoc category, PropertyPageNode node, 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 }
72
Popular Tags