Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » PartDescriptor in Fragment
PartDescriptor in Fragment [message #1271199] Fri, 14 March 2014 13:36 Go to next message
Don Smyth is currently offline Don Smyth
Messages: 35
Registered: April 2013
Member
Does anyone know if it is possible to use a PartDescriptor for an MPart in a ModelFragment?

When I do so and then trace the code in the ModelServiceImpl.class the only PartDescriptors I find there are the ones defined in the main Application - no descriptors from the fragment are found.

There was a post on this in 2012 http://www.eclipse.org/forums/index.php/t/366973/ and a bugzilla bugs.eclipse.org/bugs/show_bug.cgi?id=384514. The bugzilla tracker defines the bug as fixed in Nov 2013 - with a patch to org.eclipse.e4.tools.emf.ui...SharedElementsDialog.java but I am not using SharedElementsDialog.

Any ideas?

Cheers

Don
Re: PartDescriptor in Fragment [message #1280168 is a reply to message #1271199] Sat, 29 March 2014 22:50 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

So you can not add add it from the application model editor or you add it and the model service doesn't find it?
Re: PartDescriptor in Fragment [message #1281111 is a reply to message #1271199] Mon, 31 March 2014 11:24 Go to previous messageGo to next message
Olivier Prouvost is currently offline Olivier Prouvost
Messages: 7
Registered: August 2011
Location: TOULOUSE
Junior Member

The problem with model fragment is that you need to know the ID of your application. If you add your part descriptor in your application model and then you extract it into a fragment you will see the application ID in the model fragment. If your fragment is dedicated to a specific application it will be ok, and by extracting the fragment it should work.

May be it would be easier to use a Processor to describe it. In this case you don't need to know the application ID. Instead of choosing 'fragment' in the extension, choose 'Processor' and bind a POJO class containing an '@Execute' method that will receive the MApplication, modelService and all stuff needed :

You can then add the part descriptor using a code like this :

@Execute
public void fillMyModel(MApplication application, EModelService modelService)
{
MPartDescriptor descriptor = modelService.createModelElement(MPartDescriptor.class);

descriptor.setElementId(MyPart.class.getCanonicalName());
descriptor.setLabel(partLabel);
descriptor.setCloseable(true);

String bundle = FrameworkUtil.getBundle(myPart.class).getSymbolicName();
descriptor.setContributionURI("bundleclass://" + bundle + "/" + myPart.class.getCanonicalName());
String contributorURI = "platform:/plugin/" + FrameworkUtil.getBundle(myPart.class).getSymbolicName();
descriptor.setContributorURI(contributorURI);
descriptor.setIconURI(iconPath.toString());
application.getDescriptors().add(descriptor);

}


Re: PartDescriptor in Fragment [message #1282050 is a reply to message #1281111] Tue, 01 April 2014 20:05 Go to previous messageGo to next message
Eric Moffatt is currently offline Eric Moffatt
Messages: 118
Registered: July 2009
Senior Member
This is most likely awaiting the XPath implementation for fragment processing which would allow you to explicitly define the container without having to resort to using hte id.
Re: PartDescriptor in Fragment [message #1290870 is a reply to message #1282050] Thu, 10 April 2014 14:09 Go to previous messageGo to next message
Don Smyth is currently offline Don Smyth
Messages: 35
Registered: April 2013
Member
Thanks everyone,

I initially got this working by leaving all the model fragments (commands, handlers, menus) in the plugin, then registering PartDescriptors in the main Application.e4xmi that refernce the plugin view bundleclasses - not elegent but works.

After reading your posts, I tried extracting the part descriptor as a fragment -both into the main app and into the plugin. Neither worked.

I then tried creating a processor inside the plug-in. This method appears promising - I managed to get it add items to the menu in the main application, though there now seems to be an issue injecting a Composite into a POJO on @PostConstruct in views in the plugin.

Thanks

Don



Re: PartDescriptor in Fragment [message #1433127 is a reply to message #1290870] Sun, 28 September 2014 08:14 Go to previous message
Mikhail Niedre is currently offline Mikhail Niedre
Messages: 4
Registered: December 2012
Location: Voronezh
Junior Member
Don Smyth wrote on Thu, 10 April 2014 10:09
I managed to get it add items to the menu in the main application, though there now seems to be an issue injecting a Composite into a POJO on @PostConstruct in views in the plugin.
Thanks
Don


To solve this problem add as required plug-in javax.annotation, as result method marked as @PostConstruct will works.


without shit, without fun, just being a happy man.
Previous Topic:re-creating a closed Part
Next Topic:Luna 4.4 unable to connect to marketplace behind firewall
Goto Forum:
  


Current Time: Sat Oct 25 19:05:54 GMT 2014

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

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