Getting Toolbar for a programmatically created MPart [message #1741715] |
Sun, 28 August 2016 10:11  |
Eclipse User |
|
|
|
Hi,
currently I have the following state:
I defined a Part in a fragment.e4xmi as shared element of my main window (defined as TrimmedWindow in the Application.e4xmi). Also I defined a toolbar with some buttons as sub-element of the Part (activated the toolbar checkbox of the Part).
In the next step I defined a PartStack inside an Area as shared element of the TrimmedWindow.
Now I tried to add the part programmatically to the part stack:
EPartService partService ...
MPartStack stack ... //defined part stack
MPart part = partService.createPart(myDefinedPartId);
stack.getChildren().add(part);
partService.showPart(part, PartState.VISIBLE);
The result is, I get a opened part but without the toolbar.
When I create a MPlaceholder instead of a part like this:
EPartService partService ...
MPartStack stack ... //defined part stack
MPlaceholder mPlaceholder = partService.createSharedPart(myDefinedPartId);
stack.getChildren().add(mPlaceholder);
The part is created (but of course not on top) and it contains the defined toolbar.
My questions are:
1. Why does this happen? (part has no toolbar, placeholder has one)
2. Is there a way to create a part which also contains the defined toolbar?
I would expect that a programmatically created part also contains all of its defined child elements (menus, toolbar), exactly when I let create it via the application model.
By the way, I also tried to define a PartDescriptor instead of a Part but this also did not work.
Best Regards
Michael Kagel
|
|
|
|
Re: Getting Toolbar for a programmatically created MPart [message #1742893 is a reply to message #1742297] |
Thu, 08 September 2016 08:48  |
Eclipse User |
|
|
|
Hi,
my test with the part descriptor was afterwards. I analyzed the PartService.createPart method and found that this is using a part descriptor for creating a not existing part. So I hoped I could convince eclipse to show the toolbar when defining my own part descriptor with the toolbar. During debugging I saw that the toolbar was correctly created in the model but never rendered in the UI.
But even without a part descriptor I would excpect that a programmatically created part is based on the part definition in the model (in my case incl. toolbar).
At the moment I use placeholder and everything works fine. But this looks somehow weird to create a placeholder for a part, put it on the part stack (all programmatically) and then eclipse renders the part correctly with a toolbar. But using the part or a part descriptor doesn't work.
Because of that I wanted to know if this is the intended behavior, is there a bug or do I use this incorrect?
Best Regards
Michael
|
|
|
Powered by
FUDForum. Page generated in 1.05429 seconds