Package com.google.gwt.event.shared

Examples of com.google.gwt.event.shared.HandlerRegistration


    public void reset() {
        resetMessageText();

        Iterator<HandlerRegistration> theHandlerRegistrationIterator = myHandlerRegistrations.iterator();
        while(theHandlerRegistrationIterator.hasNext()) {
            HandlerRegistration theHandlerRegistration = theHandlerRegistrationIterator.next();
            theHandlerRegistration.removeHandler();
            theHandlerRegistrationIterator.remove();
        }
    }
View Full Code Here


    public void setFocus(boolean isFocus) {
        myMessageTextBox.setFocus(isFocus);
    }

    public HandlerRegistration addSendButtonListener(ClickHandler aClickHandler) {
        final HandlerRegistration theHandlerRegistration = mySendButton.addClickHandler(aClickHandler);
        myHandlerRegistrations.add(theHandlerRegistration);
        return theHandlerRegistration;
    }
View Full Code Here

    }

    @Override
    public void show() {
        //Hook-up events
        final HandlerRegistration registration = eventBus.addHandler( TemplateVariablesChangedEvent.TYPE,
                                                                      this );

        //Release event handlers when closed
        addCloseHandler( new CloseHandler<PopupPanel>() {

            public void onClose( CloseEvent<PopupPanel> event ) {
                registration.removeHandler();
            }

        } );
        super.show();
    }
View Full Code Here

    if (callbackFunctionsByEvent.get(fbEventType) == null) {
      JSFunction callbackFunction = subscribeToEvent(fbEventType);
      callbackFunctionsByEvent.put(fbEventType, callbackFunction);
    }

    final HandlerRegistration handlerRegistration = eventBus.addHandler(eventType, handler);
    return new HandlerRegistration() {
      @Override
      public void removeHandler() {
        handlerRegistration.removeHandler();

        // defer in case the handler removal has been deferred
        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
          @Override
          public void execute() {
View Full Code Here

    getStorageEventHandlers().add(handler);
    if (storageEventHandlers.size() == 1) {
      addStorageEventHandler0();
    }

    return new HandlerRegistration() {
      @Override
      public void removeHandler() {
        removeStorageEventHandler(handler);
      }
    };
View Full Code Here

    * will NOT automatically resubscribe.
    */
   public <H extends EventHandler> void addHandler(
         HasAttachHandlers removeWhenDetached, Type<H> type, H handler)
   {
      final HandlerRegistration reg = addHandler(type, handler);
      removeWhenDetached.addAttachHandler(new Handler()
      {
         @Override
         public void onAttachOrDetach(AttachEvent event)
         {
            if (!event.isAttached())
               reg.removeHandler();
         }
      });
   }
View Full Code Here

   {
      // GWT doesn't understand paste events via BrowserEvents.Paste, so we need
      // to manually sink and register for the paste event.
      sinkEvents(Event.ONPASTE);
      pasteHandlers_.add(handler);
      return new HandlerRegistration()
      {
         @Override
         public void removeHandler()
         {
            pasteHandlers_.remove(handler);
View Full Code Here

     
      @Override
      public HandlerRegistration addListChangedHandler(
                                                ListChangedHandler handler)
      {
         HandlerRegistration hreg =  handlers_.addHandler(ListChangedEvent.TYPE,
                                                          handler);
   
         if (list_ != null)
            handler.onListChanged(new ListChangedEvent(name_, list_));
        
View Full Code Here

         defaultValue_ = defaultValue;
      }

      public HandlerRegistration bind(final CommandWithArg<T> handler)
      {
         HandlerRegistration reg = addValueChangeHandler(new ValueChangeHandler<T>()
         {
            public void onValueChange(ValueChangeEvent<T> e)
            {
               handler.execute(e.getValue());
            }
View Full Code Here

       * annoying). Doing it this way fixes it.
       */

      hasHandlers_.addHandler(ClickEvent.getType(), clickHandler);

      final HandlerRegistration mouseDown = addDomHandler(new MouseDownHandler()
      {
         public void onMouseDown(MouseDownEvent event)
         {
            event.preventDefault();
            event.stopPropagation();

            down_ = true;
         }
      }, MouseDownEvent.getType());

      final HandlerRegistration mouseOut = addDomHandler(new MouseOutHandler()
      {
         public void onMouseOut(MouseOutEvent event)
         {
            event.preventDefault();
            event.stopPropagation();

            down_ = false;
         }
      }, MouseOutEvent.getType());

      final HandlerRegistration mouseUp = addDomHandler(new MouseUpHandler()
      {
         public void onMouseUp(MouseUpEvent event)
         {
            event.preventDefault();
            event.stopPropagation();

            if (down_)
            {
               down_ = false;

               NativeEvent clickEvent = Document.get().createClickEvent(
                     1,
                     event.getScreenX(),
                     event.getScreenY(),
                     event.getClientX(),
                     event.getClientY(),
                     event.getNativeEvent().getCtrlKey(),
                     event.getNativeEvent().getAltKey(),
                     event.getNativeEvent().getShiftKey(),
                     event.getNativeEvent().getMetaKey());
               DomEvent.fireNativeEvent(clickEvent, hasHandlers_);
            }
         }
      }, MouseUpEvent.getType());

      return new HandlerRegistration()
      {
         public void removeHandler()
         {
            mouseDown.removeHandler();
            mouseOut.removeHandler();
            mouseUp.removeHandler();
         }
      };
   }
View Full Code Here

TOP

Related Classes of com.google.gwt.event.shared.HandlerRegistration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.