Viewing the Type Hierarchy

In this section, you will learn about using the Hierarchy view.

1.

In the Packages view, find junit.framework.TestCase.java and from its context menu, select Open Type Hierarchy (or select from the menu bar Edit > Open Type Hierarchy).

2.

In the Hierarchy view, click the Show the Type Hierarchy button to see the class hierarchy, including the base classes and subclasses.

3.

In the Hierarchy view, click the Show the Supertype Hierarchy view button to see a hierarchy showing the type's parent elements including implemented interfaces (i.e., the results of going up the type hierarchy).

Notice that in this "upside-down" display, you can now see that TestCase implements the Test interface.

4.

Click the Show the Subtype Hierarchy button in the view toolbar.

5.

Click the Lock View button in the method pane (the bottom pane) in the Hierarchy view, then select the runTest() method in the method pane.

Notice that the view now shows all the types implementing runTest().

6.

In the Hierarchy view, click the Show the Supertype Hierarchy view button. Then in the list pane, select countTestCases() to display the places where this method is overridden.

7.

In the Hierarchy view, select the Test element, and select Open Type Hierarchy from its context menu.

The resource containing the selected element is represented in the Hierarchy view and also opens in an active editor.

8.

Select from the menu bar Window > Preferences > Java.

9.

In the Open a new type hierarchy inside area, click the Hierarchy Perspective. Then click OK.

10.

In the Hierarchy view, select the Test element again, and once again select Open Type Hierarchy from its context menu.

The resource containing the selected type is shown in a new perspective (the Hierarchy perspective), and its source is shown in the Java editor. If the preference is set to this option for viewing new type hierarchies, you can have more than one type hierarchy in your workbench and switch between them as needed.

Note: You can also choose to open the Hierarchy perspective in a new window by using the hot key specified on the Window > Preferences > Workbench page for opening perspectives in new windows.