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

Bug 412821

Summary: MultiPageEditorActionBarContributor does not work for lazily loaded pages
Product: [Eclipse Project] Platform Reporter: saurav sarkar <saurav.sarkar1>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: mischa
Version: 4.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=177333
Whiteboard: stalebug

Description saurav sarkar CLA 2013-07-12 02:14:13 EDT
I want to make use of setActivePage(IEditorPart activeEditor) of MultiPageActionBarContributor.

All my form pages or editors in the Multi page editor are created lazily. But it seems the activeEditor instance is always null if my pages are loaded lazily.

The reason is the pageChange of MultiPageEditorPart class getEditor(int pageIndex) to get the current editor which always return null if the pages are created  lazily

 protected IEditorPart getEditor(int pageIndex) {
		Item item = getItem(pageIndex);
		if (item != null) {
			Object data = item.getData();
			if (data instanceof IEditorPart) {
				return (IEditorPart) data;
			}
		}
		return null;
	}
here item.getData() is always null. Some time back i had debugged that for lazily created pages it will be always null. (Don't remember the exact reason now).

I saw a bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=177333 which seems to be related to this issue.

Let me know if you need any further info from my side.

cheers,
Saurav
Comment 1 Mischa Höchsmann CLA 2017-08-24 11:48:23 EDT
Doesn't work for me too:
I faced the same issue when integrating two pages in a MPE which are contributing different actions (In my case, a textual XTextEditor with contributions applied by the AbstractTextEditor, and a custom graphical editor based on an EMF EditingDomainActionBarContributor).

How to fix?
The obvious fix (propagating the MPE fields 'item' and 'nestedEditors' on all addPage(...) methods) does lead to other exceptions (and a infinite loop). Further more, since the EditingDomainActionBarContributor does not implement #setActivePage(IEditorPart) it wouldn't work anyway.

Finally:
IMHO a bunch of tricky if/than/else code has now been developed happily against a buggy API, namely MPEP#getEditor(int). So it seems to be very hard to get rid of that issue now without breaking (illegal) clients assumptions.
Comment 2 Eclipse Genie CLA 2020-06-14 16:52:20 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.