Search in sources :

Example 1 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project rstudio by rstudio.

the class AceEditorBackgroundLinkHighlighter method onAttachOrDetach.

// Event Handlers ---
@Override
public void onAttachOrDetach(AttachEvent event) {
    if (event.isAttached()) {
        previewHandler_ = Event.addNativePreviewHandler(new NativePreviewHandler() {

            @Override
            public void onPreviewNativeEvent(NativePreviewEvent preview) {
                int type = preview.getTypeInt();
                if (type == Event.ONKEYDOWN) {
                    int modifier = KeyboardShortcut.getModifierValue(preview.getNativeEvent());
                    beginDetectClickTarget(mouseTracker_.getLastMouseX(), mouseTracker_.getLastMouseY(), modifier);
                } else if (type == Event.ONKEYUP) {
                    endDetectClickTarget();
                }
            }
        });
    } else {
        for (HandlerRegistration handler : handlers_) handler.removeHandler();
        handlers_.clear();
        if (previewHandler_ != null) {
            previewHandler_.removeHandler();
            previewHandler_ = null;
        }
    }
}
Also used : NativePreviewHandler(com.google.gwt.user.client.Event.NativePreviewHandler) HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) NativePreviewEvent(com.google.gwt.user.client.Event.NativePreviewEvent)

Example 2 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project rstudio by rstudio.

the class EventBus method addHandler.

/**
    * Similar to 2-arg form of addHandler, but automatically removes handler
    * when the HasAttachHandlers object detaches.
    *
    * If the HasAttachHandlers object detaches and reattaches, the handler
    * 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();
        }
    });
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) AttachEvent(com.google.gwt.event.logical.shared.AttachEvent) EventHandler(com.google.gwt.event.shared.EventHandler) Handler(com.google.gwt.event.logical.shared.AttachEvent.Handler)

Example 3 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project opennms by OpenNMS.

the class LocationPanel method setEventBus.

/**
 * <p>setEventBus</p>
 *
 * @param eventBus a {@link com.google.gwt.event.shared.HandlerManager} object.
 */
public void setEventBus(final HandlerManager eventBus) {
    // Remove any existing handler registrations
    for (HandlerRegistration registration : eventRegistrations) {
        registration.removeHandler();
    }
    m_eventBus = eventBus;
    m_eventBus.addHandler(TagResizeEvent.TYPE, this);
    filterPanel.setEventBus(eventBus);
    tagPanel.setEventBus(eventBus);
    applicationList.setEventBus(eventBus);
// eventRegistrations.add(m_eventBus.addHandler(MapPanelBoundsChangedEvent.TYPE, this));
// eventRegistrations.add(m_eventBus.addHandler(LocationsUpdatedEvent.TYPE, this));
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration)

Example 4 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project kie-wb-common by kiegroup.

the class AbstractGroupItem method registerMouseEnterHandler.

protected HandlerRegistration registerMouseEnterHandler(final NodeMouseEnterHandler handler) {
    assert null != handler;
    HandlerRegistration reg = getPrimitive().setListening(true).addNodeMouseEnterHandler(handler);
    register(reg);
    return reg;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration)

Example 5 with HandlerRegistration

use of com.google.gwt.event.shared.HandlerRegistration in project activityinfo by bedatadriven.

the class FilterPanelSet method ensureHandlers.

private HandlerManager ensureHandlers() {
    if (manager == null) {
        manager = new HandlerManager(this);
        myRegistrations = new ArrayList<HandlerRegistration>();
        for (FilterPanel panel : panels) {
            HandlerRegistration registration = panel.addValueChangeHandler(new ValueChangeHandler<Filter>() {

                @Override
                public void onValueChange(ValueChangeEvent<Filter> event) {
                    // or indicator (reports) is selected
                    if (event.getSource() instanceof ActivityFilterPanel || event.getSource() instanceof IndicatorFilterPanel) {
                        clearAttributeAndPartnerFilters();
                    }
                    Filter value = composeFilter(new Filter(), null);
                    Log.debug("FilterPanelSet: Filter changed = " + value);
                    ValueChangeEvent.fire(FilterPanelSet.this, value);
                }
            });
            myRegistrations.add(registration);
        }
    }
    return manager;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ActivityFilterPanel(org.activityinfo.ui.client.page.entry.ActivityFilterPanel) Filter(org.activityinfo.legacy.shared.command.Filter) HandlerManager(com.google.gwt.event.shared.HandlerManager) ActivityFilterPanel(org.activityinfo.ui.client.page.entry.ActivityFilterPanel)

Aggregations

HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)57 Test (org.junit.Test)13 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)5 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)5 TextDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent)3 NodeMouseDoubleClickEvent (com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent)2 NodeMouseDoubleClickHandler (com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler)2 NodeMouseEnterEvent (com.ait.lienzo.client.core.event.NodeMouseEnterEvent)2 NodeMouseEnterHandler (com.ait.lienzo.client.core.event.NodeMouseEnterHandler)2 NodeMouseExitEvent (com.ait.lienzo.client.core.event.NodeMouseExitEvent)2 NodeMouseExitHandler (com.ait.lienzo.client.core.event.NodeMouseExitHandler)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 HandlerManager (com.google.gwt.event.shared.HandlerManager)2 Widget (com.google.gwt.user.client.ui.Widget)2 Map (java.util.Map)2 MouseDoubleClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseDoubleClickEvent)2 MouseEnterEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent)2 CommandWithArg (org.rstudio.core.client.CommandWithArg)2 Mutable (org.rstudio.core.client.Mutable)2