Search in sources :

Example 11 with ClientRuntimeError

use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method newDiagram.

private void newDiagram(final String uuid, final String title, final String definitionSetId, final String shapeSetId, final Command callback) {
    BusyPopup.showMessage("Loading");
    final Metadata metadata = buildMetadata(definitionSetId, shapeSetId, title);
    clientFactoryServices.newDiagram(uuid, definitionSetId, metadata, new ServiceCallback<Diagram>() {

        @Override
        public void onSuccess(final Diagram diagram) {
            final Metadata metadata = diagram.getMetadata();
            metadata.setShapeSetId(shapeSetId);
            metadata.setTitle(title);
            openDiagram(diagram, callback);
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            showError(error);
            callback.execute();
        }
    });
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 12 with ClientRuntimeError

use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.

the class ShowcaseDiagramService method loadByName.

public void loadByName(final String name, final ServiceCallback<Diagram> callback) {
    final DiagramLookupRequest request = new DiagramLookupRequest.Builder().withName(name).build();
    clientDiagramServices.lookup(request, new ServiceCallback<LookupManager.LookupResponse<DiagramRepresentation>>() {

        @Override
        public void onSuccess(LookupManager.LookupResponse<DiagramRepresentation> diagramRepresentations) {
            if (null != diagramRepresentations && !diagramRepresentations.getResults().isEmpty()) {
                final Path path = diagramRepresentations.getResults().get(0).getPath();
                loadByPath(path, callback);
            }
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            callback.onError(error);
        }
    });
}
Also used : DiagramRepresentation(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation) Path(org.uberfire.backend.vfs.Path) LookupManager(org.kie.workbench.common.stunner.core.lookup.LookupManager) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) DiagramLookupRequest(org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)

Example 13 with ClientRuntimeError

use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.

the class SessionDiagramPreviewScreen method doOpenDiagram.

@Override
protected void doOpenDiagram() {
    final AbstractClientSession session = getSession();
    if (null != session) {
        newPreview(() -> sessionPreview.open(session, WIDTH, HEIGHT, new SessionViewer.SessionViewerCallback<AbstractClientSession, Diagram>() {

            @Override
            public void afterCanvasInitialized() {
            }

            @Override
            public void onSuccess() {
                LOGGER.log(FINE, "Session's preview completed for [" + session + "]");
                view.showScreenView(sessionPreview.getView());
            }

            @Override
            public void onError(final ClientRuntimeError error) {
                LOGGER.log(SEVERE, "Error while showing session preview for [" + session + "]. " + "Error=[" + error + "]");
            }
        }));
    } else {
        LOGGER.log(WARNING, "Trying to open a null session!");
    }
}
Also used : AbstractClientSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractClientSession) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)

Example 14 with ClientRuntimeError

use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.

the class AbstractProjectDiagramEditor method save.

/**
 * Considering the diagram valid at this point ,
 * it delegates the save operation to the diagram services bean.
 * @param commitMessage The commit's message.
 */
@Override
@SuppressWarnings("unchecked")
protected void save(final String commitMessage) {
    super.save(commitMessage);
    showLoadingViews();
    // Update diagram's image data as thumbnail.
    final CanvasHandler canvasHandler = getSession().getCanvasHandler();
    final Diagram diagram = canvasHandler.getDiagram();
    // Perform update operation remote call.
    projectDiagramServices.saveOrUpdate(versionRecordManager.getCurrentPath(), getDiagram(), metadata, commitMessage, new ServiceCallback<ProjectDiagram>() {

        @Override
        public void onSuccess(final ProjectDiagram item) {
            getSaveSuccessCallback(item.hashCode());
            onSaveSuccess();
            hideLoadingViews();
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            onSaveError(error);
        }
    });
}
Also used : CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram)

Example 15 with ClientRuntimeError

use of org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError in project kie-wb-common by kiegroup.

the class ExportToBpmnSessionCommandTest method testExportUnSuccessful.

@Test
@SuppressWarnings("unchecked")
public void testExportUnSuccessful() {
    command.execute(callback);
    verify(clientDiagramService, times(1)).getRawContent(eq(diagram), callbackCaptor.capture());
    callbackCaptor.getValue().onError(new ClientRuntimeError(ERROR));
    verify(textFileExport, never()).export(anyObject(), anyObject());
    verify(errorPopupPresenter, times(1)).showMessage(ERROR);
}
Also used : ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Test(org.junit.Test)

Aggregations

ClientRuntimeError (org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)19 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)4 Test (org.junit.Test)3 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)3 OnSessionErrorEvent (org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent)3 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)3 PathPlaceRequest (org.uberfire.mvp.impl.PathPlaceRequest)3 Collection (java.util.Collection)2 Level (java.util.logging.Level)2 Logger (java.util.logging.Logger)2 Event (javax.enterprise.event.Event)2 Inject (javax.inject.Inject)2 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)2 CanvasSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent)2 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)2 CommandResult (org.kie.workbench.common.stunner.core.command.CommandResult)2 LookupManager (org.kie.workbench.common.stunner.core.lookup.LookupManager)2 DiagramLookupRequest (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramLookupRequest)2 DiagramRepresentation (org.kie.workbench.common.stunner.core.lookup.diagram.DiagramRepresentation)2 Path (org.uberfire.backend.vfs.Path)2