use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerBase method asNodeMap.
@SuppressWarnings("unchecked")
private Map<String, Node<View, ?>> asNodeMap(Iterable nodes) {
Map<String, Node<View, ?>> oldNodes = new HashMap<>();
nodes.forEach(n -> {
Node n1 = (Node) n;
oldNodes.put(n1.getUUID(), n1);
});
return oldNodes;
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class CaseManagementUtilsTest method checkGetFirstDiagramNodeWithNonEmptyGraph.
@Test
@SuppressWarnings("unchecked")
public void checkGetFirstDiagramNodeWithNonEmptyGraph() {
final Graph graph = new GraphImpl<>("uuid", new GraphNodeStoreImpl());
final Node node = new NodeImpl<Definition>("node-uuid");
final CaseManagementDiagram content = new CaseManagementDiagram.CaseManagementDiagramBuilder().build();
node.setContent(new DefinitionImpl<>(content));
graph.addNode(node);
final Node<Definition<CaseManagementDiagram>, ?> fNode = CaseManagementUtils.getFirstDiagramNode(graph);
assertNotNull(fNode);
assertEquals("node-uuid", fNode.getUUID());
assertEquals(content, fNode.getContent().getDefinition());
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class CaseManagementContainmentAcceptorControlImpl method evaluate.
private boolean evaluate(final Element parent, final Node[] children, final Function<Command<AbstractCanvasHandler, CanvasViolation>, CommandResult<CanvasViolation>> executor) {
if (parent == null && (children == null || children.length == 0)) {
return false;
}
final Node child = children[0];
final Optional<Edge<?, Node>> edge = getFirstIncomingEdge(child, e -> e.getContent() instanceof Child);
if (edge.isPresent()) {
final Command<AbstractCanvasHandler, CanvasViolation> command = buildCommands(parent, child, edge.get());
final CommandResult<CanvasViolation> result = executor.apply(command);
return isCommandSuccess(result);
}
return true;
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class CaseManagementDrawCommand method execute.
@Override
@SuppressWarnings("unchecked")
public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) {
final Diagram diagram = context.getDiagram();
final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId();
childrenTraverseProcessor.traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() {
@Override
public void startNodeTraversal(final Node<View, Edge> node) {
super.startNodeTraversal(node);
addNode(node);
}
@Override
public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) {
super.startNodeTraversal(parents, node);
addNode(node);
context.addChild(parents.get(parents.size() - 1), node);
return true;
}
private void addNode(final Node<View, Edge> node) {
context.register(shapeSetId, node);
context.applyElementMutation(node, MutationContext.STATIC);
}
@Override
public void endGraphTraversal() {
super.endGraphTraversal();
context.getCanvas().draw();
}
});
return buildResult();
}
use of org.kie.workbench.common.stunner.core.graph.Node in project kie-wb-common by kiegroup.
the class CaseManagementSetChildNodeGraphCommand method addRelationship.
@SuppressWarnings("unchecked")
private void addRelationship(final Node parent, final Node child, final Optional<Integer> index, final GraphCommandExecutionContext context) {
final String uuid = UUID.uuid();
final Edge<Child, Node> edge = new EdgeImpl<>(uuid);
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(child);
if (index.isPresent()) {
parent.getOutEdges().add(index.get(), edge);
} else {
parent.getOutEdges().add(edge);
}
child.getInEdges().add(edge);
getMutableIndex(context).addEdge(edge);
}
Aggregations