在Eclipse编辑器中检测选项卡关闭

时间:2012-08-01 09:40:19

标签: java eclipse-rcp

我有一个带有自己编辑器的Eclipse RCP应用程序。类编辑器从org.eclipse.ui.texteditor.AbstractTextEditor延伸,并在plugin.xml -> org.eclipse.ui.editors的扩展名中添加。如何检测用户何时关闭文档?

1 个答案:

答案 0 :(得分:4)

对于编辑器关闭事件,请执行以下操作:

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);

看看这些链接:

  1. How to add a listener to the default code editor in Eclipse?
  2. FAQ How do I find out what view or editor is selected?