Search in sources :

Example 6 with DragProxyCallback

use of org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback in project kie-wb-common by kiegroup.

the class ShapeGlyphDragHandlerImplTest method testShow.

@Test
public void testShow() throws Exception {
    CountDownLatch latch = new CountDownLatch(1);
    DragProxyCallback callback = mock(DragProxyCallback.class);
    shapeGlyphDragHandler.show(item, 0, 0, callback);
    // asserting handlers registrations
    assertEquals(shapeGlyphDragHandler.handlerRegistrations.size(), 2);
    // delay timeout to add MouseUp handler
    latch.await(201, TimeUnit.MILLISECONDS);
    assertEquals(shapeGlyphDragHandler.handlerRegistrations.size(), 2);
    assertNotNull(shapeGlyphDragHandler.dragProxyPanel);
    verify(glyphLienzoGlyphRenderer).render(item.getShape(), item.getWidth(), item.getHeight());
}
Also used : DragProxyCallback(org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 7 with DragProxyCallback

use of org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback in project kie-wb-common by kiegroup.

the class ShapeViewDragProxyImpl method show.

@Override
public DragProxy<AbstractCanvas, ShapeView<?>, DragProxyCallback> show(final ShapeView<?> item, final int x, final int y, final DragProxyCallback callback) {
    final AbstractDragProxy.Callback c = new AbstractDragProxy.Callback() {

        @Override
        public void onStart(final int x, final int y) {
            callback.onStart(x, y);
        }

        @Override
        public void onMove(final int x, final int y) {
            callback.onMove(x, y);
        }

        @Override
        public void onComplete(final int x, final int y) {
            callback.onComplete(x, y);
        }
    };
    if (item instanceof WiresShape) {
        final WiresShape wiresShape = (WiresShape) item;
        this.proxy = new WiresShapeDragProxy(getLayer().getLienzoLayer(), wiresShape, x, y, 100, c);
    } else if (item instanceof WiresConnector) {
        final WiresConnector wiresConnector = (WiresConnector) item;
        this.proxy = new WiresConnectorDragProxy(getLayer().getLienzoLayer(), wiresConnector, x, y, 100, c);
    }
    return this;
}
Also used : AbstractDragProxy(org.kie.workbench.common.stunner.lienzo.primitive.AbstractDragProxy) WiresShape(com.ait.lienzo.client.core.shape.wires.WiresShape) WiresConnector(com.ait.lienzo.client.core.shape.wires.WiresConnector) DragProxyCallback(org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback) WiresConnectorDragProxy(org.kie.workbench.common.stunner.lienzo.primitive.WiresConnectorDragProxy) WiresShapeDragProxy(org.kie.workbench.common.stunner.lienzo.primitive.WiresShapeDragProxy)

Example 8 with DragProxyCallback

use of org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback in project kie-wb-common by kiegroup.

the class BS3PaletteWidgetViewImpl method showDragProxy.

@Override
public void showDragProxy(String itemId, double x, double y, double width, double height) {
    final Glyph glyph = presenter.getShapeGlyph(itemId);
    itemDragProxy = shapeGlyphDragHandler.show(new ShapeGlyphDragHandler.Item() {

        @Override
        public Glyph getShape() {
            return glyph;
        }

        @Override
        public int getWidth() {
            return (int) width;
        }

        @Override
        public int getHeight() {
            return (int) height;
        }
    }, (int) x, (int) y, new DragProxyCallback() {

        @Override
        public void onStart(int x, int y) {
            presenter.onDragStart(itemId, x, y);
        }

        @Override
        public void onMove(int x, int y) {
            presenter.onDragProxyMove(itemId, (double) x, (double) y);
        }

        @Override
        public void onComplete(int x, int y) {
            presenter.onDragProxyComplete(itemId, (double) x, (double) y);
        }
    });
}
Also used : Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) DragProxyCallback(org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback)

Aggregations

DragProxyCallback (org.kie.workbench.common.stunner.core.client.components.drag.DragProxyCallback)8 Test (org.junit.Test)3 ShapeFactory (org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory)2 Edge (org.kie.workbench.common.stunner.core.graph.Edge)2 Node (org.kie.workbench.common.stunner.core.graph.Node)2 MultiPath (com.ait.lienzo.client.core.shape.MultiPath)1 WiresConnector (com.ait.lienzo.client.core.shape.wires.WiresConnector)1 WiresShape (com.ait.lienzo.client.core.shape.wires.WiresShape)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 WiresConnectorView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresConnectorView)1 WiresShapeView (org.kie.workbench.common.stunner.client.lienzo.shape.view.wires.WiresShapeView)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 RequiresCommandManager (org.kie.workbench.common.stunner.core.client.command.RequiresCommandManager)1 ConnectorDragProxy (org.kie.workbench.common.stunner.core.client.components.drag.ConnectorDragProxy)1 EdgeShape (org.kie.workbench.common.stunner.core.client.shape.EdgeShape)1 MouseClickEvent (org.kie.workbench.common.stunner.core.client.shape.view.event.MouseClickEvent)1 Glyph (org.kie.workbench.common.stunner.core.definition.shape.Glyph)1 MagnetConnection (org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1 AbstractDragProxy (org.kie.workbench.common.stunner.lienzo.primitive.AbstractDragProxy)1