Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Java Development User Guide
Previous Page Home Next Page

Using the local history

In this section, you will use the local history feature to switch to a previously saved version of an individual Java element.

  1. Open junit.samples/ file in the Java editor and select the method testCapacity() in the Outline view.
  2. Change the content of the method so that the 'for' statements reads as:

    for (int i= 0; i < 99; i++)

    Save the file by pressing Ctrl+S.
  3. In the Outline view, select the method testCapacity(), and from its context menu, select Replace With > Element from Local History.
  4. In the Replace Java Element from Local History 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.

    Replace from local history

  5. In the top pane, select the previous version, and click the Replace button. In the Java editor, the method is replaced with the selected history version.
  6. Save the file.
  7. Beside replacing a method's version with a previous one you can also restore Java elements that were deleted. Again, select the method testCapacity() in the Outline view, and from its context menu, select Delete. Confirm the resulting dialog with Yes and save the file.
  8. Now select the type VectorTest in the Outline view, and from its context menu, select Restore from Local History.... Select and check the method testCapacity() in the Available Java Elements pane. As before, the Local History pane shows the versions saved in the local history.

    Restore from local history

  9. In the Local History pane, select the earlier working version and then click Restore.

Related concepts

Java editor

Related tasks

Using the local history

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire