问题
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:
- How to add a listener to the default code editor in Eclipse?
- FAQ How do I find out what view or editor is selected?
来源:https://stackoverflow.com/questions/11756534/detect-tab-close-in-eclipse-editor