]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/typehierarchy/SuperTypeHierarchyViewer.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / typehierarchy / SuperTypeHierarchyViewer.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
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.jdt.core.IType;
18 import org.eclipse.jdt.core.ITypeHierarchy;
19
20 /**
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)
24  */
25 public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
26
27         public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle) {
28                 super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle);
29         }
30
31         /*
32          * @see TypeHierarchyViewer#updateContent
33          */
34         @Override
35         public void updateContent(boolean expand) {
36                 getTree().setRedraw(false);
37                 refresh();
38                 if (expand) {
39                         expandAll();
40                 }
41                 getTree().setRedraw(true);
42         }
43
44         /*
45          * Content provider for the supertype hierarchy
46          */
47         public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
48                 public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
49                         super(lifeCycle);
50                 }
51
52                 @Override
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++) {
58                                         res.add(types[i]);
59                                 }
60                         }
61                 }
62
63                 @Override
64                 protected IType getParentType(IType type) {
65                         // cant handle
66                         return null;
67                 }
68
69         }
70
71 }