You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "A.J. (JIRA)" <ji...@apache.org> on 2010/08/26 09:27:54 UTC

[jira] Created: (PIVOT-611) add a method hasListener() in ListenerList object

add a method hasListener() in ListenerList object
-------------------------------------------------

                 Key: PIVOT-611
                 URL: https://issues.apache.org/jira/browse/PIVOT-611
             Project: Pivot
          Issue Type: Improvement
    Affects Versions: 1.5
            Reporter: A.J.
            Priority: Minor


there is no easy way to determine wether a listener has already been added to a listener list (except by getting an iterator and traversing the list).
it would be convenient to have 'hasListener' method in the ListenerList class that encapsulates this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-611) add a method hasListener() in ListenerList object

Posted by "A.J. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902792#action_12902792 ] 

A.J. commented on PIVOT-611:
----------------------------

Here it is

    /**
     * Check wether the listener has already been added
     *
     * @param listener
     * @return true if and only if the given listener has already been added to this list
     */
    public boolean contains(T listener) {
        if (listener == null) {
            throw new IllegalArgumentException("listener is null.");
        }

        Node node = first;
        while (node != null
                && node.listener != listener) {
                node = node.next;
        }

        return (node != null);
    }

If you want me to add it to the code base, please let me know how you want me to proceed (svn commit ? patch ? ...)


> add a method hasListener() in ListenerList object
> -------------------------------------------------
>
>                 Key: PIVOT-611
>                 URL: https://issues.apache.org/jira/browse/PIVOT-611
>             Project: Pivot
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: A.J.
>            Priority: Minor
>
> there is no easy way to determine wether a listener has already been added to a listener list (except by getting an iterator and traversing the list).
> it would be convenient to have 'hasListener' method in the ListenerList class that encapsulates this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-611) add a method hasListener() in ListenerList object

Posted by "A.J. (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902870#action_12902870 ] 

A.J. commented on PIVOT-611:
----------------------------

I'm creating a Form at runtime based on user interaction;
In this process, I'm adding listeners on some components.
During user interaction, some of these components may be processed again (listeners set) and I want to avoid having twice the same listener on the component (it wont happen, I will get a sysout message instead, but I want to avoid this too).
When the form is hidden or disposed, I just want to remove the listeners without having to create a Map at application level to retain which component is concerned or not.
The remove() method does not fit here since it will throw an error if the listener has not been added.
I could refactor all this to have a more precise behaviour, but having this method could save me a lot of time :)
and I think it could be useful in other circumstances as well.

> add a method hasListener() in ListenerList object
> -------------------------------------------------
>
>                 Key: PIVOT-611
>                 URL: https://issues.apache.org/jira/browse/PIVOT-611
>             Project: Pivot
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: A.J.
>            Priority: Minor
>
> there is no easy way to determine wether a listener has already been added to a listener list (except by getting an iterator and traversing the list).
> it would be convenient to have 'hasListener' method in the ListenerList class that encapsulates this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-611) add a method hasListener() in ListenerList object

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902830#action_12902830 ] 

Greg Brown commented on PIVOT-611:
----------------------------------

I don't see any harm in adding this method, but I am curious about your use case. Under what circumstances might you not know whether a listener has already been added/removed or not?


> add a method hasListener() in ListenerList object
> -------------------------------------------------
>
>                 Key: PIVOT-611
>                 URL: https://issues.apache.org/jira/browse/PIVOT-611
>             Project: Pivot
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: A.J.
>            Priority: Minor
>
> there is no easy way to determine wether a listener has already been added to a listener list (except by getting an iterator and traversing the list).
> it would be convenient to have 'hasListener' method in the ListenerList class that encapsulates this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-611) add a method hasListener() in ListenerList object

Posted by "Noel Grandin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12902764#action_12902764 ] 

Noel Grandin commented on PIVOT-611:
------------------------------------

public boolean contains(T t) {}
  would be the appropriate method to add 

> add a method hasListener() in ListenerList object
> -------------------------------------------------
>
>                 Key: PIVOT-611
>                 URL: https://issues.apache.org/jira/browse/PIVOT-611
>             Project: Pivot
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: A.J.
>            Priority: Minor
>
> there is no easy way to determine wether a listener has already been added to a listener list (except by getting an iterator and traversing the list).
> it would be convenient to have 'hasListener' method in the ListenerList class that encapsulates this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PIVOT-611) add a method hasListener() in ListenerList object

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-611?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown resolved PIVOT-611.
------------------------------

    Fix Version/s: 1.5.2
                   2.0
       Resolution: Fixed

Resolved. Thanks for the patch!


> add a method hasListener() in ListenerList object
> -------------------------------------------------
>
>                 Key: PIVOT-611
>                 URL: https://issues.apache.org/jira/browse/PIVOT-611
>             Project: Pivot
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: A.J.
>            Priority: Minor
>             Fix For: 1.5.2, 2.0
>
>
> there is no easy way to determine wether a listener has already been added to a listener list (except by getting an iterator and traversing the list).
> it would be convenient to have 'hasListener' method in the ListenerList class that encapsulates this.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.