use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class TestingGraphMockHandler method newViewNode.
public Node newViewNode(String uuid, Optional<Object> def, final double x, final double y, final double w, final double h) {
final Object definition = def.isPresent() ? def.get() : newDef("def-" + uuid, Optional.empty());
when(definitionUtils.buildBounds(eq(definition), anyDouble(), anyDouble())).thenReturn(new BoundsImpl(new BoundImpl(x, y), new BoundImpl(x + w, y + h)));
final Node<Definition<Object>, Edge> result = nodeFactory.build(uuid, definition);
execute(commandFactory.addNode(result));
when(graphIndex.getNode(eq(uuid))).thenReturn(result);
when(graphIndex.get(eq(uuid))).thenReturn(result);
return result;
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class LiteralExpressionGridTest method setup.
@Before
public void setup() {
tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
definition = new LiteralExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
expression = definition.getModelClass();
expression.ifPresent(e -> e.setText(EXPRESSION_TEXT));
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
when(parent.getGridWidget()).thenReturn(parentGridWidget);
when(parent.getRowIndex()).thenReturn(0);
when(parent.getColumnIndex()).thenReturn(1);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class BaseExpressionGrid method getUpdateStunnerTitleCommand.
protected Optional<AbstractCanvasGraphCommand> getUpdateStunnerTitleCommand(final String value) {
AbstractCanvasGraphCommand command = null;
if (nodeUUID.isPresent()) {
final String uuid = nodeUUID.get();
final AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler();
final Element<?> element = canvasHandler.getGraphIndex().get(uuid);
if (element.getContent() instanceof Definition) {
final Definition definition = (Definition) element.getContent();
final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition());
if (nameId != null) {
command = (AbstractCanvasGraphCommand) canvasCommandFactory.updatePropertyValue(element, nameId, value);
}
}
}
return Optional.ofNullable(command);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class AbstractDMNDiagramFactory method updateDefaultNameSpaces.
private void updateDefaultNameSpaces(final Node<Definition<DMNDiagram>, ?> diagramNode) {
final DMNDiagram dmnDiagram = (DMNDiagram) DefinitionUtils.getElementDefinition(diagramNode);
final Definitions dmnDefinitions = dmnDiagram.getDefinitions();
Stream.of(DMNModelInstrumentedBase.Namespace.values()).filter(namespace -> !dmnDefinitions.getNsContext().containsValue(namespace.getUri())).forEach(namespace -> {
if (!namespace.getPrefix().equalsIgnoreCase(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix())) {
dmnDefinitions.getNsContext().put(namespace.getPrefix(), namespace.getUri());
}
});
String defaultNamespace = !StringUtils.isEmpty(dmnDefinitions.getNamespace().getValue()) ? dmnDefinitions.getNamespace().getValue() : DMNModelInstrumentedBase.Namespace.DEFAULT.getUri() + UUID.uuid();
dmnDefinitions.setNamespace(new Text(defaultNamespace));
dmnDefinitions.getNsContext().putIfAbsent(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix(), defaultNamespace);
}
use of org.kie.workbench.common.stunner.core.graph.content.definition.Definition in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionTest method createNodeWithContentDefinitionId.
private Node createNodeWithContentDefinitionId(final String contentDefinitionId) {
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final DRGElement drgElement = mock(DRGElement.class);
when(drgElement.getContentDefinitionId()).thenReturn(contentDefinitionId);
when(definition.getDefinition()).thenReturn(drgElement);
when(node.getContent()).thenReturn(definition);
return node;
}
Aggregations