Community
Participate
Working Groups
Build Identifier: [14:20] rcjsuen: unclecj: when the document changes it will fire events [14:20] unclecj: Ok, cool, so I plug in a listener, not doing it on pagechange? [14:21] rcjsuen: unclecj: You can have multiple editors open (Window > New Editor). [14:21] rcjsuen: Reacting on page change is a noble optimization but can result in failure. [14:22] unclecj: rcjsuen: The MPE example re-sorts on pagechange [14:22] rcjsuen: That is unfortunate. [14:23] rcjsuen: unclecj: Please open a bug requesting the template be updated. Reproducible: Always Steps to Reproduce: 1. Create two instances of MPE sharing the same document 2. Edit the document in one 3. Watch the results page not updating since there is no page-change, but a document change was fired
FWDing to Platform UI
The template project is generated from PDE's 'Plug-in Project' wizard. I believe they come from PDE's org.eclipse.pde.ui.templates bundle. http://dev.eclipse.org/viewcvs/index.cgi/pde/ui/org.eclipse.pde.ui.templates/templates_3.0/multiPageEditor/java/%24contributorClassName%24.java?view=log
Any possibility of getting a patch? The templates are in the org.eclipse.pde.ui.templates project as Remy mentioned.
The problem disappears when you change the method createPages() in /org.eclipse.pde.ui.templates/templates_3.0/multiPageEditor/java/$editorClassName$.java as follows: ## add to class: private final class MPEDocumentChangedListener implements IDocumentListener { @Override public void documentChanged(DocumentEvent event) { sortWords(); } @Override public void documentAboutToBeChanged(DocumentEvent event) { } } private IDocument document; private MPEDocumentChangedListener mpeDocumentChangeListener; ## change methods createPages() and dispose(): /** * Creates the pages of the multi-page editor. */ protected void createPages() { createPage0(); createPage1(); createPage2(); document = editor.getDocumentProvider().getDocument(getEditorInput()); mpeDocumentChangeListener = new MPEDocumentChangedListener(); document.addDocumentListener(mpeDocumentChangeListener); } /** * The <code>MultiPageEditorPart</code> implementation of this * <code>IWorkbenchPart</code> method disposes all nested editors. * Subclasses may extend. */ public void dispose() { document.removeDocumentListener(mpeDocumentChangeListener); ResourcesPlugin.getWorkspace().removeResourceChangeListener(this); super.dispose(); } Assign to me and I will provide patches. Attaching Mylyn context protected void createPages() { createPage0(); createPage1(); createPage2(); IDocument document = editor.getDocumentProvider().getDocument(getEditorInput()); document.addDocumentListener(new IDocumentListener() { @Override public void documentChanged(DocumentEvent event) { sortWords(); } @Override public void documentAboutToBeChanged(DocumentEvent event) { } }); } But this may not be totally neat, maybe the listener should be removed on dispose as the document maybe shared between editors. Attaching Mylyn context
Created attachment 253498 [details] mylyn/context/zip
Created attachment 253502 [details] MultiPageEditor Preview auto synchs to file open in TextEditor Using a DocumentListener as per chat transcript.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.