Search in sources :

Example 66 with Diagram

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

the class SessionDiagramEditorScreen method openDiagram.

private void openDiagram(Diagram diagram, Command callback) {
    final Metadata metadata = diagram.getMetadata();
    sessionManager.getSessionFactory(metadata, ClientFullSession.class).newSession(metadata, s -> {
        final AbstractClientFullSession session = (AbstractClientFullSession) s;
        presenter = sessionPresenterFactory.newPresenterEditor();
        screenPanelView.setWidget(presenter.getView());
        presenter.withToolbar(true).withPalette(true).displayNotifications(type -> true).open(diagram, session, new ScreenPresenterCallback(callback));
    });
}
Also used : OnLostFocus(org.uberfire.lifecycle.OnLostFocus) ValidationUtils(org.kie.workbench.common.stunner.core.validation.impl.ValidationUtils) UUID(org.kie.workbench.common.stunner.core.util.UUID) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) SessionPresenter(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenter) DiagramElementViolation(org.kie.workbench.common.stunner.core.validation.DiagramElementViolation) PathFactory(org.uberfire.backend.vfs.PathFactory) Observes(javax.enterprise.event.Observes) DefinitionManager(org.kie.workbench.common.stunner.core.api.DefinitionManager) IsWidget(com.google.gwt.user.client.ui.IsWidget) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) WorkbenchScreen(org.uberfire.client.annotations.WorkbenchScreen) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) Collection(java.util.Collection) Violation(org.kie.workbench.common.stunner.core.validation.Violation) Menus(org.uberfire.workbench.model.menu.Menus) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Logger(java.util.logging.Logger) ClientFactoryService(org.kie.workbench.common.stunner.core.client.service.ClientFactoryService) PlaceRequest(org.uberfire.mvp.PlaceRequest) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) WorkbenchMenu(org.uberfire.client.annotations.WorkbenchMenu) LogConfiguration(com.google.gwt.logging.client.LogConfiguration) EditorToolbar(org.kie.workbench.common.stunner.client.widgets.toolbar.impl.EditorToolbar) OnOpen(org.uberfire.lifecycle.OnOpen) MenuDevCommandsBuilder(org.kie.workbench.common.stunner.client.widgets.menu.dev.MenuDevCommandsBuilder) PostConstruct(javax.annotation.PostConstruct) MetadataImpl(org.kie.workbench.common.stunner.core.diagram.MetadataImpl) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) DiagramEditor(org.kie.workbench.common.stunner.core.client.annotation.DiagramEditor) OnFocus(org.uberfire.lifecycle.OnFocus) ScreenPanelView(org.kie.workbench.common.stunner.client.widgets.views.session.ScreenPanelView) ScreenErrorView(org.kie.workbench.common.stunner.client.widgets.views.session.ScreenErrorView) Level(java.util.logging.Level) Inject(javax.inject.Inject) MenuFactory(org.uberfire.workbench.model.menu.MenuFactory) ClientSessionCommand(org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) WorkbenchPartTitle(org.uberfire.client.annotations.WorkbenchPartTitle) SessionPresenterFactory(org.kie.workbench.common.stunner.client.widgets.presenters.session.SessionPresenterFactory) WorkbenchContextId(org.uberfire.client.annotations.WorkbenchContextId) AbstractClientReadOnlySession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientReadOnlySession) SessionManager(org.kie.workbench.common.stunner.core.client.api.SessionManager) ServiceCallback(org.kie.workbench.common.stunner.core.client.service.ServiceCallback) OnStartup(org.uberfire.lifecycle.OnStartup) Command(org.uberfire.mvp.Command) FINE(java.util.logging.Level.FINE) Event(javax.enterprise.event.Event) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Dependent(javax.enterprise.context.Dependent) WorkbenchPartView(org.uberfire.client.annotations.WorkbenchPartView) OnClose(org.uberfire.lifecycle.OnClose) BusyPopup(org.uberfire.ext.widgets.common.client.common.BusyPopup) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession) ClientFullSession(org.kie.workbench.common.stunner.core.client.session.ClientFullSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) AbstractClientFullSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientFullSession)

Example 67 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 68 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 69 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 70 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)

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