Best practice to handle a null selection [message #466727] |
Tue, 24 April 2007 07:32 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #466878 is a reply to message #466843] |
Thu, 26 April 2007 07:40 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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...
|
|
|
Powered by
FUDForum. Page generated in 0.04358 seconds