Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to get a selected object for an Action?
How to get a selected object for an Action? [message #447766] Fri, 14 April 2006 14:52 Go to next message
Eclipse UserFriend
Originally posted by: kale12.yahoo.com

How to get a selected object inside the run() method for an Action?

it would be more helpful if anyone can provide a link or sample example.

Thanks,
Kale
Re: How to get a selected object for an Action? [message #447782 is a reply to message #447766] Sat, 15 April 2006 22:09 Go to previous messageGo to next message
Stefan Zugal is currently offline Stefan ZugalFriend
Messages: 59
Registered: July 2009
Member
You could use the SelectionService from your IWorkbenchWindow

code ;-)
window.getSelectionService()

Regards,
Stefan

Kale schrieb:
> How to get a selected object inside the run() method for an Action?
>
> it would be more helpful if anyone can provide a link or sample example.
>
> Thanks,
> Kale
>
Re: How to get a selected object for an Action? [message #447793 is a reply to message #447782] Sun, 16 April 2006 14:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kale.kale.com

yes I tried it but window.getSelectionService().getSelection() returns
null.

will I have to set the selection somewhere?

Thanks,
Kale
Re: How to get a selected object for an Action? [message #447801 is a reply to message #447793] Mon, 17 April 2006 07:46 Go to previous messageGo to next message
Neil Bartlett is currently offline Neil BartlettFriend
Messages: 93
Registered: July 2009
Member
Kale,

Assuming you're using a Viewer (eg TreeViewer, TableViewer) inside your
view, and that contains the things that can be selected, then you need to
set that Viewer as the selection provider for your view site.

Eg in your createPartControl() call getSite().setSelectionProvider(viewer)

- Neil


Kale wrote:

> yes I tried it but window.getSelectionService().getSelection() returns
> null.

> will I have to set the selection somewhere?

> Thanks,
> Kale
Re: How to get a selected object for an Action? [message #447808 is a reply to message #447766] Mon, 17 April 2006 14:29 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

How was your action created? If it's done via actionSets, you subclass
ActionDelegate which allows you to override selectionChanged(IAction
action, ISelection selection) and save the selection when it changes.

Later,
PW


Re: How to get a selected object for an Action? [message #447817 is a reply to message #447801] Mon, 17 April 2006 15:53 Go to previous message
Eclipse UserFriend
Originally posted by: kale.k.com

Yes this works. Thanks to everyone for the help.

Regards,
Kale
Previous Topic:Virtual Directory Structure
Next Topic:logtest problem
Goto Forum:
  


Current Time: Fri Dec 13 22:56:18 GMT 2024

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

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

Back to the top