本文介绍了在Eclipse编辑器中检测选项卡关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有自己编辑器的Eclipse RCP应用程序。类编辑器从 org.eclipse.ui.texteditor.AbstractTextEditor
扩展而来,并在 plugin.xml - >中添加到扩展中。 org.Eclipse.ui.editors的
。如何检测用户何时关闭文档?
I have an Eclipse RCP application with own editor. Class editor extends from org.eclipse.ui.texteditor.AbstractTextEditor
and it is added in extension in plugin.xml -> org.eclipse.ui.editors
. How can I detect when the user closes document?
推荐答案
对于编辑器关闭事件,请执行以下操作:
For editor close event do something like this:
IWorkbenchPage page = ...;
//adding a listener
IPartListener2 pl = new IPartListener2() {
// ... Other methods
public void partClosed(IWorkbenchPartReference partRef)
{
//if(partRef.getId().equals(youreditor.id){ /* do something*/ }
}
};
page.addPartListener(pl);
看看这些链接:
- 的
- How to add a listener to the default code editor in Eclipse?
- FAQ How do I find out what view or editor is selected?
这篇关于在Eclipse编辑器中检测选项卡关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!