Search in sources :

Example 1 with NodeDragMoveHandler

use of com.ait.lienzo.client.core.event.NodeDragMoveHandler in project drools-wb by kiegroup.

the class RadarMenuViewImpl method setup.

@PostConstruct
public void setup() {
    radarCanvas.add(radarLayer);
    radarMenuDropdown.setTitle(translationService.getTranslation(GuidedDecisionTableErraiConstants.RowContextMenuViewImpl_Title));
    visibleBounds.setDraggable(true);
    visibleBounds.addNodeDragMoveHandler(new NodeDragMoveHandler() {

        @Override
        public void onNodeDragMove(final NodeDragMoveEvent event) {
            presenter.onDragVisibleBounds(visibleBounds.getX(), visibleBounds.getY());
        }
    });
    visibleBounds.setFillColor(ColorName.GRAY);
    visibleBounds.setAlpha(0.25);
    visibleBounds.setLocation(new Point2D((RADAR_WIDTH - visibleBounds.getWidth()) / 2, (RADAR_HEIGHT - visibleBounds.getHeight()) / 2));
    radarLayer.add(visibleBounds);
    radarCanvas.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (eventTargetsPopup(event.getNativeEvent(), radarMenu)) {
                event.stopPropagation();
                event.preventDefault();
            }
        }

        private boolean eventTargetsPopup(final NativeEvent event, final Element element) {
            final EventTarget target = event.getEventTarget();
            if (Element.is(target)) {
                return element.isOrHasChild(Element.as(target));
            }
            return false;
        }
    });
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Point2D(com.ait.lienzo.client.core.types.Point2D) NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ButtonElement(com.google.gwt.dom.client.ButtonElement) LIElement(com.google.gwt.dom.client.LIElement) Element(com.google.gwt.dom.client.Element) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) EventTarget(com.google.gwt.dom.client.EventTarget) NativeEvent(com.google.gwt.dom.client.NativeEvent) PostConstruct(javax.annotation.PostConstruct)

Example 2 with NodeDragMoveHandler

use of com.ait.lienzo.client.core.event.NodeDragMoveHandler in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenterTest method checkRegisteredNodeDragMoveHandler.

@Test
@SuppressWarnings("unchecked")
public void checkRegisteredNodeDragMoveHandler() {
    final ArgumentCaptor<NodeDragMoveHandler> nodeDragMoveHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeDragMoveHandler.class);
    // dtPresenter.setContent(...) is called by the base tests @Before method
    verify(view, times(1)).registerNodeDragMoveHandler(nodeDragMoveHandlerArgumentCaptor.capture());
    final NodeDragMoveHandler nodeDragMoveHandler = nodeDragMoveHandlerArgumentCaptor.getValue();
    assertNotNull(nodeDragMoveHandler);
    nodeDragMoveHandler.onNodeDragMove(mock(NodeDragMoveEvent.class));
    verify(modellerPresenter, times(1)).updateRadar();
}
Also used : NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) NodeDragMoveEvent(com.ait.lienzo.client.core.event.NodeDragMoveEvent) Test(org.junit.Test)

Example 3 with NodeDragMoveHandler

use of com.ait.lienzo.client.core.event.NodeDragMoveHandler in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenterTest method initialiseEventHandler.

@Test
@SuppressWarnings("unchecked")
public void initialiseEventHandler() {
    final ArgumentCaptor<NodeDragMoveHandler> nodeDragMoveHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeDragMoveHandler.class);
    final ArgumentCaptor<NodeMouseDoubleClickHandler> nodeMouseDoubleClickHandlerArgumentCaptor = ArgumentCaptor.forClass(NodeMouseDoubleClickHandler.class);
    // dtPresenter.setContent(...) is called by the base tests @Before method
    verify(view, times(1)).registerNodeDragMoveHandler(nodeDragMoveHandlerArgumentCaptor.capture());
    verify(view, times(1)).registerNodeMouseDoubleClickHandler(nodeMouseDoubleClickHandlerArgumentCaptor.capture());
    final NodeDragMoveHandler nodeDragMoveHandler = nodeDragMoveHandlerArgumentCaptor.getValue();
    final NodeMouseDoubleClickHandler nodeMouseDoubleClickHandler = nodeMouseDoubleClickHandlerArgumentCaptor.getValue();
    assertNotNull(nodeDragMoveHandler);
    assertNotNull(nodeMouseDoubleClickHandler);
}
Also used : NodeDragMoveHandler(com.ait.lienzo.client.core.event.NodeDragMoveHandler) NodeMouseDoubleClickHandler(com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler) Test(org.junit.Test)

Aggregations

NodeDragMoveHandler (com.ait.lienzo.client.core.event.NodeDragMoveHandler)3 NodeDragMoveEvent (com.ait.lienzo.client.core.event.NodeDragMoveEvent)2 Test (org.junit.Test)2 NodeMouseDoubleClickHandler (com.ait.lienzo.client.core.event.NodeMouseDoubleClickHandler)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 ButtonElement (com.google.gwt.dom.client.ButtonElement)1 Element (com.google.gwt.dom.client.Element)1 EventTarget (com.google.gwt.dom.client.EventTarget)1 LIElement (com.google.gwt.dom.client.LIElement)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 PostConstruct (javax.annotation.PostConstruct)1