I have a part stack with two parts. The second part has a ToolBar
with a Direct Tool Item
with an icon.
I would like to initialise the second part without displaying it as some code needs to be executed straight away not when focused.
To do this I call:
partService.showPart(secondPartID, PartState.CREATE);
After this I call:
partService.showPart(secondPartID, PartState.ACTIVATE);
This then brings the second view to the front as expected but the toolbar is missing.
I've tried getting the toolbar for the part and getting the widget but the widget is null.
If I switch to the first part (by clicking the tab) then switch back to the second, the toolbar has successfully been created.
I'm wondering if I'm using the CREATE
/ACTIVATE
calls incorrectly as the behaviour I'm getting is strange.
What could be causing this?
By wrapping this in an async
it fixes it. I've tried multiple variations to fix this and this is the only thing that will.
Display.getDefault().asyncExec(() -> partService.showPart(id, PartState.ACTIVATE));
It must be that things aren't initialised/ready yet which causes the toolbar to not be added. By using async it must be waiting until it's ready to display the toolbar.
If anybody is able to give any extra information as to why this fixes it I'll update the answer.