KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > typehierarchy > SuperTypeHierarchyViewer


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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 JavaDoc;
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 /**
23  * A viewer including the content provider for the supertype hierarchy.
24  * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
25  * on construction (shared type hierarchy)
26  */

27 public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
28     
29     public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
30         super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
31     }
32
33     /*
34      * @see TypeHierarchyViewer#getTitle
35      */

36     public String JavaDoc getTitle() {
37         if (isMethodFiltering()) {
38             return TypeHierarchyMessages.SuperTypeHierarchyViewer_filtered_title;
39         } else {
40             return TypeHierarchyMessages.SuperTypeHierarchyViewer_title;
41         }
42     }
43
44     /*
45      * @see TypeHierarchyViewer#updateContent
46      */

47     public void updateContent(boolean expand) {
48         getTree().setRedraw(false);
49         refresh();
50         if (expand) {
51             expandAll();
52         }
53         getTree().setRedraw(true);
54     }
55     
56     /*
57      * Content provider for the supertype hierarchy
58      */

59     public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
60         public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
61             super(lifeCycle);
62         }
63         
64         protected final void getTypesInHierarchy(IType type, List JavaDoc res) {
65             ITypeHierarchy hierarchy= getHierarchy();
66             if (hierarchy != null) {
67                 IType[] types= hierarchy.getSupertypes(type);
68                 for (int i= 0; i < types.length; i++) {
69                     res.add(types[i]);
70                 }
71             }
72         }
73         
74         protected IType getParentType(IType type) {
75             // cant handle
76
return null;
77         }
78         
79     }
80
81 }
82
Popular Tags