Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Calling setContributorURI From A @ProcessAdditions Method Has No Effect
Calling setContributorURI From A @ProcessAdditions Method Has No Effect [message #906190] Fri, 31 August 2012 16:16 Go to next message
Rob Hatcherson is currently offline Rob Hatcherson
Messages: 27
Registered: July 2009
Location: Fort Worth, TX, USA
Junior Member
I've been exercising the e4 model manipulation API some to see what's possible from code.

I hooked into the lifeCycleURI mechanism and added a class containing a method annotated with @ProcessAdditions. This method gets called as expected, and I'm able to do things like add new windows and/or add a new Part to a PartStack. So far so good.

However...

If I specify the content of a new Part (or the content of a preexisting empty Part) by calling setContributorURI then the content is never realized. The content in question is a simple label containing a static string. The code that creates the label does the work in a method annotated with @PostConstruct, and a method annotated with @Focus is included.

I know the URI is correct because I later specified it statically in the model and the content was shown.

At this point I started slinging arrows at it, and tried obtaining the EPartService and calling showPart. However, this caused the app to refuse to start. I guess this makes sense since it may be too early in the lifecycle to show anything (?).

On the surface it seems that if I can specify the contributor URI in the static model and that works, and the method annotated with @ProcessAdditions is just adding to the model, then setting the contributor URI from code at this point should have a similar effect.

Any guidance?
Re: Calling setContributorURI From A @ProcessAdditions Method Has No Effect [message #906448 is a reply to message #906190] Sat, 01 September 2012 09:59 Go to previous messageGo to next message
Joseph Carroll is currently offline Joseph Carroll
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

Well the contributor URI is just that, the "contributor"'s URI. The contributor would be the bundle from which the "contribution" is made. So if you want to set/change the content of a part, call setContributionURI() and make sure the URI is of the form bundleclass://your.plugin.id/namespace.of.your.Class

However, I wouldn't change the contribution if there is a chance the part has been rendered. AFAIK, the model will not cause the part to be re-rendered and it might introduce some instability.


JD
Re: Calling setContributorURI From A @ProcessAdditions Method Has No Effect [message #907371 is a reply to message #906448] Mon, 03 September 2012 17:33 Go to previous messageGo to next message
Rob Hatcherson is currently offline Rob Hatcherson
Messages: 27
Registered: July 2009
Location: Fort Worth, TX, USA
Junior Member
> Well the contributor URI is just that, the "contributor"'s URI. The
> contributor would be the bundle from which the "contribution" is made.
> So if you want to set/change the content of a part, call setContributionURI()
> and make sure the URI is of the form
> bundleclass://your.plugin.id/namespace.of.your.Class

Yep, that was the problem. It works as I expected after choosing the API method with the right word in it :-/. Thanks JD!


> However, I wouldn't change the contribution if there is a chance the part
> has been rendered. AFAIK, the model will not cause the part to be re-rendered
> and it might introduce some instability.

According to one of Lars Vogel's tutorials lifecycle manager methods annotated with @ProcessAdditions are "...called directly before the model is passed to the renderer, can be used to add additional elements to the model." So, I guess this part of it is a non-issue, and we ought to able to fiddle with the model with impunity at this point.
Re: Calling setContributorURI From A @ProcessAdditions Method Has No Effect [message #907434 is a reply to message #907371] Mon, 03 September 2012 22:05 Go to previous message
Joseph Carroll is currently offline Joseph Carroll
Messages: 174
Registered: May 2012
Location: Milwaukee, WI
Senior Member

Yes that is correct, and that is exactly where it was intended to be "fiddled" with. I was just referencing the case where you grab the MPart from a live model element that has already been rendered and start "fiddling" with it.

Glad it works,

JD
Previous Topic:Graphiti and E4
Next Topic:New RCP / Integration into legacy RCP / Which approach?
Goto Forum:
  


Current Time: Thu Jul 31 11:49:03 EDT 2014

Powered by FUDForum. Page generated in 0.01693 seconds