[ 
https://issues.apache.org/jira/browse/PIVOT-670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12932686#action_12932686
 ] 

Greg Brown commented on PIVOT-670:
----------------------------------

> i generally consider using a single/shared listener for distinct classes as a 
> bad idea. 

Component fires events that are shared by all components, and each subclass 
fires its own class-specific events. Are you suggesting that only concrete 
classes should fire events? If so, how would you handle common events (such as 
mouse move, etc.)?

Doesn't GWT have the same issue? For example, the 
com.google.gwt.user.client.ui.MouseListener interface passes a Widget as the 
sender argument to all of the user input event handler methods.



> Generic types for listeners
> ---------------------------
>
>                 Key: PIVOT-670
>                 URL: https://issues.apache.org/jira/browse/PIVOT-670
>             Project: Pivot
>          Issue Type: Improvement
>         Environment: All
>            Reporter: Frédéric VERGEZ
>            Priority: Trivial
>
> Could listener interfaces have generic types ?
> This would allow to be type safe in methods, and avoid objects casting.
> For instance in a ComponentMouseListener:
> public interface ComponentMouseListener<T extends Component> {
>     /**
>      * Component mouse button listener adapter.
>      */
>     public static class Adapter implements ComponentMouseListener {
>         @Override
>         public boolean mouseMove(T component, int x, int y) {
>             return false;
>         }
>         @Override
>         public void mouseOver(T component) {
>         }
>         @Override
>         public void mouseOut(T component) {
>         }
>     }
>     /**
>      * Called when the mouse is moved over a component.
>      *
>      * @param component
>      * @param x
>      * @param y
>      *
>      * @return
>      * <tt>true</tt> to consume the event; <tt>false</tt> to allow it to
>      * propagate.
>      */
>     public boolean mouseMove(T component, int x, int y);
>     /**
>      * Called when the mouse enters a component.
>      *
>      * @param component
>      */
>     public void mouseOver(T component);
>     /**
>      * Called when the mouse exits a component.
>      *
>      * @param component
>      */
>     public void mouseOut(T component);
> }

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

Reply via email to