Search in sources :

Example 26 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 27 with HandlerRegistration

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

the class ViewEventHandlerManager method registerDoubleClickHandler.

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

Example 28 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 29 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)

Example 30 with HandlerRegistration

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

the class WiresShapeViewExt method registerDragHandler.

private HandlerRegistration[] registerDragHandler(final ViewHandler<DragEvent> eventHandler) {
    if (!getAttachableShape().isDraggable()) {
        final DragHandler dragHandler = (DragHandler) eventHandler;
        setDragEnabled(true);
        HandlerRegistration dragStartReg = addWiresDragStartHandler(wiresDragStartEvent -> {
            final DragEvent e = buildDragEvent(wiresDragStartEvent);
            dragHandler.start(e);
        });
        HandlerRegistration dragMoveReg = addWiresDragMoveHandler(wiresDragMoveEvent -> {
            final DragEvent e = buildDragEvent(wiresDragMoveEvent);
            dragHandler.handle(e);
        });
        HandlerRegistration dragEndReg = addWiresDragEndHandler(wiresDragEndEvent -> {
            final DragEvent e = buildDragEvent(wiresDragEndEvent);
            dragHandler.end(e);
        });
        return new HandlerRegistration[] { dragStartReg, dragMoveReg, dragEndReg };
    }
    return null;
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) DragEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.DragEvent) AbstractWiresDragEvent(com.ait.lienzo.client.core.shape.wires.event.AbstractWiresDragEvent) DragHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.DragHandler)

Aggregations

HandlerRegistration (com.google.gwt.event.shared.HandlerRegistration)48 Test (org.junit.Test)7 MouseEvent (com.google.gwt.event.dom.client.MouseEvent)4 ViewEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.ViewEvent)4 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 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 Attribute (com.ait.lienzo.client.core.Attribute)1 AbstractNodeGestureEvent (com.ait.lienzo.client.core.event.AbstractNodeGestureEvent)1 NodeGestureChangeEvent (com.ait.lienzo.client.core.event.NodeGestureChangeEvent)1 NodeGestureChangeHandler (com.ait.lienzo.client.core.event.NodeGestureChangeHandler)1