use of org.kie.workbench.common.stunner.core.graph.processing.index.Index in project kie-wb-common by kiegroup.
the class GenerateSelectedFormsSessionCommand method call.
private void call(final FormGenerationService service) {
final AbstractCanvasHandler canvasHandler = getCanvasHandler();
final Index index = canvasHandler.getGraphIndex();
final String[] selectedItems = getSelectedItems().stream().map(index::get).filter(acceptor).map(Element::getUUID).toArray(String[]::new);
if (selectedItems.length > 0) {
service.generateSelectedForms(getCanvasHandler().getDiagram(), selectedItems);
} else {
formGenerationNotifier.showNotification(translationService.getValue(FormsClientConstants.FormsNoItemsSelectedForGeneration));
}
}
use of org.kie.workbench.common.stunner.core.graph.processing.index.Index in project kie-wb-common by kiegroup.
the class BaseCanvasHandlerTest method getElementAtWhenCanvasDoesNotHaveShapeAtPosition.
@Test
@SuppressWarnings("unchecked")
public void getElementAtWhenCanvasDoesNotHaveShapeAtPosition() {
final Optional<Shape> oShape = Optional.empty();
final Index index = mock(Index.class);
when(canvas.getShapeAt(anyDouble(), anyDouble())).thenReturn(oShape);
when(commandExecutionContext.getGraphIndex()).thenReturn(index);
final Optional<Element> oElement = tested.getElementAt(0.0, 0.0);
assertFalse(oElement.isPresent());
}
use of org.kie.workbench.common.stunner.core.graph.processing.index.Index in project kie-wb-common by kiegroup.
the class BaseCanvasHandlerTest method getElementAtWhenCanvasHasShapeAtPosition.
@Test
@SuppressWarnings("unchecked")
public void getElementAtWhenCanvasHasShapeAtPosition() {
final Optional<Shape> oShape = Optional.of(mock(Shape.class));
final Index index = mock(Index.class);
final Node n = mock(Node.class);
when(canvas.getShapeAt(anyDouble(), anyDouble())).thenReturn(oShape);
when(commandExecutionContext.getGraphIndex()).thenReturn(index);
when(index.getNode(anyString())).thenReturn(n);
final Optional<Element> oElement = tested.getElementAt(0.0, 0.0);
assertTrue(oElement.isPresent());
}
Aggregations