Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » view and multiple viewers
view and multiple viewers [message #332867] Tue, 11 November 2008 17:01 Go to next message
Eclipse UserFriend
Hi all
I have got a view which use a table viewer and a tree viewer . both this
component are inside a PShelfItem (from nebula)

What I need is to set the view selection provider accordingly with the
active viewer . I have done this adding a selection listener to the PShell .
So depending on the selected Shelf Item I set the view selection provider .

The point is . with the debug everything looks fine . but the other view,
the one listening for selection, gets only the selection coming from the
first provider I set in the other view.
If I'm not wrong a view can have only one selection provider active at the
time ...

Am I doing something wrong?
Thanks
Kar
Re: view and multiple viewers [message #332877 is a reply to message #332867] Wed, 12 November 2008 06:31 Go to previous messageGo to next message
Eclipse UserFriend
> If I'm not wrong a view can have only one selection provider active at the
> time ...

Yes. At any given point of time, there can be only one active selection
provider for a view (or an editor)

> What I need is to set the view selection provider accordingly with the
> active viewer . I have done this adding a selection listener to the PShell
> .

Never used nebula, so not sure how it works. But switching the view's
selection provider based on the control that has the focus is the right
thing to do.

- Prakash
--

http://blog.eclipse-tips.com
Re: view and multiple viewers [message #332879 is a reply to message #332877] Wed, 12 November 2008 08:43 Go to previous messageGo to next message
Eclipse UserFriend
so why only the first provider I set works? all the following changes do not
take effect :(
kar


"Prakash G.R." <grprakash@gmail.com> wrote in message
news:gfdt92$9it$1@build.eclipse.org...
>> If I'm not wrong a view can have only one selection provider active at
>> the time ...
>
> Yes. At any given point of time, there can be only one active selection
> provider for a view (or an editor)
>
>> What I need is to set the view selection provider accordingly with the
>> active viewer . I have done this adding a selection listener to the
>> PShell .
>
> Never used nebula, so not sure how it works. But switching the view's
> selection provider based on the control that has the focus is the right
> thing to do.
>
> - Prakash
> --
>
> http://blog.eclipse-tips.com
>
>
Re: view and multiple viewers [message #332880 is a reply to message #332879] Wed, 12 November 2008 08:55 Go to previous messageGo to next message
Eclipse UserFriend
Well, I can't comment on a code which I didn't see :-) Is it possible to
share the code? At least, can you put a breakpoint at the point where you
set the view's selection provider and make sure that line executes?

- Prakash
--

http://blog.eclipse-tips.com



"Kar" <carmeloscala@hotmail.com> wrote in message
news:gfe4vh$ffn$1@build.eclipse.org...
> so why only the first provider I set works? all the following changes do
> not take effect :(
> kar
>
>
> "Prakash G.R." <grprakash@gmail.com> wrote in message
> news:gfdt92$9it$1@build.eclipse.org...
>>> If I'm not wrong a view can have only one selection provider active at
>>> the time ...
>>
>> Yes. At any given point of time, there can be only one active
>> selection provider for a view (or an editor)
>>
>>> What I need is to set the view selection provider accordingly with the
>>> active viewer . I have done this adding a selection listener to the
>>> PShell .
>>
>> Never used nebula, so not sure how it works. But switching the view's
>> selection provider based on the control that has the focus is the right
>> thing to do.
>>
>> - Prakash
>> --
>>
>> http://blog.eclipse-tips.com
>>
>>
Re: view and multiple viewers [message #332881 is a reply to message #332880] Wed, 12 November 2008 09:06 Go to previous messageGo to next message
Eclipse UserFriend
Morning Prakash and thanks ...
I have tried with the debug and the call is made correctly ... the weird
thing is that I can set the provider again ... but ...
if I set the provider to the table viewer ... switch to tree viewer ....
works fine ... NOW ... if from here I set the provider back again to the
table viewer ... the other view doesn't get any selection notification ....
but again it starts working if the selection is set back to the TreeViewer
....
ciao
kar


public void createPartControl(Composite parent)
{

PShelf pShelf = new PShelf(parent, SWT.NONE);
pShelf.addSelectionListener(new SelectionListener()
{

@Override
public void widgetDefaultSelected(SelectionEvent e)
{

}

@Override
public void widgetSelected(SelectionEvent e)
{
NavigatorTree.this.setSelectionProvider(e);

}
});


viewer = createTreeViewer ();

adminViewer = createTableViewer ();

...

getSite().setSelectionProvider(adminViewer);

....
}



protected void setSelectionProvider(SelectionEvent e)
{
String itemSelected = ((PShelfItem)e.item).getText();
if (itemSelected.equals(DATABASE))
{
System.out.println("setting database");
getSite().setSelectionProvider(getViewer());
}
else if (itemSelected.equals(SUB_ITEM))
{
System.out.println("setting null");
getSite().setSelectionProvider (null);
}
else if (itemSelected.equals(ADMIN))
{
System.out.println("setting admin");
getSite().setSelectionProvider(getAdminViewer());
}

}


"Prakash G.R." <grprakash@gmail.com> wrote in message
news:gfe5l8$agk$1@build.eclipse.org...
> Well, I can't comment on a code which I didn't see :-) Is it possible to
> share the code? At least, can you put a breakpoint at the point where you
> set the view's selection provider and make sure that line executes?
>
> - Prakash
> --
>
> http://blog.eclipse-tips.com
>
>
>
> "Kar" <carmeloscala@hotmail.com> wrote in message
> news:gfe4vh$ffn$1@build.eclipse.org...
>> so why only the first provider I set works? all the following changes do
>> not take effect :(
>> kar
>>
>>
>> "Prakash G.R." <grprakash@gmail.com> wrote in message
>> news:gfdt92$9it$1@build.eclipse.org...
>>>> If I'm not wrong a view can have only one selection provider active at
>>>> the time ...
>>>
>>> Yes. At any given point of time, there can be only one active
>>> selection provider for a view (or an editor)
>>>
>>>> What I need is to set the view selection provider accordingly with the
>>>> active viewer . I have done this adding a selection listener to the
>>>> PShell .
>>>
>>> Never used nebula, so not sure how it works. But switching the view's
>>> selection provider based on the control that has the focus is the right
>>> thing to do.
>>>
>>> - Prakash
>>> --
>>>
>>> http://blog.eclipse-tips.com
>>>
>>>
Re: view and multiple viewers [message #332882 is a reply to message #332880] Wed, 12 November 2008 09:08 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Why not registering your own instance of ISelectionProvider mediating
between the 2 internal ones.

This way you don't have to replace the selection provider?

Tom

Prakash G.R. schrieb:
> Well, I can't comment on a code which I didn't see :-) Is it possible to
> share the code? At least, can you put a breakpoint at the point where
> you set the view's selection provider and make sure that line executes?
>
> - Prakash


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: view and multiple viewers [message #332883 is a reply to message #332882] Wed, 12 November 2008 09:40 Go to previous message
Eclipse UserFriend
Thanks Tom ... this worked ...

actually reading a bit better the article on the selection I found this ...

--- Multiple Selection Providers Within a Part ---
Be aware that the part's site accepts a single selection provider only,
which should be registered within the createPartControl() method only:

getSite().setSelectionProvider(provider);

Replacing the selection provider during the lifetime of the part is not
properly supported by the workbench. If a part contains multiple viewers
providing selections, like the "Java Hierarchy" view does, a intermediate
ISelectionProvider implementation has to be provided that allows dynamically
delegating to the currently active viewer within the part. As a starting
point you may look into SelectionProviderIntermediate.java provided with
this article.

Thanks again

Ciao


"Tom Schindl" <tom.schindl@bestsolution.at> wrote in message
news:gfe6e6$d8k$1@build.eclipse.org...
> Hi,
>
> Why not registering your own instance of ISelectionProvider mediating
> between the 2 internal ones.
>
> This way you don't have to replace the selection provider?
>
> Tom
>
> Prakash G.R. schrieb:
>> Well, I can't comment on a code which I didn't see :-) Is it possible to
>> share the code? At least, can you put a breakpoint at the point where
>> you set the view's selection provider and make sure that line executes?
>>
>> - Prakash
>
>
> --
> B e s t S o l u t i o n . at
> ------------------------------------------------------------ --------
> Tom Schindl JFace-Committer
> ------------------------------------------------------------ --------
Previous Topic:How to open a file and jump to a certain line number
Next Topic:cannot be cast to org.eclipse.ui.ide.FileStoreEditorInput
Goto Forum:
  


Current Time: Mon Feb 10 00:19:31 GMT 2025

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

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

Back to the top