Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » How to get view part from Handler
How to get view part from Handler [message #1008149] Sun, 10 February 2013 23:07 Go to next message
Eclipse UserFriend
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] Sun, 10 February 2013 23:19 Go to previous messageGo to next message
Eclipse UserFriend
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] Sun, 10 February 2013 23:26 Go to previous messageGo to next message
Eclipse UserFriend
No Message Body

[Updated on: Sun, 10 February 2013 23:28] by Moderator

Re: How to get view part from Handler [message #1008166 is a reply to message #1008152] Mon, 11 February 2013 03:59 Go to previous messageGo to next message
Eclipse UserFriend
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 02:33 Go to previous messageGo to next message
Eclipse UserFriend
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 17:30 Go to previous messageGo to next message
Eclipse UserFriend
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 17:35 Go to previous messageGo to next message
Eclipse UserFriend
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 17:45 Go to previous message
Eclipse UserFriend
Razz That's quick, Thanks
Previous Topic:Command parameters in context menu
Next Topic:creating input part via part descriptor
Goto Forum:
  


Current Time: Thu Jul 24 11:24:39 EDT 2025

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

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

Back to the top