Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Best practice to handle a null selection
Best practice to handle a null selection [message #466727] Tue, 24 April 2007 07:32 Go to next message
Eclipse UserFriend
Originally posted by: robert.moestl.joanneum.at

Hello!

I'm wondering what's the best practice to handle null selections in the
communication between ViewParts.

My solution to this problem is to implement INullSelectionListener
adding it like that:
this.getSite().getPage().addSelectionListener(String partId,
INullSelectionListener listener);

So the listener only listens to null selections of the ViewPart
specified by partId. The problem is that the one ViewPart must know the
other ViewPart in order to get the partId. But i mean this violates the
concept of uncoupled ViewParts via the Selection mechanism.

Another solution I worked out is to define a marker interface. The
selection listener checks if the part where the selection occurred is an
instance of the marker interface and if the selection is empty. That way
I am also able to identify relevant null selections for a ViewPart.
Additionally I mean that this also doesn't violate the concept of
uncoupled ViewParts...

What do you think? Is there another maybe more elegant way to deal with
null selections?

Kind regards,
Robert
Re: Best practice to handle a null selection [message #466742 is a reply to message #466727] Tue, 24 April 2007 12:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

On Tue, 24 Apr 2007 09:32:06 +0200, Robert Möstl wrote:


>
> What do you think? Is there another maybe more elegant way to deal with
> null selections?
>
> Kind regards,
> Robert

How are you getting null selections? I don't know any way to deselect.
Have you looked at IAdapter?
Re: Best practice to handle a null selection [message #466744 is a reply to message #466742] Tue, 24 April 2007 13:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: robert.moestl.joanneum.at

CL 'dnoyeB' Gilbert wrote:
> On Tue, 24 Apr 2007 09:32:06 +0200, Robert Möstl wrote:
>
>
>> What do you think? Is there another maybe more elegant way to deal with
>> null selections?
>>
>> Kind regards,
>> Robert
>
> How are you getting null selections? I don't know any way to deselect.
> Have you looked at IAdapter?

Hi!

First of all thank you for your participation.

I define a null selection, if for some reason a ViewPart gets empty.
Just like when in JDT all projects in the Projects-View got deleted. In
that case no selection takes place, but although in other ViewParts you
want to react on that event...

Hopefully you understand what I mean ;-)
Re: Best practice to handle a null selection [message #466837 is a reply to message #466744] Wed, 25 April 2007 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

On Tue, 24 Apr 2007 15:20:25 +0200, Robert Möstl wrote:
>
> Hi!
>
> First of all thank you for your participation.
>
> I define a null selection, if for some reason a ViewPart gets empty.
> Just like when in JDT all projects in the Projects-View got deleted. In
> that case no selection takes place, but although in other ViewParts you
> want to react on that event...
>
> Hopefully you understand what I mean ;-)

OK. A selection is a list. In this case you should see an
'empty' selection. Not a null selection.
Re: Best practice to handle a null selection [message #466839 is a reply to message #466837] Wed, 25 April 2007 15:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: robert.moestl.joanneum.at

CL 'dnoyeB' Gilbert wrote:
> On Tue, 24 Apr 2007 15:20:25 +0200, Robert Möstl wrote:
>> Hi!
>>
>> First of all thank you for your participation.
>>
>> I define a null selection, if for some reason a ViewPart gets empty.
>> Just like when in JDT all projects in the Projects-View got deleted. In
>> that case no selection takes place, but although in other ViewParts you
>> want to react on that event...
>>
>> Hopefully you understand what I mean ;-)
>
> OK. A selection is a list. In this case you should see an
> 'empty' selection. Not a null selection.

Thank you! This term may fit better for such a selection.

Back to the main question... any ideas how to handle empty selections?
Re: Best practice to handle a null selection [message #466843 is a reply to message #466839] Wed, 25 April 2007 18:18 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
If you don't want to couple the listener with a part id, they why do you use the addSelectionListener(String partId, ISelectionListener listener) API? Try addSelectionListener(ISelectionListener listener) instead.
Re: Best practice to handle a null selection [message #466878 is a reply to message #466843] Thu, 26 April 2007 07:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: robert.moestl.joanneum.at

Prakash wrote:
> If you don't want to couple the listener with a part id, they why do you use the addSelectionListener(String partId, ISelectionListener listener) API? Try addSelectionListener(ISelectionListener listener) instead.

Thanks, but in my opinion that would not solve the problem. If I use
addSelectionListener(ISelectionListener listener) instead then I have to
ask in #selectionChanged if the SelectionProvider is instance of a
certain ViewPart. So I just "moved the problem into #selectionChanged"...
Re: Best practice to handle a null selection [message #466908 is a reply to message #466839] Thu, 26 April 2007 13:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lamont_gilbert.rigidsoftware.com

On Wed, 25 Apr 2007 17:01:12 +0200, Robert Möstl wrote:

> CL 'dnoyeB' Gilbert wrote:
>>
>> OK. A selection is a list. In this case you should see an
>> 'empty' selection. Not a null selection.
>
> Thank you! This term may fit better for such a selection.
>
> Back to the main question... any ideas how to handle empty selections?

That depends on what you do with a non-empty selection. I don't
understand why you must always have a selection? What is it that you do
with this?
Re: Best practice to handle a null selection [message #466916 is a reply to message #466908] Thu, 26 April 2007 13:41 Go to previous message
Eclipse UserFriend
Originally posted by: robert.moestl.joanneum.at

CL 'dnoyeB' Gilbert wrote:
> On Wed, 25 Apr 2007 17:01:12 +0200, Robert Möstl wrote:
>
>> CL 'dnoyeB' Gilbert wrote:
>>> OK. A selection is a list. In this case you should see an
>>> 'empty' selection. Not a null selection.
>> Thank you! This term may fit better for such a selection.
>>
>> Back to the main question... any ideas how to handle empty selections?
>
> That depends on what you do with a non-empty selection. I don't
> understand why you must always have a selection? What is it that you do
> with this?

I already opened a thread in this newsgroup with the title 'Problem with
communication between Views over Selection Mechanism' where I described
the problem... Unfortunately I got no answers and therefore I tried to
point out the problem more general in this thread...
Previous Topic:How to get custom sized icons in perspective bar?
Next Topic:eclipse xml editor
Goto Forum:
  


Current Time: Thu Apr 25 02:09:01 GMT 2024

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

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

Back to the top