KickJava   Java API By Example, From Geeks To Geeks.

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


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

11 package org.eclipse.ui.internal.dialogs;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.jface.preference.PreferenceContentProvider;
16 import org.eclipse.ui.activities.WorkbenchActivityHelper;
17
18 /**
19  * Adds activity filtering support to <code>PreferenceContentProvider</code>.
20  *
21  * @since 3.0
22  */

23 public class FilteredPreferenceContentProvider extends PreferenceContentProvider {
24     
25     /**
26      * Create a new instance of the <code>FilteringPreferenceContentProvider</code>.
27      *
28      */

29     public FilteredPreferenceContentProvider() {
30         //no-op
31
}
32
33     /* (non-Javadoc)
34      * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
35      */

36     public Object JavaDoc[] getChildren(Object JavaDoc parentElement) {
37         Object JavaDoc[] children = super.getChildren(parentElement);
38         ArrayList JavaDoc filteredChildren = new ArrayList JavaDoc(children.length);
39         for (int i = 0; i < children.length; i++) {
40             if (WorkbenchActivityHelper.filterItem(children[i]))
41                 continue;
42
43             filteredChildren.add(children[i]);
44         }
45         return filteredChildren.toArray();
46     }
47
48
49     /* (non-Javadoc)
50      * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
51      */

52     public Object JavaDoc getParent(Object JavaDoc element) {
53         Object JavaDoc parent = super.getParent(element);
54         if (WorkbenchActivityHelper.filterItem(parent))
55             return null;
56         return parent;
57     }
58 }
59
Popular Tags