use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class AbstractClientSessionCommand method loadCanvasFactory.
protected CanvasCommandFactory<AbstractCanvasHandler> loadCanvasFactory(final ManagedInstance<CanvasCommandFactory<AbstractCanvasHandler>> canvasCommandFactoryInstance, final DefinitionUtils definitionUtils) {
final Diagram diagram = session.getCanvasHandler().getDiagram();
final String id = diagram.getMetadata().getDefinitionSetId();
final Annotation qualifier = definitionUtils.getQualifier(id);
return InstanceUtils.lookup(canvasCommandFactoryInstance, qualifier);
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class GraphUtilsTest method testComputeCardinalityState.
@SuppressWarnings("unchecked")
@Test
public void testComputeCardinalityState() {
String canvasRootUUID = "rootUUID";
Node rootNode = new NodeImpl<>(canvasRootUUID);
Node node1 = new NodeImpl<>("node1");
Node node2 = new NodeImpl<>("node2");
Node node3 = new NodeImpl<>("node3");
Metadata metadata = new MetadataImpl();
metadata.setCanvasRootUUID(canvasRootUUID);
Graph graph = new GraphImpl<>("graph1", new GraphNodeStoreImpl());
Diagram diagram = new DiagramImpl("diagram1", graph, metadata);
assertEquals(GraphUtils.CardinalityCountState.EMPTY, computeCardinalityState(diagram));
graph.addNode(rootNode);
assertEquals(GraphUtils.CardinalityCountState.EMPTY, computeCardinalityState(diagram));
graph.addNode(node1);
assertEquals(GraphUtils.CardinalityCountState.SINGLE_NODE, computeCardinalityState(diagram));
graph.addNode(node2);
assertEquals(GraphUtils.CardinalityCountState.MULTIPLE_NODES, computeCardinalityState(diagram));
graph.clear();
assertEquals(GraphUtils.CardinalityCountState.EMPTY, computeCardinalityState(diagram));
graph.addNode(node1);
assertEquals(GraphUtils.CardinalityCountState.SINGLE_NODE, computeCardinalityState(diagram));
graph.addNode(rootNode);
assertEquals(GraphUtils.CardinalityCountState.SINGLE_NODE, computeCardinalityState(diagram));
graph.addNode(node2);
assertEquals(GraphUtils.CardinalityCountState.MULTIPLE_NODES, computeCardinalityState(diagram));
graph.clear();
assertEquals(GraphUtils.CardinalityCountState.EMPTY, computeCardinalityState(diagram));
graph.addNode(node1);
assertEquals(GraphUtils.CardinalityCountState.SINGLE_NODE, computeCardinalityState(diagram));
graph.addNode(node2);
assertEquals(GraphUtils.CardinalityCountState.MULTIPLE_NODES, computeCardinalityState(diagram));
graph.addNode(node3);
assertEquals(GraphUtils.CardinalityCountState.MULTIPLE_NODES, computeCardinalityState(diagram));
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class AbstractVFSDiagramServiceTest method testGetDiagramByPath.
@Test
public void testGetDiagramByPath() throws IOException {
final Path path = mockGetDiagramByPathObjects();
Diagram result = diagramService.getDiagramByPath(path);
assertEquals(diagram, result);
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DeleteNodeConfirmationImpl method init.
@PostConstruct
public void init() {
final Diagram diagram = sessionManager.getCurrentSession().getCanvasHandler().getDiagram();
final Annotation qualifier = definitionUtils.getQualifier(diagram.getMetadata().getDefinitionSetId());
graphsProvider = InstanceUtils.lookup(graphsProviderInstances, GraphsProvider.class, qualifier);
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class GlobalSessionManager method destroy.
@Override
public <S extends ClientSession> void destroy(final S session) {
final boolean isCurrent = session.equals(current);
final String uuid = session.getSessionUUID();
final Diagram diagram = session.getCanvasHandler().getDiagram();
final String name = null != diagram ? diagram.getName() : null;
final String graphUuid = null != diagram ? diagram.getGraph().getUUID() : null;
final Metadata metadata = null != diagram ? diagram.getMetadata() : null;
((AbstractSession) session).destroy();
sessionInstances.destroy(session);
if (isCurrent) {
current = null;
}
sessionDestroyedEvent.fire(new SessionDestroyedEvent(uuid, name, graphUuid, metadata));
}
Aggregations