private TypedListener findSelectionListener(Widget provider, Class<?> declaringClass) {
   for (Listener o : provider.getListeners(SWT.Selection))
     if (o instanceof TypedListener
         && ((TypedListener) o).getEventListener().getClass().getDeclaringClass()
             == declaringClass) return (TypedListener) o;
   return null;
 }
 private TypedListener findMenuListener(Widget provider, Class<?> declaringClass) {
   for (Listener o : provider.getListeners(SWT.Show))
     try {
       if (o instanceof TypedListener
           && ((TypedListener) o)
                   .getEventListener()
                   .getClass()
                   .getDeclaredField("this$0")
                   .getType()
               == declaringClass) return (TypedListener) o;
     } catch (NoSuchFieldException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     } catch (SecurityException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   return null;
 }