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);
}
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);
}
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());
}
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());
}
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);
}
Aggregations