Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » ViewPart's @PostConstruct createControls() not called
ViewPart's @PostConstruct createControls() not called [message #1001493] Wed, 16 January 2013 20:24 Go to next message
Joel Becker is currently offline Joel Becker
Messages: 14
Registered: December 2012
Junior Member
Hi,

I defined a MPartDescriptor in my Application.e4xmi, then in a Handler I get an EPartService injected which I use to createPart() and showPart(). I can then get my actual ViewPart impl object from mpart.getObject(). The problem I have though is that my ViewPart class's createControls() is never called. It is annotated with @PostConstruct (the ViewPart class was created with the Eclipse 4 ViewPart wizard). Any ideas how I can get the method to be called? (I can't call it myself because I don't have the parent Composite that must be passed in...)
Re: ViewPart's @PostConstruct createControls() not called [message #1001526 is a reply to message #1001493] Wed, 16 January 2013 21:43 Go to previous messageGo to next message
Frank Benoit is currently offline Frank Benoit
Messages: 47
Registered: July 2009
Member
Hi

I add the part to its new parent part stack, like this

	    MPartStack stack = (MPartStack) modelService.find("org.eclipse.e4.primaryDataStack", appl);	    
	    MPart part = partService.createPart("...");
	    stack.getChildren().add(part);
	    partService.showPart(part, PartState.ACTIVATE);


cu
Frank
Re: ViewPart's @PostConstruct createControls() not called [message #1001534 is a reply to message #1001493] Wed, 16 January 2013 22:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5400
Registered: July 2009
Senior Member
If @PostConstruct is not called please check if the bundle in question
does an import-package for javax.annotation, do not use require bundle!
You need to have a import-package javax.annotation 1.0.0

Tom

Am 16.01.13 21:24, schrieb Joel Becker:
> Hi,
>
> I defined a MPartDescriptor in my Application.e4xmi, then in a Handler I
> get an EPartService injected which I use to createPart() and showPart().
> I can then get my actual ViewPart impl object from mpart.getObject().
> The problem I have though is that my ViewPart class's createControls()
> is never called. It is annotated with @PostConstruct (the ViewPart class
> was created with the Eclipse 4 ViewPart wizard). Any ideas how I can get
> the method to be called? (I can't call it myself because I don't have
> the parent Composite that must be passed in...)
>
Re: ViewPart's @PostConstruct createControls() not called [message #1001918 is a reply to message #1001534] Thu, 17 January 2013 14: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

@Tom

I am not familiar with the issue of required vs. imported javax.annotation. Is there a bug or some other documentation where I can read a little more about this?

Thanks,

JD

ps. - I haven't run into an issue, but I want to make sure I don't Smile
Re: ViewPart's @PostConstruct createControls() not called [message #1001951 is a reply to message #1001534] Thu, 17 January 2013 15:47 Go to previous messageGo to next message
Joel Becker is currently offline Joel Becker
Messages: 14
Registered: December 2012
Junior Member
Thanks, Frank and Tom. I was missing the javax.annotation package import.
Re: ViewPart's @PostConstruct createControls() not called [message #1002005 is a reply to message #1001918] Thu, 17 January 2013 17:39 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5400
Registered: July 2009
Senior Member
IIRC there's even an FAQ,
http://wiki.eclipse.org/Eclipse4/RCP/FAQ#Why_isn.27t_my_.40Inject-able.2F.40PostConstruct_methods_being_injected.3F

Tom

Am 17.01.13 15:59, schrieb Joseph Carroll:
> @Tom
>
> I am not familiar with the issue of required vs. imported
> javax.annotation. Is there a bug or some other documentation where I can
> read a little more about this?
>
> Thanks,
>
> JD
>
> ps. - I haven't run into an issue, but I want to make sure I don't :)
Previous Topic:Putting a PerspectiveStack on a Part
Next Topic:No menu when launching newly built e4 application
Goto Forum:
  


Current Time: Tue Oct 21 10:33:43 GMT 2014

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

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