eclipse 中的Link with Editor功能是如何实现
来源:互联网 发布:嘉桥数据咨询 编辑:程序博客网 时间:2024/04/29 21:56
今天向大家介绍Eclipse中很有用的一个功能: Link with Editor。
当打开很多文件,而左边的Navigator又有很多资源,很深层次时, 找到当前的编辑器对应的是哪个项目的那个文件,是一件困难的事情。
Link with Editot自动在Navigator中定位资源,并选中, 如下图所示,双向箭头就是Link with Editor未选中时:
启用后,选中右边的java文件,左边也会自动选中相应的文件:
这个功能是如何实现的呢?
查看ResourceNavigator的editorActivated方法,可以看到实现代码。
protected void editorActivated(IEditorPart editor) {
if (!isLinkingEnabled()) {
return;
}
IFile file = ResourceUtil.getFile(editor.getEditorInput());
if (file != null) {
ISelection newSelection = new StructuredSelection(file);
if (getTreeViewer().getSelection().equals(newSelection)) {
getTreeViewer().getTree().showSelection();
} else {
getTreeViewer().setSelection(newSelection, true);
}
}
}
当Link with Editor启用后,程序会获得当前编辑器的文件, 并在左边的Navigator树形结构里选中。
我们可以继承ResourceNavigator并对代码做一些修改,做一个自己的Navigator: 比如选中编辑器时,选中左边对应的父文件夹。
只需修改一句代码:
ISelection newSelection = new StructuredSelection(file.getParent());
本文介绍了 Link with Editor功能,实现原理,以及如何做一个定制的。
注:在最新的Eclipse中,类ResourceNavigator已经弃用
【完】
- Eclipse中的Link with Editor功能是如何实现
- eclipse 中的Link with Editor功能是如何实现
- eclipse(Link with Editor)
- Visual Studio 类似 Eclipse中的 Link with Editor 的设置
- eclipse中的Link with Editor不能定位到js
- intellij的link with editor功能
- link with editor
- sublime link with editor
- eclipse中的properties editor
- Zend Studio "Link with Editor"惹得祸
- Netbeans Link editor window with file in Project tree
- FRAGS中的游戏屏幕录像功能在底层是如何实现的?
- Build GUIs with the Eclipse Visual Editor project
- [Netadvantage:Editor]如何实现Editor From和To的联动
- J2EE--如何实现servlet中的发信功能?
- Java中的hashCode()是如何实现的?
- Java中的hashCode()是如何实现的?
- c++中的"<<"是如何实现的?
- 概要设计与详细设计的作用与区别
- 计算日期间隔的天数_INTEL2014笔
- Ubuntu apt-get代理设置
- Mvc 中部分视图的使用
- 黑马程序员-MAP集合
- eclipse 中的Link with Editor功能是如何实现
- 如何做理员为什活”颂
- 小生活
- Mybatis与ibatis的区别
- 黑马程序员-IO流
- 将Excel的内容复制到EasyUI的dataGrid里(复制列)
- 咦?这些产品当年都是怎么抢到第一批用户的?
- 使用foxmail的一次坑爹经历
- Makefile汇总