Search in sources :

Example 1 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class DecisionComponentsItemViewTest method testDecisionComponentItemMouseDown.

@Test
public void testDecisionComponentItemMouseDown() {
    final MouseDownEvent mouseDownEvent = mock(MouseDownEvent.class);
    final Callback proxy = mock(Callback.class);
    final DRGElement drgElement = mock(DRGElement.class);
    final DMNShapeFactory factory = mock(DMNShapeFactory.class);
    final ShapeGlyphDragHandler.Item item = mock(ShapeGlyphDragHandler.Item.class);
    final Glyph glyph = mock(Glyph.class);
    final int x = 10;
    final int y = 20;
    when(dmnShapeSet.getShapeFactory()).thenReturn(factory);
    when(presenter.getDrgElement()).thenReturn(drgElement);
    when(factory.getGlyph(any())).thenReturn(glyph);
    when(mouseDownEvent.getX()).thenReturn(x);
    when(mouseDownEvent.getY()).thenReturn(y);
    doReturn(proxy).when(view).makeDragProxyCallbackImpl(drgElement, factory);
    doReturn(item).when(view).makeDragHandler(glyph);
    view.decisionComponentItemMouseDown(mouseDownEvent);
    verify(shapeGlyphDragHandler).show(item, x, y, proxy);
}
Also used : Item(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Item) Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) DMNShapeFactory(org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ShapeGlyphDragHandler(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler) MouseDownEvent(com.google.gwt.event.dom.client.MouseDownEvent) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Example 2 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class DecisionComponentsItemView method decisionComponentItemMouseDown.

@EventHandler("decision-component-item")
public void decisionComponentItemMouseDown(final MouseDownEvent mouseDownEvent) {
    final DRGElement drgElement = presenter.getDrgElement();
    final ShapeFactory factory = dmnShapeSet.getShapeFactory();
    final Glyph glyph = factory.getGlyph(drgElement.getClass().getName());
    final ShapeGlyphDragHandler.Item item = makeDragHandler(glyph);
    final Callback proxy = makeDragProxyCallbackImpl(drgElement, factory);
    shapeGlyphDragHandler.show(item, mouseDownEvent.getX(), mouseDownEvent.getY(), proxy);
}
Also used : Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) ShapeGlyphDragHandler(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) EventHandler(org.jboss.errai.ui.shared.api.annotations.EventHandler)

Example 3 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class ShapeGlyphDragHandlerTest method testClear.

@Test
public void testClear() throws Exception {
    Callback callback = mock(Callback.class);
    tested.show(glyphDragItem, 11, 33, callback);
    tested.clear();
    verify(proxyPanel, times(1)).clear();
    verify(proxyPanel, never()).destroy();
    verify(moveHandlerReg, times(1)).removeHandler();
    verify(upHandlerReg, times(1)).removeHandler();
    verify(rootPanel, times(1)).remove(eq(proxyPanel));
    assertTrue(handlerRegistrations.isEmpty());
}
Also used : Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) Test(org.junit.Test)

Example 4 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class ShapeGlyphDragHandlerTest method testKeyboardHandling.

@Test
public void testKeyboardHandling() throws Exception {
    Callback callback = mock(Callback.class);
    tested.show(glyphDragItem, 11, 33, callback);
    assertEquals(keyHandlerReg, handlerRegistrations.get(2));
    KeyDownEvent event = mock(KeyDownEvent.class);
    tested.onKeyDown(event);
    verify(moveHandlerReg, times(1)).removeHandler();
    verify(upHandlerReg, times(1)).removeHandler();
    verify(rootPanel, times(1)).remove(eq(proxyPanel));
    assertTrue(handlerRegistrations.isEmpty());
}
Also used : Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) Test(org.junit.Test)

Example 5 with Callback

use of org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback in project kie-wb-common by kiegroup.

the class BS3PaletteWidgetViewImplTest method testShowDragProxy.

@Test
@SuppressWarnings("unchecked")
public void testShowDragProxy() {
    view.showDragProxy(ITEM_ID, X, Y, WIDTH, HEIGHT);
    verify(presenter).getShapeDragProxyGlyph(ITEM_ID);
    verify(shapeGlyphDragHandler).show(dragItemCaptor.capture(), eq((int) X), eq((int) Y), dragProxyCallbackCaptor.capture());
    final Item dragItem = dragItemCaptor.getValue();
    assertEquals(glyph, dragItem.getShape());
    assertEquals(WIDTH, dragItem.getWidth(), 0.0);
    assertEquals(HEIGHT, dragItem.getHeight(), 0.0);
    final Callback dragProxyCallback = dragProxyCallbackCaptor.getValue();
    dragProxyCallback.onStart((int) X, (int) Y);
    verify(presenter).onDragStart(ITEM_ID, (int) X, (int) Y);
    dragProxyCallback.onMove((int) X, (int) Y);
    verify(presenter).onDragProxyMove(ITEM_ID, (int) X, (int) Y);
    dragProxyCallback.onComplete((int) X, (int) Y);
    verify(presenter).onDragProxyComplete(ITEM_ID, (int) X, (int) Y);
}
Also used : Item(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Item) Callback(org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback) Test(org.junit.Test)

Aggregations

Callback (org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Callback)7 Test (org.junit.Test)6 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)2 ShapeGlyphDragHandler (org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler)2 Item (org.kie.workbench.common.stunner.client.lienzo.components.glyph.ShapeGlyphDragHandler.Item)2 Glyph (org.kie.workbench.common.stunner.core.definition.shape.Glyph)2 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 MouseDownEvent (com.google.gwt.event.dom.client.MouseDownEvent)1 MouseMoveEvent (com.google.gwt.event.dom.client.MouseMoveEvent)1 MouseUpEvent (com.google.gwt.event.dom.client.MouseUpEvent)1 EventHandler (org.jboss.errai.ui.shared.api.annotations.EventHandler)1 DMNShapeFactory (org.kie.workbench.common.dmn.client.shape.factory.DMNShapeFactory)1 ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)1