Take the multi-page editor inherited from the formeditor class as an example.
Inherit from the save of formeditor Editor, where formediotr inherits from multipageeditorpart
In fact, it still needs to call the save of every page, as shown in figure
Public void dosave (iprogressmonitor Monitor ){
Tagpage. dosave (MONITOR );
// Omitting the dosave (MONITOR) Call of other pages
Editordirtystatechanged ();
}
The tagpage is one of the pages of the Multi-page editor, inherited from formpage. In fact, formpage is also an editor that inherits from editorpage and implements the iformpage interface.
In formpage, the editor is usually saved like this. You can define a variable in the editor that indicates whether the editor is dirty:
① Private Boolean isdirty = false; // The initial value is false. If it is not rewritten, The isdirty method returns isdirty.
② Set the isdirty value where the event needs to be monitored and modified, and notify the event, such:
Isdirty = true;
Geteditor (). editordirtystatechanged (); // pay special attention to the geteditor () method.
③ Complete the save in the dosave method and set isdirty to false, for example:
Public void dosave (iprogressmonitor Monitor ){
Writefieldstotag ();
Id3taginfo. savemp3file ();
Isdirty = false; // reset to false
}
Note: in fact, the isdirty () method in formeditor traverses all the formpage contained in it to determine which modifications are made.