1 11 package org.eclipse.jdt.internal.ui.typehierarchy; 12 13 import java.util.List ; 14 15 import org.eclipse.swt.widgets.Composite; 16 17 import org.eclipse.ui.IWorkbenchPart; 18 19 import org.eclipse.jdt.core.IType; 20 import org.eclipse.jdt.core.ITypeHierarchy; 21 22 27 public class SubTypeHierarchyViewer extends TypeHierarchyViewer { 28 29 public SubTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) { 30 super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle, part); 31 } 32 33 36 public String getTitle() { 37 if (isMethodFiltering()) { 38 return TypeHierarchyMessages.SubTypeHierarchyViewer_filtered_title; 39 } else { 40 return TypeHierarchyMessages.SubTypeHierarchyViewer_title; 41 } 42 } 43 44 47 public void updateContent(boolean expand) { 48 getTree().setRedraw(false); 49 refresh(); 50 51 if (expand) { 52 int expandLevel= 2; 53 if (isMethodFiltering()) { 54 expandLevel++; 55 } 56 expandToLevel(expandLevel); 57 } 58 getTree().setRedraw(true); 59 } 60 61 64 public static class SubTypeHierarchyContentProvider extends TypeHierarchyContentProvider { 65 public SubTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) { 66 super(lifeCycle); 67 } 68 69 protected final void getTypesInHierarchy(IType type, List res) { 70 ITypeHierarchy hierarchy= getHierarchy(); 71 if (hierarchy != null) { 72 IType[] types= hierarchy.getSubtypes(type); 73 if (isObject(type)) { 74 for (int i= 0; i < types.length; i++) { 75 IType curr= types[i]; 76 if (!isAnonymousFromInterface(curr)) { 77 res.add(curr); 78 } 79 } 80 } else { 81 for (int i= 0; i < types.length; i++) { 82 res.add(types[i]); 83 } 84 } 85 } 86 87 } 88 89 protected IType getParentType(IType type) { 90 ITypeHierarchy hierarchy= getHierarchy(); 91 if (hierarchy != null) { 92 return hierarchy.getSuperclass(type); 93 } 95 return null; 96 } 97 98 } 99 100 101 102 } 103 | Popular Tags |