Search in sources :

Example 21 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method onStartup.

@OnStartup
public void onStartup(final PlaceRequest placeRequest) {
    this.placeRequest = placeRequest;
    this.menu = makeMenuBar();
    final String name = placeRequest.getParameter("name", "");
    final boolean isCreate = name == null || name.trim().length() == 0;
    final Command callback = () -> {
        final Diagram diagram = getDiagram();
        if (null != diagram) {
            // Update screen title.
            updateTitle(diagram.getMetadata().getTitle());
        }
    };
    if (isCreate) {
        final String defSetId = placeRequest.getParameter("defSetId", "");
        final String shapeSetd = placeRequest.getParameter("shapeSetId", "");
        final String title = placeRequest.getParameter("title", "");
        // Create a new diagram.
        newDiagram(UUID.uuid(), title, defSetId, shapeSetd, callback);
    } else {
        // Load an existing diagram.
        load(name, callback);
    }
}
Also used : ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.uberfire.mvp.Command) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnStartup(org.uberfire.lifecycle.OnStartup)

Example 22 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class SessionDiagramViewerScreen method onStartup.

@OnStartup
public void onStartup(final PlaceRequest placeRequest) {
    this.placeRequest = placeRequest;
    this.menu = makeMenuBar();
    final String name = placeRequest.getParameter("name", "");
    final boolean isCreate = name == null || name.trim().length() == 0;
    if (isCreate) {
        LOGGER.log(SEVERE, "This screen it's just read only!");
    } else {
        // Load an existing diagram.
        load(name, () -> {
            final Diagram diagram = getDiagram();
            if (null != diagram) {
                // Update screen title.
                updateTitle(diagram.getMetadata().getTitle());
            }
        });
    }
}
Also used : Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnStartup(org.uberfire.lifecycle.OnStartup)

Example 23 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method save.

// TODO: Move this to ClientFactoryServices, so shared for others as well.
public void save(final AbstractClientFullSession session, final ServiceCallback<Diagram<Graph, Metadata>> diagramServiceCallback) {
    // Update diagram's image data as thumbnail.
    final String thumbData = toImageData(session);
    final CanvasHandler canvasHandler = session.getCanvasHandler();
    final Diagram diagram = canvasHandler.getDiagram();
    diagram.getMetadata().setThumbData(thumbData);
    save(diagram, diagramServiceCallback);
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 24 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallEvaluationTwice.

@Test
public void testMarshallEvaluationTwice() throws Exception {
    Diagram diagram = unmarshall(BPMN_EVALUATION);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Diagram diagram2 = unmarshall(BPMN_EVALUATION);
    String result2 = tested.marshall(diagram2);
    assertDiagram(result2, 1, 7, 7);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Test(org.junit.Test)

Example 25 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method onStartup.

@OnStartup
public void onStartup(final PlaceRequest placeRequest) {
    this.placeRequest = placeRequest;
    this.menu = makeMenuBar();
    final String name = placeRequest.getParameter("name", "");
    final boolean isCreate = name == null || name.trim().length() == 0;
    final Command callback = () -> {
        final Diagram diagram = getDiagram();
        if (null != diagram) {
            // Update screen title.
            updateTitle(diagram.getMetadata().getTitle());
        }
    };
    if (isCreate) {
        final String defSetId = placeRequest.getParameter("defSetId", "");
        final String shapeSetd = placeRequest.getParameter("shapeSetId", "");
        final String title = placeRequest.getParameter("title", "");
        // Create a new diagram.
        newDiagram(UUID.uuid(), title, defSetId, shapeSetd, callback);
    } else {
        // Load an existing diagram.
        load(name, callback);
    }
}
Also used : ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) Command(org.uberfire.mvp.Command) NavigateToExpressionEditorCommand(org.kie.workbench.common.dmn.client.commands.general.NavigateToExpressionEditorCommand) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnStartup(org.uberfire.lifecycle.OnStartup)

Aggregations

Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)36 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)17 Test (org.junit.Test)12 Matchers.anyString (org.mockito.Matchers.anyString)9 Collection (java.util.Collection)7 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)7 Graph (org.kie.workbench.common.stunner.core.graph.Graph)7 ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)6 Node (org.kie.workbench.common.stunner.core.graph.Node)6 Before (org.junit.Before)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)5 Edge (org.kie.workbench.common.stunner.core.graph.Edge)5 OnStartup (org.uberfire.lifecycle.OnStartup)5 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)4 Element (org.kie.workbench.common.stunner.core.graph.Element)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 Command (org.uberfire.mvp.Command)4 ArrayList (java.util.ArrayList)3 Assert.assertEquals (org.junit.Assert.assertEquals)3