Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
> 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
Eclipse UserFriend
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: Tue Jul 22 18:15:35 EDT 2025

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

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

Back to the top