Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 17: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 18:31 Go to previous messageGo to next message
Snjezana Peco is currently offline Snjezana PecoFriend
Messages: 789
Registered: July 2009
Senior Member
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 19: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 14:26 Go to previous messageGo to next message
Daniel Krügler is currently offline Daniel KrüglerFriend
Messages: 853
Registered: July 2009
Senior Member
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 16:35 Go to previous messageGo to next message
Patrick Paulin is currently offline Patrick PaulinFriend
Messages: 44
Registered: July 2009
Location: Madison, Wisconsin
Member
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


Patrick Paulin
Eclipse RCP/OSGi Trainer and Consultant
Modular Mind, Ltd.

patrick@modumind.com
www.modumind.com
twitter.com/pjpaulin
linkedin.com/in/pjpaulin
Re: Obtain JFace Viewer selection within a wizard [message #462619 is a reply to message #462544] Wed, 31 January 2007 03: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: Wed Sep 18 05:52:36 GMT 2024

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

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

Back to the top