Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325232 - MultiPageEditor wizard template misrepresents that updating form on pagechange is sufficient, it should use a document change listener
Summary: MultiPageEditor wizard template misrepresents that updating form on pagechang...
Status: CLOSED WONTFIX
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-14 07:35 EDT by Carl-Johan Sveningsson CLA
Modified: 2019-10-06 08:44 EDT (History)
4 users (show)

See Also:


Attachments
mylyn/context/zip (4.17 KB, application/octet-stream)
2015-05-15 07:26 EDT, maarten meijer CLA
no flags Details
MultiPageEditor Preview auto synchs to file open in TextEditor (30.29 KB, image/png)
2015-05-15 09:16 EDT, maarten meijer CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Carl-Johan Sveningsson CLA 2010-09-14 07:35:44 EDT
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
Comment 1 Ankur Sharma CLA 2010-09-14 07:42:19 EDT
FWDing to Platform UI
Comment 2 Remy Suen CLA 2010-09-14 09:15:43 EDT
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
Comment 3 Curtis Windatt CLA 2010-09-14 09:37:50 EDT
Any possibility of getting a patch?  The templates are in the org.eclipse.pde.ui.templates project as Remy mentioned.
Comment 4 maarten meijer CLA 2015-05-15 07:26:26 EDT
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
Comment 5 maarten meijer CLA 2015-05-15 07:26:32 EDT
Created attachment 253498 [details]
mylyn/context/zip
Comment 6 maarten meijer CLA 2015-05-15 09:16:04 EDT
Created attachment 253502 [details]
MultiPageEditor Preview auto synchs to file open in TextEditor

Using a DocumentListener as per chat transcript.
Comment 7 Eclipse Genie CLA 2019-10-06 08:44:28 EDT
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.