Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to get view part from Handler
How to get view part from Handler [message #1008149] Mon, 11 February 2013 04:07 Go to next message
Li Chen is currently offline Li ChenFriend
Messages: 20
Registered: July 2011
Location: Sydney
Junior Member
I have a injected view part class: TestView and a handler class: TestHandler.
And I wish to obtained the exact injected TestView object, could somebody tell me how to do that please?

I've tried to use PartService.getPart(), but this only give me a MPart object.
I've also tried use ContextInjectionFactory.make(), but this creates a new TestView object instead of the one used as my view.

Thanks.
Re: How to get view part from Handler [message #1008151 is a reply to message #1008149] Mon, 11 February 2013 04:19 Go to previous messageGo to next message
Li Chen is currently offline Li ChenFriend
Messages: 20
Registered: July 2011
Location: Sydney
Junior Member
I've tried add
 @Named("viewId") TestView test View
as a parameter of the handler's execute() method but still not working
Re: How to get view part from Handler [message #1008152 is a reply to message #1008149] Mon, 11 February 2013 04:26 Go to previous messageGo to next message
Li Chen is currently offline Li ChenFriend
Messages: 20
Registered: July 2011
Location: Sydney
Junior Member
No Message Body

[Updated on: Mon, 11 February 2013 04:28]

Report message to a moderator

Re: How to get view part from Handler [message #1008166 is a reply to message #1008152] Mon, 11 February 2013 08:59 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot CelaFriend
Messages: 597
Registered: December 2010
Senior Member

MPart.getObject() and cast it to your runtime class.
Re: How to get view part from Handler [message #1008258 is a reply to message #1008149] Mon, 11 February 2013 07:33 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
Did you inspect the MPart instance - believe me you'll find a method
there to give you the instance of your view.

Tom

Am 11.02.13 06:07, schrieb Li Chen:
> I have a injected view part class: TestView and a handler class:
> TestHandler.
> And I wish to obtained the exact injected TestView object, could
> somebody tell me how to do that please?
>
> I've tried to use PartService.getPart(), but this only give me a MPart
> object.
> I've also tried use ContextInjectionFactory.make(), but this creates a
> new TestView object instead of the one used as my view.
>
> Thanks.
Re: How to get view part from Handler [message #1008322 is a reply to message #1008149] Mon, 11 February 2013 22:30 Go to previous messageGo to next message
Li Chen is currently offline Li ChenFriend
Messages: 20
Registered: July 2011
Location: Sydney
Junior Member
Thanks. Embarrassed

Also, may I ask if I am using the "best practice" here?
What I want to do is to set some data that is associated with the TestView class. So I try to obtain that object and then set it's attribute.
In eclipse 4, is there any "standard practice" to solve this kind of problem? such as using IEventBroker to post the data.
Re: How to get view part from Handler [message #1008324 is a reply to message #1008322] Mon, 11 February 2013 22:35 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5467
Registered: July 2009
Senior Member
there are 2 ways:
a) send an event using IEventBroker
b) set the value in the IEclipseContext of the part or one of the parent
contexts
Am 11.02.13 23:30, schrieb Li Chen:
> Thanks. :blush:
> Also, may I ask if I am using the "best practice" here? What I want to
> do is to set some data that is associated with the TestView class. So I
> try to obtain that object and then set it's attribute.
> In eclipse 4, is there any "standard practice" to solve this kind of
> problem? such as using IEventBroker to post the data.
Re: How to get view part from Handler [message #1008325 is a reply to message #1008149] Mon, 11 February 2013 22:45 Go to previous message
Li Chen is currently offline Li ChenFriend
Messages: 20
Registered: July 2011
Location: Sydney
Junior Member
Razz That's quick, Thanks
Previous Topic:Command parameters in context menu
Next Topic:creating input part via part descriptor
Goto Forum:
  


Current Time: Wed Nov 26 04:30:20 GMT 2014

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

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