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

Bug 311064

Summary: EPartService/PartServiceImpl doesn't find target container specified with category attribute after switching perspective via EModelService
Product: [Eclipse Project] e4 Reporter: Sebastian Schneider <laluz>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED WORKSFORME QA Contact: Eric Moffatt <emoffatt>
Severity: minor    
Priority: P3 CC: laluz, remy.suen
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
Force a context 'ACTIVE_CHILD' change on a perspective switch none

Description Sebastian Schneider CLA 2010-04-29 12:52:58 EDT
Build Identifier: I20100428-2215

With to perspectives I encounter the following issue:
1. Having two perspectives perspective1 and perspective2
perspective1 having a sash with tag sash1
perspective2 having a sash with tag sash2

2. Opening view via EPartService in current perspective works fine

3. Now switching from perspective1 to perspective2 via EModelService (as performed in e4 photo demo SwitchPerspectiveHandler) works out quite well.

4.Now opening a new Part via EPartService using showPart(MPart) with specified category shash2 seems to buggy. 
While debugging the code I found out, that field rootContainer of PartServiceImpl doesn't get updated when step 3 is performed, thus the specified target container sash2 cannot be found and thus the new part is created in a new viewcontainer in perspective1.

Cannot think of a workaround for that.

Reproducible: Always

Steps to Reproduce:
see in details
Comment 1 Sebastian Schneider CLA 2010-04-29 15:00:13 EDT
Hi,

I worked around the issue, by finding the stack myself using the App for searchRoot and showing it like:

MPart part = partService.createPart(ELEMENT_ID);
MPartStack stack = (MPartStack) modelService.find(TARGET_STACK, theApp); 
stack.getChildren().add(part);

// now the workaround for the part getting rendered and activated
stack.setSelectedElement(part);

Can anyone think of a case with non-unique <tag>'s in application model?

Sebastian
Comment 2 Brian de Alwis CLA 2010-05-06 10:03:19 EDT
I've noticed the same thing.  It appears that PART_SERVICE_ROOT isn't being properly updated for perspective-changes, with the consequence that PartServiceImpl#isIInContainer() returns false, and bringToTop() never does anything.

In the function for updating PART_SERVICE_ROOT, the MPerspective pulled from the current context at line 289 of E4Application:

   Object object = current.get(MPerspective.class.getName());
   
is actually the wrong perspective.  In my testing, where I have 6 perspectives and had performed a perspective switch prior (from A -> B, and now trying B -> C), the perspective reported is actually A, and not B.
Comment 3 Eric Moffatt CLA 2010-05-12 11:39:55 EDT
Created attachment 168174 [details]
Force a context 'ACTIVE_CHILD' change on a perspective switch


Since this is in the rendering code it's now *enforced* that all perspective changes will result in a context 'activation'.
Comment 4 Eric Moffatt CLA 2010-05-12 11:43:08 EDT
Committed in >20100511. Applied the patch.

Note that this means that any old code that was performing the context switching itself (i.e. WorkbenchPage#setPerspective) should likely remove that code (even though a code inspection indicates that the context implementation will treat this as a NO-OP).

Brian, I'm going to mark this as fixed. If it's still not working correctly in your scenarios feel free to re-open...
Comment 5 Sebastian Schneider CLA 2010-06-17 04:36:31 EDT
Since a few I-Builds the automatic update for rootContainer in PartServiceImpl seems to be broken, when switching perspectives as done in e4 photo demo until now (SwitchPerspectiveHandler 1.7).

Currently work around is direct update on eclipse context for rootContainer like
eclipseContext.modify(EPartService.PART_SERVICE_ROOT, newRootContainer);

So the issue seems to be broken again.

Can anyone confirm?
Comment 6 Eric Moffatt CLA 2010-06-21 13:32:37 EDT
Remy, I know we used to have issues here...do you know if they are still there? I seem to remember adding some code is the LSR to handle this but we've lost the history for the class...
Comment 7 Remy Suen CLA 2010-07-09 09:27:52 EDT
Is this still a problem? The EPS and the renderers have changed quite a bit.
Comment 8 Eclipse Genie CLA 2018-11-10 02:42:57 EST
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.
Comment 9 Lars Vogel CLA 2019-06-05 07:46:56 EDT
This is a mass change to close all e4 bugs marked with "stalebug" whiteboard.

If this bug is still valid, please reopen and remove the "stalebug" keyword.