Detect tab close in Eclipse editor

被刻印的时光 ゝ 提交于 2019-12-01 08:19:30

问题


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?


回答1:


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

Have a look at these links:

  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?


来源:https://stackoverflow.com/questions/11756534/detect-tab-close-in-eclipse-editor

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!