Search in sources :

Example 91 with Diagram

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);
}
Also used : Annotation(java.lang.annotation.Annotation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 92 with Diagram

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));
}
Also used : GraphNodeStoreImpl(org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) Graph(org.kie.workbench.common.stunner.core.graph.Graph) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) GraphImpl(org.kie.workbench.common.stunner.core.graph.impl.GraphImpl) DiagramImpl(org.kie.workbench.common.stunner.core.diagram.DiagramImpl) Node(org.kie.workbench.common.stunner.core.graph.Node) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 93 with 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);
}
Also used : Path(org.uberfire.backend.vfs.Path) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 94 with Diagram

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);
}
Also used : GraphsProvider(org.kie.workbench.common.stunner.core.diagram.GraphsProvider) Annotation(java.lang.annotation.Annotation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) PostConstruct(javax.annotation.PostConstruct)

Example 95 with Diagram

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));
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) SessionDestroyedEvent(org.kie.workbench.common.stunner.core.client.session.event.SessionDestroyedEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) AbstractSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)

Aggregations

Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)128 Test (org.junit.Test)64 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)48 Node (org.kie.workbench.common.stunner.core.graph.Node)38 Graph (org.kie.workbench.common.stunner.core.graph.Graph)31 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)24 View (org.kie.workbench.common.stunner.core.graph.content.view.View)23 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)22 ArrayList (java.util.ArrayList)20 List (java.util.List)20 Edge (org.kie.workbench.common.stunner.core.graph.Edge)20 Inject (javax.inject.Inject)15 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)15 Before (org.junit.Before)14 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)14 Map (java.util.Map)13 Optional (java.util.Optional)13 Collectors (java.util.stream.Collectors)13 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)13 Collection (java.util.Collection)12