Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Obtain JFace Viewer selection within a wizard
Obtain JFace Viewer selection within a wizard [message #462451] Mon, 29 January 2007 12:34 Go to next message
Eclipse UserFriend
Originally posted by: newsgroup.weyands.net

Hello Newsgroup,

i'm working on a little Plugin. The Data is presented with a TreeViewer.
To add new Objects to my tree im working on a wizard right now, but
could not figure out how i can get the item that's selected when i fire
my action (item -> contextMenu -> wizardaction).

The ISelectionListener seems to be for View-View interaction only - any
hint on how i can obtain the selectedObject in my wizard?

Any Help is appreciated!

-Chris
Re: Obtain JFace Viewer selection within a wizard [message #462460 is a reply to message #462451] Mon, 29 January 2007 13:31 Go to previous messageGo to next message
Eclipse UserFriend
Use the Viewer.addSelectionChangedListener(ISelectionChangedListener
listener) method.
You can get the selected item by using getSelection()

Snjeza

Christian Weyand wrote:
> Hello Newsgroup,
>
> i'm working on a little Plugin. The Data is presented with a TreeViewer.
> To add new Objects to my tree im working on a wizard right now, but
> could not figure out how i can get the item that's selected when i fire
> my action (item -> contextMenu -> wizardaction).
>
> The ISelectionListener seems to be for View-View interaction only - any
> hint on how i can obtain the selectedObject in my wizard?
>
> Any Help is appreciated!
>
> -Chris
Re: Obtain JFace Viewer selection within a wizard [message #462466 is a reply to message #462460] Mon, 29 January 2007 14:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: newsgroup.weyands.net

Snjezana Peco schrieb:
> Use the Viewer.addSelectionChangedListener(ISelectionChangedListener
> listener) method.
> You can get the selected item by using getSelection()
>
> Snjeza
>

Thanks for your reply Snjeza,

the SelectionChangedListener is added to my view. But i can't figure out
how to access this information within my Wizard class.

I've added the following lines to my createPartControl Method of my viewer:

treeViewer.addSelectionChangedListener(new ISelectionChangedListener () {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection)
event.getSelection();
}
});

getViewSite().setSelectionProvider(treeViewer);

But i got no direct access to my viewer within the wizard to add the
SelectionChangedListener to this class..


Greetings
-chris
> Christian Weyand wrote:
>> Hello Newsgroup,
>>
>> i'm working on a little Plugin. The Data is presented with a
>> TreeViewer. To add new Objects to my tree im working on a wizard
>> right now, but could not figure out how i can get the item that's
>> selected when i fire my action (item -> contextMenu -> wizardaction).
>>
>> The ISelectionListener seems to be for View-View interaction only -
>> any hint on how i can obtain the selectedObject in my wizard?
>>
>> Any Help is appreciated!
>>
>> -Chris
Re: Obtain JFace Viewer selection within a wizard [message #462544 is a reply to message #462466] Tue, 30 January 2007 09:26 Go to previous messageGo to next message
Eclipse UserFriend
Christian Weyand wrote:
> Snjezana Peco schrieb:
>
>> Use the Viewer.addSelectionChangedListener(ISelectionChangedListener
>> listener) method.
>> You can get the selected item by using getSelection()
>>
>> Snjeza
>>
>
> Thanks for your reply Snjeza,
>
> the SelectionChangedListener is added to my view. But i can't figure out
> how to access this information within my Wizard class.
>
> I've added the following lines to my createPartControl Method of my viewer:
>
> treeViewer.addSelectionChangedListener(new ISelectionChangedListener () {
> public void selectionChanged(SelectionChangedEvent event) {
> IStructuredSelection selection = (IStructuredSelection)
> event.getSelection();
> }
> });
>
> getViewSite().setSelectionProvider(treeViewer);
>
> But i got no direct access to my viewer within the wizard to add the
> SelectionChangedListener to this class..

First: Don't forget to register your view as selection provider
Second: You have a basic design problem not related to your IDE and
programming language. One solution for this would be that your
view forwards the selection change event to interested listeners (e.g.
your wizard).

Greetings from Bremen,

Daniel Krügler
Re: Obtain JFace Viewer selection within a wizard [message #462571 is a reply to message #462451] Tue, 30 January 2007 11:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi Chris,

I'm assuming you're trying to capture the selection at the point the
wizard is created. If so, you need to do the following:

1. Register your TreeViewer as the selection provider for the view.
2. Add a "selection" element to your wizard extension declaration. This
allows you to get access to the current workbench selection if the all
selected elements are instances of a certain type.
3. Access the selection in the init method of your wizard.

Hope this helps,

--- Patrick
patrick@rcpquickstart.com


Christian Weyand wrote:

> Hello Newsgroup,

> i'm working on a little Plugin. The Data is presented with a TreeViewer.
> To add new Objects to my tree im working on a wizard right now, but
> could not figure out how i can get the item that's selected when i fire
> my action (item -> contextMenu -> wizardaction).

> The ISelectionListener seems to be for View-View interaction only - any
> hint on how i can obtain the selectedObject in my wizard?

> Any Help is appreciated!

> -Chris
Re: Obtain JFace Viewer selection within a wizard [message #462619 is a reply to message #462544] Tue, 30 January 2007 22:38 Go to previous message
Eclipse UserFriend
Originally posted by: partyhut.internode.on.net

Hi Daniel,

I had the same question few days ago with my SWT + Jface app(not RCP).
How exactly to forwards the seleciton change event to a listener? Can
the listener be the parent composite or the parent's parent?

Thank you!

HS

Daniel Krügler wrote:
> Christian Weyand wrote:
>> Snjezana Peco schrieb:
>>
>>> Use the Viewer.addSelectionChangedListener(ISelectionChangedListener
>>> listener) method.
>>> You can get the selected item by using getSelection()
>>>
>>> Snjeza
>>>
>>
>> Thanks for your reply Snjeza,
>>
>> the SelectionChangedListener is added to my view. But i can't figure
>> out how to access this information within my Wizard class.
>>
>> I've added the following lines to my createPartControl Method of my
>> viewer:
>>
>> treeViewer.addSelectionChangedListener(new ISelectionChangedListener () {
>> public void selectionChanged(SelectionChangedEvent event) {
>> IStructuredSelection selection =
>> (IStructuredSelection) event.getSelection();
>> }
>> });
>>
>> getViewSite().setSelectionProvider(treeViewer);
>>
>> But i got no direct access to my viewer within the wizard to add the
>> SelectionChangedListener to this class..
>
> First: Don't forget to register your view as selection provider
> Second: You have a basic design problem not related to your IDE and
> programming language. One solution for this would be that your
> view forwards the selection change event to interested listeners (e.g.
> your wizard).
>
> Greetings from Bremen,
>
> Daniel Krügler
Previous Topic:What is rcp plugin?
Next Topic:TreeViewer refresh
Goto Forum:
  


Current Time: Sun Jul 06 08:24:02 EDT 2025

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

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

Back to the top