| Calling setContributorURI From A @ProcessAdditions Method Has No Effect [message #906190] |
Fri, 31 August 2012 16:16  |
Rob Hatcherson Messages: 25 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 #907371 is a reply to message #906448] |
Mon, 03 September 2012 17:33   |
Rob Hatcherson Messages: 25 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.
|
|
|
|
Powered by
FUDForum. Page generated in 0.01702 seconds