Search in sources :

Example 51 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 52 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)

Example 53 with HandlerRegistration

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

the class WiresShapeViewExt method registerResizeHandler.

private HandlerRegistration[] registerResizeHandler(final ViewHandler<ResizeEvent> eventHandler) {
    final ResizeHandler resizeHandler = (ResizeHandler) eventHandler;
    setResizable(true);
    HandlerRegistration r0 = addWiresResizeStartHandler(wiresResizeStartEvent -> {
        final ResizeEvent event = buildResizeEvent(wiresResizeStartEvent);
        resizeHandler.start(event);
    });
    HandlerRegistration r1 = addWiresResizeStepHandler(wiresResizeStepEvent -> {
        final ResizeEvent event = buildResizeEvent(wiresResizeStepEvent);
        resizeHandler.handle(event);
        rebuildTextBoundaries(event.getWidth(), event.getHeight());
    });
    HandlerRegistration r2 = addWiresResizeEndHandler(wiresResizeEndEvent -> {
        final ResizeEvent event = buildResizeEvent(wiresResizeEndEvent);
        resizeHandler.end(event);
    });
    return new HandlerRegistration[] { r0, r1, r2 };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ResizeHandler(org.kie.workbench.common.stunner.core.client.shape.view.event.ResizeHandler) AbstractWiresResizeEvent(com.ait.lienzo.client.core.shape.wires.event.AbstractWiresResizeEvent) ResizeEvent(org.kie.workbench.common.stunner.core.client.shape.view.event.ResizeEvent)

Example 54 with HandlerRegistration

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

the class CustomGroupItemTest method setup.

@Before
public void setup() throws Exception {
    styles.clear();
    text.clear();
    clickHandler = null;
    customGroupItem = new CustomGroupItem("item", IconType.ADJUST, command) {

        public void addStyleName(final String style) {
            styles.add(style);
        }

        public void removeStyleName(final String style) {
            styles.remove(style);
        }

        public String getStyleName() {
            return styles.toString();
        }

        public void setText(final String value) {
            text.add(value);
        }

        public String getText() {
            return text.get(0);
        }

        public IconType getIcon() {
            return icon.get(0);
        }

        public void setIcon(IconType icontype) {
            icon.add(icontype);
        }

        public HandlerRegistration addClickHandler(final ClickHandler handler) {
            clickHandler = handler;
            return new HandlerRegistration() {

                @Override
                public void removeHandler() {
                }
            };
        }
    };
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) IconType(org.gwtbootstrap3.client.ui.constants.IconType) Before(org.junit.Before)

Example 55 with HandlerRegistration

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

the class AnalyzerControllerImplTest method areHandlersTornDownOnTerminate.

@Test
public void areHandlersTornDownOnTerminate() throws Exception {
    final HandlerRegistration validateEvent = mock(HandlerRegistration.class);
    when(eventBus.addHandler(ValidateEvent.TYPE, controller)).thenReturn(validateEvent);
    final HandlerRegistration deleteRowEvent = mock(HandlerRegistration.class);
    when(eventBus.addHandler(DeleteRowEvent.TYPE, controller)).thenReturn(deleteRowEvent);
    final HandlerRegistration afterColumnDeleted = mock(HandlerRegistration.class);
    when(eventBus.addHandler(AfterColumnDeleted.TYPE, controller)).thenReturn(afterColumnDeleted);
    final HandlerRegistration updateColumnDataEvent = mock(HandlerRegistration.class);
    when(eventBus.addHandler(UpdateColumnDataEvent.TYPE, controller)).thenReturn(updateColumnDataEvent);
    final HandlerRegistration appendRowEvent = mock(HandlerRegistration.class);
    when(eventBus.addHandler(AppendRowEvent.TYPE, controller)).thenReturn(appendRowEvent);
    final HandlerRegistration insertRowEvent = mock(HandlerRegistration.class);
    when(eventBus.addHandler(InsertRowEvent.TYPE, controller)).thenReturn(insertRowEvent);
    final HandlerRegistration afterColumnInserted = mock(HandlerRegistration.class);
    when(eventBus.addHandler(AfterColumnInserted.TYPE, controller)).thenReturn(afterColumnInserted);
    controller.initialiseAnalysis();
    controller.terminateAnalysis();
    verify(validateEvent).removeHandler();
    verify(deleteRowEvent).removeHandler();
    verify(afterColumnDeleted).removeHandler();
    verify(updateColumnDataEvent).removeHandler();
    verify(appendRowEvent).removeHandler();
    verify(insertRowEvent).removeHandler();
    verify(afterColumnDeleted).removeHandler();
}
Also used : HandlerRegistration(com.google.gwt.event.shared.HandlerRegistration) Test(org.junit.Test)

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