Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328178 - setToBeRendered(true) on a Part does not re-draw the UI
Summary: setToBeRendered(true) on a Part does not re-draw the UI
Status: RESOLVED WORKSFORME
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 16:39 EDT by Lars Vogel CLA
Modified: 2014-03-19 22:17 EDT (History)
2 users (show)

See Also:


Attachments
number1 (28.07 KB, image/png)
2010-10-19 16:39 EDT, Lars Vogel CLA
no flags Details
number2 (28.46 KB, image/png)
2010-10-19 16:39 EDT, Lars Vogel CLA
no flags Details
number3 (30.02 KB, image/png)
2010-10-19 16:40 EDT, Lars Vogel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2010-10-19 16:39:38 EDT
Created attachment 181223 [details]
number1

If I get a part and call setToBeRendered(false); setToBeRendered(true) then the SWT Widgets are not drawn. If I then click on the part header the controls are drawn. 

Here is what I do:

findPart = service.findPart("de.vogella.e4.tododetails");
findPart.setToBeRendered(false);
findPart.setToBeRendered(true);

--> The part is shown again but its controls are not visible. Please see the attached screenshots.
Comment 1 Lars Vogel CLA 2010-10-19 16:39:54 EDT
Created attachment 181224 [details]
number2
Comment 2 Lars Vogel CLA 2010-10-19 16:40:12 EDT
Created attachment 181225 [details]
number3
Comment 3 Remy Suen CLA 2010-10-19 16:48:30 EDT
(In reply to comment #0)
> findPart = service.findPart("de.vogella.e4.tododetails");
> findPart.setToBeRendered(false);
> findPart.setToBeRendered(true);

I thought the stack's selectedElement had changed to 'null' after the second line but this doesn't appear to be the case. So it seems to me that the third line should have caused the renderer to both recreate the tab item (which it does) and also select it (which it does _not_).
Comment 4 Eric Moffatt CLA 2010-10-20 14:48:37 EDT
After talking this over with Remy we think that the following 'rule' makes sense:

The selectedElement (SE) of a container must be:

a) a child of the container (obvious) 

*AND*

b) its TBR must be true (we can't find a scenario where having an SE that isn't rendered in the UI makes sense)

The rendering engine can(will) enforce this by setting the SE to null whenever it detects that the above conditions no longer apply. 

The rendering engine will *never* attempt to determine a new 'correct' value for the SE (i.e. the only change it will ever make is to set it to null). It would be up to the code making the changes in the model to pick a new selected element. 

The rendering engine simply doesn't have enough info to make a valid selection (i.e. in the compat layer the new selected element should be determined through the 'activation history'.

In this particular scenario the engine couldn't 'know' whether or not the call to findPart.setToBeRendered(true) wasn't going to be followed by a few more calls showing other parts...
Comment 5 Eric Moffatt CLA 2010-10-20 15:19:39 EDT
BTW, there's a fairly simple pattern that can be used to re-institute the naive version of 'auto-select'.

Add a listener that detects when the 'selectedElement' goes to null and do the following:

// Selects the first visible entry in the presentation
for (MUIElement element : container.getChildren()) {
   if (element.isToBeRendered() && element.isVisible()) {
      container.setSelectedElement(element);
      break;
   }
}
Comment 6 Lars Vogel CLA 2010-10-20 15:24:09 EDT
Thanks Eric.
Comment 7 Lars Vogel CLA 2014-03-19 22:17:29 EDT
WORKFORME