Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Getting Toolbar for a programmatically created MPart
Getting Toolbar for a programmatically created MPart [message #1741715] Sun, 28 August 2016 14:11 Go to next message
Michael Kagel is currently offline Michael KagelFriend
Messages: 9
Registered: May 2015
Junior Member
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 #1742297 is a reply to message #1741715] Thu, 01 September 2016 13:24 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
Have a look at the EPartService.createPart(String) implementation. It consumes the PartDescriptor.
Seems that the effects are the results of your experiments with PartDescriptor vs. shared element.
Re: Getting Toolbar for a programmatically created MPart [message #1742893 is a reply to message #1742297] Thu, 08 September 2016 12:48 Go to previous message
Michael Kagel is currently offline Michael KagelFriend
Messages: 9
Registered: May 2015
Junior Member
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
Previous Topic:3x e4 Bridge, View, and getting the Shell
Next Topic:Eclipse neon most crappiest version ever
Goto Forum:
  


Current Time: Fri Sep 18 15:23:03 GMT 2020

Powered by FUDForum. Page generated in 0.02051 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top