Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327168

Summary: XtextContentOutlinePage listens to wrong model after 'saveAs'
Product: [Modeling] TMF Reporter: Henrik Lindberg <henrik.lindberg>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jan
Version: 1.0.1Flags: jan: juno+
Target Milestone: M4   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Hacked version of XtextContentOutlinePage none

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