Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [riena-dev] ListenerList vs ArrayList

I think we should agree on something (either duplicates or not). Now you, Elias, removed the ListenerList to allow duplicates while
Thorsten just on monday replaced an ArrayList with the ListenerList.

There should be a unique policy throughout Riena. I am sure what the policy is in Eclipse. I thought the ListenerList that we use is just a copy of the class of Riena with an API that supports Generics. So the "offiicial" class in Eclipse that should be used for Listeners does not
allow duplicates (or better it ignores them).

If you ignore what could happen is that if you add the same listener twice and then remove one, no listener is registered (since there is no counter). So can a programmer know that a listener he wants to register (this particular instance) is already registered ? If he can, then he is doing something wrong registering it the second time. Its a little that we dont throw an exception for duplicates then, but that is the way the Eclipse class behaves.

IMHO I think since the ListenerList exists we should use it for each and every case where a Listener is required. Since the original implementation from Eclipse ignores duplicates (and hence does not allow them), we could think about throwing some kind of runtime exception and document that duplicate
listeners are not allowed.

What do you guys think ?

christian


Am 27.08.2008 um 07:31 schrieb Stefan Liebig:

We could also extend ListenerList to allow duplicates. There is already an enum Mode that could be
extended for that.
However, does it make sense for a listener to be notified multiple times for the same event?

Stefan

Volanakis, Elias wrote:
Just FYI, in the Tree/Table/List-Ridget I changed the container for the double click listeners to ArrayList (recently changed to ListenerList). The reason for using an ArrayList is that adding duplicate listeners is
explicitly permitted there.

This fixes the recent test failures in #testAddDoubleClickListener.
Feel free to discuss if you disagree. The alternative is to adjust the
tests / javadoc to disallow duplicate listeners.

Thanks,
Elias.

_______________________________________________
riena-dev mailing list
riena-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/riena-dev


_______________________________________________
riena-dev mailing list
riena-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/riena-dev



Back to the top