blob: 4775728d1df1d06a3dc6758b8657582a6a48a809 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>
Using the local history
</title>
</head>
<body>
<h1>
Using the local history
</h1>
<p>
In this section, you will use the local history feature to switch to a previously saved version of an individual
Java element.
</p>
<ol>
<li>
Open <em>junit.samples.VectorTest.java</em> file in the Java editor and select the method
<em>testCapacity()</em> in the Outline view.
</li>
<li>
Change the content of the method so that the 'for' statements reads as:<br>
<p><code>
for (int i= 0; i &lt; 99; i++)
</code></p>
Save the file by pressing <kbd>Ctrl+S</kbd>.
</li>
<li>
In the Outline view, select the method <code>testCapacity()</code>, and from its context menu, select <strong>Replace
With &gt; Element from Local History</strong>.
</li>
<li>
In the <strong>Replace Java Element from Local History</strong> dialog, the Local History list
shows the various saved states of the method. The Java Source Compare pane shows details of the
differences between the selected history resource and the existing workbench resource.
<p>
<img src="images/replace_local_element.png" alt="Replace from local history">
</p>
</li>
<li>
In the top pane, select the previous version, and click the <strong> Replace
button</strong>. In the Java editor, the method is replaced with the selected history version.
</li>
<li>
Save the file.
</li>
<li>
Beside replacing a method's version with a previous one you can also restore Java elements that were
deleted. Again, select the method <em>testCapacity()</em> in the Outline view, and from its context
menu, select <strong>Delete</strong>. Confirm the resulting dialog with <strong>Yes</strong> and
save the file.
</li>
<li>
Now select the type <em>VectorTest</em> in the Outline view, and from its context menu, select
<strong>Restore from Local History...</strong>. Select and check the method <em>testCapacity()</em>
in the Available Java Elements pane. As before, the Local History pane shows the versions saved
in the local history.
<p>
<img src="images/restore_local_history.png" alt="Restore from local history">
</p>
</li>
<li>
In the Local History pane, select the earlier working version and then click <strong>Restore</strong>.
</li>
</ol>
<P class="nav_footer" id="nav_footer">Next Section: <A href="qs-ExtractMethod.htm">Extracting a new method</A>
</P>
<p>
<img border="0" src="../images/ngrelc.png" alt="Related concepts" >
</p>
<p>
<a href="../concepts/concepts-7.htm">Java editor</a><br>
</p>
<p>
<img src="../images/ngrelt.png" alt="Related tasks" border="0" >
</p>
<p>
<a href="../tasks/tasks-62.htm">Using the local history</a><br>
</p>
</body>
</html>