在org.eclipse.ui.editors扩展点中有个matchingStrategy的元素,可以实现IEditorMatchingStrategy接口,覆写
public boolean matches(IEditorReference editorRef, IEditorInput input)方法,就可以做到判断编辑器输入是否匹配打开的编辑器。
说的简单点:每次我们打开一个文件,转化为input会去回调matches方法,判断是否文件已经打开,从而达到不会打开多次目的,即单例。一般应用于一个编辑器编辑多个文件。
如:
public class DiagramMatchingStrategy implements IEditorMatchingStrategy {
@Override
public boolean matches(final IEditorReference editorRef, final IEditorInput input) {
try {
final IFile newDataFile = FileService.getDataFileForInput(input);
final IFile openEditorDataFile = FileService.getDataFileForInput(editorRef.getEditorInput());
if (null != newDataFile && newDataFile.equals(openEditorDataFile)) {
return true;
}
} catch (PartInitException exception) {
exception.printStackTrace();
}
return new DiagramMatchingStrategy ().matches(editorRef, input);
}
}
分享到:
相关推荐
EclipseSWT_JFace_RCP插件开发书中源代码。
eclipse3.4 RCP插件开发英文教程,转成了pdf
eclipse rcp 插件开发学习笔记.pdf 15-24章
eclipse rcp 插件开发学习笔记.pdf 1-14章
学习RCP后开发的第一个小程序,和大家分享下
rcp的文本编辑器的实例,可以读取,写入一个文本文件。初学者可以学习学习
精简版rcp JAVA 编辑器,非常实用 精简版rcp JAVA 编辑器
eclipse插件开发: rcp/swt相关资料 rcp swt 插件开发
Eclipse RCP plugin 开发快速入门。理论与实践相结合,容易理解。
RCP&OSGI;
Eclipse RCP 属性编辑器实例!!!!!!!
rcp 开发自学教程,eclipse插件开发,是个很不错的入门教程
Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT
有关rcp项目创建,视图创建。 开发插件项目基础
eclipse插件及RCP开发资料.rar eclipse插件及RCP开发资料.rar eclipse插件及RCP开发资料.rar
eclipse RCP学习项目源码&扩展控制台插件for eclipse3.5
转载的他人的资料 希望对大家有用 RCP开发书籍资料简介 插件开发 - 中国Eclipse社区
博文链接:https://dollyn.iteye.com/blog/79632
Eclipse RCP应用系统开发方法与实战 Eclipse RCP应用系统开发方法与实战 Eclipse RCP应用系统开发方法与实战