Viewing the Type Hierarchy

In this section, you will learn about using the Hierarchy view.
 
1.
In the Package Explorer view, find junit.framework.TestCase.java. From its context menu, select Open Type Hierarchy. You can also open type hierarchy view:
  • from the menu bar by selecting Navigate > Open Type Hierarchy
  • from the keyboard by pressing F4 after selecting TestCase.java
  • by using drag and drop by dropping TestCase.java to an open hierarchy view.
Context menu
2.
In the Hierarchy view, click the Show the Type Hierarchy button to see the class hierarchy, including the base classes and subclasses.
The small arrow on the left side of the type icon of TestCase indicates that the hierarchy was opened on this type.
Type hierarchy
3.
Click the Show the Supertype Hierarchy button to see a hierarchy showing the type's parent elements including implemented interfaces,  i.e., the results of going up the type hierarchy.
Supertype hierarchy
In this "reversed hierarchy" view, you can see that TestCase implements the Test interface.
4.
Click the Show the Subtype Hierarchy button in the view toolbar.
Subtype hierarchy
5.
Click the Lock View and Show Members in Hierarchy button in the toolbar of the member pane, then select the runTest() method in the member pane.
The view will now show all the types implementing runTest().
Subtype hierarchy showing method implementors
6.
In the Hierarchy view, click the Show the Supertype Hierarchy button. Then on the member pane, select countTestCases() to display the places where this method is overridden.
Supertype hierarchy showing method implementors
7.
In the Hierarchy view select the Test element and select Focus On 'Test' from its context menu. 
The resource containing the selected element is represented in the Hierarchy view and also opens in an active editor.
8.
Activate the Package Explorer view and select the package junit.framework. Use Open Type Hierarchy from its context menu.
A hierarchy is opened containing all classes of the package. For completion of the tree, the hierarchy also shows some classes from other packages. These types are shown by a type icon with a white fill. 
Hierarchy on a package
9. Use Previous Hierarchy Inputs to go back to a previously opened element. Click on the arrow next to the button to see a menu or click on the button to edit the history list.
History menu
10.
From the menu bar, select Window > Preferences. Go to Java and select Open a new Type Hierarchy Perspective. Then click OK.
11.
In the Hierarchy view, select the Test element again, and activate Open Type Hierarchy from the Navigate menu bar.
The resource containing the selected type is shown in a new perspective (the Hierarchy perspective), and its source is shown in the Java editor. 

By setting the preference option for viewing type hierarchy perspectives, you can have more than one type hierarchy in your workbench and switch between them as needed. 
You can also configure a new perspective to open in a new window under Window > Preferences > Workbench > Perspectives.