use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent in project kie-wb-common by kiegroup.
the class MorphNodeActionTest method testAction.
@Test
public void testAction() {
final MouseClickEvent event = mock(MouseClickEvent.class);
ToolboxAction<AbstractCanvasHandler> cascade = tested.onMouseClick(canvasHandler, E_UUID, event);
assertEquals(tested, cascade);
verify(commandFactory, times(1)).morphNode(eq(element), eq(morphDefinition), eq(MORPH_TARGET_ID), eq(SSID_UUID));
verify(sessionCommandManager, times(1)).execute(eq(canvasHandler), eq(morphNodeCommand));
final ArgumentCaptor<CanvasSelectionEvent> eventArgumentCaptor = ArgumentCaptor.forClass(CanvasSelectionEvent.class);
verify(canvasElementSelectedEvent, times(1)).fire(eventArgumentCaptor.capture());
final CanvasSelectionEvent eCaptured = eventArgumentCaptor.getValue();
assertEquals(E_UUID, eCaptured.getIdentifiers().iterator().next());
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent in project kie-wb-common by kiegroup.
the class BaseSessionCommandKeyboardSelectionAwareTest method testHandleCanvasSelectionEventWhenCanvasRootIsSelected.
@Test
public void testHandleCanvasSelectionEventWhenCanvasRootIsSelected() {
command.bind(session);
List<String> selectedIds = new ArrayList<>();
selectedIds.add(CANVAS_ROOT_ID);
CanvasSelectionEvent selectionEvent = new CanvasSelectionEvent(canvasHandler, selectedIds);
((AbstractSelectionAwareSessionCommand) command).handleCanvasSelectionEvent(selectionEvent);
assertFalse(command.isEnabled());
verify(statusCallback, times(1)).execute();
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent in project kie-wb-common by kiegroup.
the class BaseSessionCommandKeyboardSelectionAwareTest method testHandleCanvasSelectionEventWhenElementsAreSelected.
@Test
public void testHandleCanvasSelectionEventWhenElementsAreSelected() {
command.bind(session);
List<String> selectedIds = new ArrayList<>();
selectedIds.add("id1");
selectedIds.add("id2");
CanvasSelectionEvent selectionEvent = new CanvasSelectionEvent(canvasHandler, selectedIds);
((AbstractSelectionAwareSessionCommand) command).handleCanvasSelectionEvent(selectionEvent);
assertTrue(command.isEnabled());
verify(statusCallback, times(1)).execute();
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent in project kie-wb-common by kiegroup.
the class MapSelectionControl method enable.
@Override
public void enable(final H canvasHandler) {
super.enable(canvasHandler);
final Layer layer = canvasHandler.getCanvas().getLayer();
// Click handler for the canvas area - cleans current selection, if any.
final MouseClickHandler clickHandler = new MouseClickHandler() {
@Override
public void handle(final MouseClickEvent event) {
if (event.isButtonLeft() || event.isButtonRight()) {
clearSelection(false);
final String canvasRootUUID = getRootUUID();
fireCanvasClear();
if (null != canvasRootUUID) {
selectionEventConsumer.accept(new CanvasSelectionEvent(canvasHandler, canvasRootUUID));
}
}
}
};
layer.addHandler(ViewEventType.MOUSE_CLICK, clickHandler);
this.layerClickHandler = clickHandler;
}
use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent in project kie-wb-common by kiegroup.
the class ControlPointControlImplTest method setUp.
@Before
public void setUp() {
super.setUp();
initialControlPointPosition = new Point2D(0, 0);
newControlPointPosition = new Point2D(10, 10);
controlPoint1 = new ControlPointImpl(initialControlPointPosition);
canvasSelectionEvent = new CanvasSelectionEvent(canvasHandler, EDGE_UUID);
canvasControlPointDragStartEvent = new CanvasControlPointDragStartEvent(initialControlPointPosition);
canvasControlPointDragEndEvent = new CanvasControlPointDragEndEvent(newControlPointPosition);
canvasControlPointDoubleClickEvent = new CanvasControlPointDoubleClickEvent(initialControlPointPosition);
controlPointControl = spy(new ControlPointControlImpl(canvasCommandFactory));
when(canvas.getShape(EDGE_UUID)).thenReturn(connectorShape);
when(graphIndex.get(EDGE_UUID)).thenReturn(edge);
when(graphIndex.getEdge(EDGE_UUID)).thenReturn(edge);
when(edge.getContent()).thenReturn(viewConnector);
when(edge.getUUID()).thenReturn(EDGE_UUID);
when(connectorShape.getShapeView()).thenReturn(shapeView);
when(viewConnector.getControlPoints()).thenReturn(Arrays.asList(controlPoint1));
controlPointControl.enable(canvasHandler);
controlPointControl.setCommandManagerProvider(() -> commandManager);
controlPointControl.register(edge);
}
Aggregations