1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.typehierarchy;
13 import java.util.List;
15 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.jdt.core.IType;
18 import org.eclipse.jdt.core.ITypeHierarchy;
21 * A viewer including the content provider for the supertype hierarchy.
22 * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
23 * on construction (shared type hierarchy)
25 public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
27 public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle) {
28 super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle);
32 * @see TypeHierarchyViewer#updateContent
35 public void updateContent(boolean expand) {
36 getTree().setRedraw(false);
41 getTree().setRedraw(true);
45 * Content provider for the supertype hierarchy
47 public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
48 public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
53 protected final void getTypesInHierarchy(IType type, List<IType> res) {
54 ITypeHierarchy hierarchy= getHierarchy();
55 if (hierarchy != null) {
56 IType[] types= hierarchy.getSupertypes(type);
57 for (int i= 0; i < types.length; i++) {
64 protected IType getParentType(IType type) {