【Eclipse】使用指南(11)使用本地历史

 (翻译说明:http://my.oschina.net/ywlaker/blog/468911

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.  
在本小节,你将使用本地历史版本还原修改后的Java文件。

  1. Open junit.samples/VectorTest.java file in the Java editor and select the method testCapacity() in the Outline view.      
    打开junit.samples/VectorTest.java 文件并通过Outline视图选择testCapacity()方法。

  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 pressingCtrl+S.        
    Ctrl+S保存文件。

  3. In the Outline view, select the method testCapacity(), and from its context menu, select Replace With > Element from Local History.      
    在Outline视图中选择testCapacity()方法右键选择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.      
    在弹出的对话框中,本地历史记录列表显示了该方法保存过的多个状态;Java源码对比面板则显示了当前源码与所选历史版本之间的细节差异。      

    image

  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.      
    选择之前的历史版本,点击Replace 按钮,编辑器中方法的源码就回到了修改之前的状态。

  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.      
    除了用旧版本代码替换当前代码之外,还可以恢复删除的方法。在Outline视图中选择testCapacity()方法,右键Delete删除,点击OK确定并保存文件。

  8. Now select the type VectorTest in the Outline view, and from its context menu, select Restore from Local History.... Select and check the methodtestCapacity() in the Available Java Elements pane. As before, the Local History pane shows the versions saved in the local history.      
    在Outline视图中选择VectorTest 类,右键选择Restore from Local History....菜单,在Available Java Elements 面板中勾选方法,Local History 面板会显示本地历史记录      

    image

  9. In the Local History pane, select the earlier working version and then click Restore.      
    选择之前的版本,点击Restore按钮。

转载于:https://my.oschina.net/ywlaker/blog/474223

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值