Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 8. Editors > Editor Lifecycle

8.4. Editor Lifecycle

Typical editors go through an open-modify-save-close lifecycle. When the editor is opened, the init(IEditorSite, IEditorInput) method is called to set the editor’s initial content. When the user modifies the editor’s content, the editor must notify others that its content is now “dirty” by using the firePropertyChange(int) method. When a user saves the editor’s content, the firePropertyChange(int) method must be used again to notify registered listeners that the editor’s content is no longer dirty. Eclipse automatically registers listeners to perform various tasks based on the value returned by the isDirty() method, such as updating the editor’s title, adding or removing an asterisk preceding the title, and enabling the Save menu. Finally, when the editor is closed, the editor’s content is saved if the isDirty() method returns true.

8.4.1. Dirty editors

You need to ensure that the editor knows whether its content has been modified by the user since the last save operation. To do this, introduce this new field to track whether the current page has been modified relative to the other pages:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial