1 11 package org.eclipse.ui.internal.dialogs; 12 13 import java.util.Collection ; 14 import java.util.HashSet ; 15 16 import org.eclipse.jface.preference.IPreferenceNode; 17 import org.eclipse.jface.viewers.Viewer; 18 import org.eclipse.jface.viewers.ViewerFilter; 19 20 24 public class PreferenceNodeFilter extends ViewerFilter { 25 26 Collection ids = new HashSet (); 27 28 34 public PreferenceNodeFilter(String [] filteredIds) { 35 super(); 36 for (int i = 0; i < filteredIds.length; i++) { 37 ids.add(filteredIds[i]); 38 } 39 } 40 41 44 public boolean select(Viewer viewer, Object parentElement, Object element) { 45 return checkNodeAndChildren((IPreferenceNode) element); 46 } 47 48 55 private boolean checkNodeAndChildren(IPreferenceNode node) { 56 if(ids.contains(node.getId())) { 57 return true; 58 } 59 60 IPreferenceNode[] subNodes = node.getSubNodes(); 61 for (int i = 0; i < subNodes.length; i++) { 62 if(checkNodeAndChildren(subNodes[i])) { 63 return true; 64 } 65 66 } 67 return false; 68 } 69 70 } 71 | Popular Tags |