blob: 23257a1152b6fda80a276ae2585fe6ab2ddf8ad4 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title> Viewing the type hierarchy</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script>
</head>
<body>
<h1>Viewing the type hierarchy</h1>
<p> In this section, you will learn about using the Hierarchy view by viewing
classes and members in a variety of different ways. </p>
<ol>
<li> In the Package Explorer view, find <em>junit.framework.TestCase.java</em>.
From its context menu, select
<a class="command-link" href='javascript:executeCommand("org.eclipse.jdt.ui.commands.showElementInTypeHierarchyView(elementRef=JUnit/junit.framework.TestCase)")'>
<img src="PLUGINS_ROOT/org.eclipse.help/command_link.png" alt="Open type hierarchy">
<strong>Open Type Hierarchy</strong></a>.
You can also open type hierarchy view:
<ul>
<li> from the menu bar by selecting <strong>Navigate &gt; Open Type
Hierarchy</strong>.</li>
<li> from the keyboard by pressing F4 after selecting <em>TestCase.java</em>.
</li>
</ul>
<p>
<img src="../images/qs-28.png" alt="Context menu">
</p>
</li>
<li> The buttons in the view tool bar control which part of the hierarchy is
shown.&nbsp; Click the&nbsp;<strong>Show the Type Hierarchy&nbsp;</strong>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.
<p>
<img src="../images/qs-29.png" alt="Type hierarchy">
</p>
</li>
<li> Click the <strong>Show the Supertype Hierarchy</strong> button to
see a hierarchy showing the type's parent elements including implemented
interfaces. This view shows the results of going up the type hierarchy.
<p>
<img src="../images/qs-30.png" alt="Supertype hierarchy">
</p>
In this &quot;reversed hierarchy&quot; view, you can see that TestCase implements
the Test interface. </li>
<li> Click the&nbsp;<strong>Show the Subtype Hierarchy</strong> button in the
view toolbar.
<p>
<img src="../images/qs-31.png" alt="Subtype hierarchy">
</p>
</li>
<li> Click the <strong>Lock View and Show Members in Hierarchy</strong>
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().
<p>
<img src="../images/qs-32.png" alt="Subtype hierarchy showing method implementors">
</p>
</li>
<li> In the Hierarchy view, click the <strong>Show the Supertype Hierarchy</strong>
button. Then on the member pane, select <code>countTestCases()</code> to display
the places where this method is declared.
<p>
<img src="../images/qs-33.png" alt="Supertype hierarchy showing method implementors">
</p>
</li>
<li> In the Hierarchy view select the <em>Test</em> element and select <strong>Focus
On 'Test'</strong> from its context menu. <em>Test</em> is presented in the Hierarchy view. </li>
<li> Activate the Package Explorer view and select the package junit.framework.
Use <strong>Open Type Hierarchy</strong> 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.
<p>
<img src="../images/qs-33a.png" alt="Hierarchy on a package">
</p>
</li>
<li> Use <strong>Previous Type Hierarchies</strong> to go back to a previously
opened element. Click on the arrow next to the button to see a list of elements or click
on the button to edit the history list.
<p>
<img src="../images/qs-33b.png" alt="History menu">
</p>
</li>
<li>Open the
<a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.jdt.ui.preferences.JavaBasePreferencePage)")'>
<img src="PLUGINS_ROOT/org.eclipse.help/command_link.png" alt="Goto the Java preference page">
<strong>Java</strong></a> preference page, find the group labeled
<strong>When opening a Type Hierarchy</strong> and enable
<strong>Open a new Type Hierarchy Perspective</strong>.
Then click&nbsp;<strong>OK</strong>.</li>
<li> In the Hierarchy view, select the Test element again, and activate&nbsp;<strong>Open
Type Hierarchy</strong> 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.&nbsp; 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.
Return to the
<a class="command-link" href='javascript:executeCommand("org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.jdt.ui.JavaPerspective)")'>
<img src="PLUGINS_ROOT/org.eclipse.help/command_link.png" alt="Goto the Java preference page">
<strong>Java</strong> perspective</a> before proceeding to the next step.
</li>
</ol>
<img src="../images/ngrelc.png" alt="Related concepts" border="0">
<p> <a href="../concepts/concepts-7.htm">Java views</a> </p>
<p> <img src="../images/ngrelt.png" alt="Related tasks" border="0">
</p>
<p> <a href="../tasks/tasks-37.htm">Using the Hierarchy view</a> </p>
<p> <img src="../images/ngrelr.png" alt="Related reference" border="0">
</p>
<p> <a href="../reference/ref-type-hierarchy.htm">Type Hierarchy view</a><br>
<a href="../reference/ref-13.htm">Java Base preference page</a> </p>
</body>
</html>