When you do an Eclipse editor development, you may need to listen for a process in the life cycle of the editor, which is Org.eclipse.ui.IPartListener (2):
Public interface Ipartlistener {public void partactivated (Iworkbenchpart part); public void Partbroughttotop (Iworkbenchpart part); public void partclosed (Iworkbenchpart part); public void partdeactivated (Iworkbenchpart part); public void partopened (Iworkbenchpart part);
Implement the interface, and then, after the editor is created, in the editor code (such as in the AddPage () method of Formeditor), add:
Getsite (). GetPage (). Addpartlistener (this); Join the Monitor getsite (). GetPage (). Removepartlistener (this); Delete the listener in the Dispose () method of the editor
For example, if you need to save the editor data when the current editor fails (Deactivated), you only need to call Dosave () in the Partdeactivated () method. This avoids the user forgetting to save the editor and loses the data modified in the editor, which is automatically saved when the user leaves the current editor for any other action.
This article from "Winger" blog, declined reprint!
Eclipse Editor life cycle event listener