Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 327168 - XtextContentOutlinePage listens to wrong model after 'saveAs'
Summary: XtextContentOutlinePage listens to wrong model after 'saveAs'
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 1.0.1   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: M4   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-06 20:31 EDT by Henrik Lindberg CLA
Modified: 2017-09-19 17:23 EDT (History)
1 user (show)

See Also:
jan: juno+


Attachments
Hacked version of XtextContentOutlinePage (15.40 KB, application/octet-stream)
2010-10-06 20:31 EDT, Henrik Lindberg CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Henrik Lindberg CLA 2010-10-06 20:31:43 EDT
Created attachment 180380 [details]
Hacked version of XtextContentOutlinePage

When performing a save as - and the editor gets a new editor input, the outline page will continue to listen to a model that is no longer maintained.

I first tried deriving a class that exposed the "refresh" method via an "externalRefresh", but this was not enough as the outline page held on to a registered modelListener, and this also needed to be reset (a new listener must be registred). The work around turned out to be a quite ugly hack because I did not know if it was possible to also replace the toolbar configurer (with other possible consequences).

I attached the modified class with an externalRefresh method that simply nulls the modelListener. It seems like a change of editor input should lead to unregistration of the current listener, but I did not know how to do that without holding on to the xtextDocument (which may be a really bad idea).

The externalRefresh simply does this:
	/**
	 * THIS METHOD IS THE ONLY REAL ADDITION TO THE COPIED/HACKED CLASS
	 * Special method that should be called from performSavedAs
	 */
	public void externalRefresh() {
		// Must drop old listener (should ideally get rid of the listener, but since the document changed already (??)
		// it will probably not unregister for the correct document.
		modelListener = null;
		// Install a model listener for the current document
		installModelListener();
		refresh();
	}
Comment 1 Jan Koehnlein CLA 2011-11-11 09:22:46 EST
Has been fixed with the redesign of the outline API.
Comment 2 Karsten Thoms CLA 2017-09-19 17:11:34 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:23:07 EDT
Closing all bugs that were set to RESOLVED before Neon.0