Search in sources :

Example 46 with HandlerRegistration

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

the class ViewEventHandlerManager method registerExitHandler.

protected HandlerRegistration[] registerExitHandler(final ViewHandler<ViewEvent> eventHandler) {
    return new HandlerRegistration[] { shape.addNodeMouseExitHandler(e -> {
        if (isEnabled()) {
            final MouseExitEvent event = new MouseExitEvent(e.getX(), e.getY(), e.getMouseEvent().getClientX(), e.getMouseEvent().getClientY());
            event.setShiftKeyDown(e.isShiftKeyDown());
            event.setAltKeyDown(e.isAltKeyDown());
            event.setMetaKeyDown(e.isMetaKeyDown());
            eventHandler.handle(event);
        }
    }) };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) MouseExitEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseExitEvent)

Example 47 with HandlerRegistration

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

the class ViewEventHandlerManager method registerTextDoubleClickHandler.

protected HandlerRegistration[] registerTextDoubleClickHandler(final ViewHandler<ViewEvent> eventHandler) {
    return new HandlerRegistration[] { node.addNodeMouseDoubleClickHandler(nodeMouseDoubleClickEvent -> {
        if (isEnabled()) {
            skipClickHandler();
            final TextDoubleClickEvent event = new TextDoubleClickEvent(nodeMouseDoubleClickEvent.getX(), nodeMouseDoubleClickEvent.getY(), nodeMouseDoubleClickEvent.getMouseEvent().getClientX(), nodeMouseDoubleClickEvent.getMouseEvent().getClientY());
            event.setShiftKeyDown(nodeMouseDoubleClickEvent.isShiftKeyDown());
            event.setAltKeyDown(nodeMouseDoubleClickEvent.isAltKeyDown());
            event.setMetaKeyDown(nodeMouseDoubleClickEvent.isMetaKeyDown());
            eventHandler.handle(event);
            restoreClickHandler();
        }
    }) };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) TextDoubleClickEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.TextDoubleClickEvent)

Example 48 with HandlerRegistration

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

the class ViewEventHandlerManager method registerGestureHandler.

protected HandlerRegistration[] registerGestureHandler(final GestureHandler gestureHandler) {
    HandlerRegistration gestureStartReg = node.addNodeGestureStartHandler(new NodeGestureStartHandler() {

        @Override
        public void onNodeGestureStart(final NodeGestureStartEvent event) {
            if (isEnabled()) {
                final GestureEvent event1 = buildGestureEvent(event);
                if (null != event1) {
                    gestureHandler.start(event1);
                }
            }
        }
    });
    HandlerRegistration gestureChangeReg = node.addNodeGestureChangeHandler(new NodeGestureChangeHandler() {

        @Override
        public void onNodeGestureChange(final NodeGestureChangeEvent event) {
            if (isEnabled()) {
                final GestureEvent event1 = buildGestureEvent(event);
                if (null != event1) {
                    gestureHandler.change(event1);
                }
            }
        }
    });
    HandlerRegistration gestureEndReg = node.addNodeGestureEndHandler(new NodeGestureEndHandler() {

        @Override
        public void onNodeGestureEnd(final NodeGestureEndEvent event) {
            if (isEnabled()) {
                final GestureEvent event1 = buildGestureEvent(event);
                if (null != event1) {
                    gestureHandler.end(event1);
                }
            }
        }
    });
    return new HandlerRegistration[] { gestureStartReg, gestureChangeReg, gestureEndReg };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) NodeGestureStartHandler(com.ait.lienzo.client.core.event.NodeGestureStartHandler) NodeGestureEndHandler(com.ait.lienzo.client.core.event.NodeGestureEndHandler) NodeGestureChangeEvent(com.ait.lienzo.client.core.event.NodeGestureChangeEvent) NodeGestureStartEvent(com.ait.lienzo.client.core.event.NodeGestureStartEvent) GestureEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.GestureEvent) AbstractNodeGestureEvent(com.ait.lienzo.client.core.event.AbstractNodeGestureEvent) NodeGestureEndEvent(com.ait.lienzo.client.core.event.NodeGestureEndEvent) NodeGestureChangeHandler(com.ait.lienzo.client.core.event.NodeGestureChangeHandler)

Example 49 with HandlerRegistration

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

the class ViewEventHandlerManager method removeHandler.

@SuppressWarnings("unchecked")
public void removeHandler(final ViewHandler<? extends ViewEvent> eventHandler) {
    final ViewEventType type = eventHandler.getType();
    if (registrationMap.containsKey(type)) {
        final HandlerRegistration[] registrations = registrationMap.get(type);
        if (null != registrations && registrations.length > 0) {
            for (final HandlerRegistration registration : registrations) {
                registrationManager.deregister(registration);
            }
        }
        registrationMap.remove(type);
    }
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ViewEventType(org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEventType)

Example 50 with HandlerRegistration

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

the class ViewEventHandlerManager method registerEnterHandler.

protected HandlerRegistration[] registerEnterHandler(final ViewHandler<ViewEvent> eventHandler) {
    return new HandlerRegistration[] { shape.addNodeMouseEnterHandler(e -> {
        if (isEnabled()) {
            final MouseEnterEvent event = new MouseEnterEvent(e.getX(), e.getY(), e.getMouseEvent().getClientX(), e.getMouseEvent().getClientY());
            event.setShiftKeyDown(e.isShiftKeyDown());
            event.setAltKeyDown(e.isAltKeyDown());
            event.setMetaKeyDown(e.isMetaKeyDown());
            eventHandler.handle(event);
        }
    }) };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) MouseEnterEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.MouseEnterEvent)

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