Search in sources :

Example 6 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 7 with ClientRuntimeError

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

the class ClientSessionManagerImpl method handleCommandError.

@Override
public void handleCommandError(final CommandException ce) {
    super.handleCommandError(ce);
    sessionErrorEvent.fire(new OnSessionErrorEvent(current, new ClientRuntimeError("Error while executing command.", ce)));
}
Also used : OnSessionErrorEvent(org.kie.workbench.common.stunner.core.client.session.event.OnSessionErrorEvent) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError)

Example 8 with ClientRuntimeError

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

the class AbstractElementBuilderControl method build.

@Override
@SuppressWarnings("unchecked")
public void build(final ElementBuildRequest<AbstractCanvasHandler> request, final BuildCallback buildCallback) {
    if (null == canvasHandler) {
        buildCallback.onSuccess(null);
        return;
    }
    double x = request.getX();
    ;
    double y = request.getY();
    ;
    if (checkOutOfBoundsCanvas(x, y)) {
        buildCallback.onError(new ClientRuntimeError(new ElementOutOfBoundsException("Element is placed outside canvas bounds")));
        return;
    }
    final Object definition = request.getDefinition();
    // Notify processing starts.
    fireProcessingStarted();
    final Node<View<?>, Edge> parent = getParent(x, y);
    final Point2D childCoordinates = getChildCoordinates(parent, x, y);
    getCommands(definition, parent, childCoordinates.getX(), childCoordinates.getY(), new CommandsCallback() {

        @Override
        public void onComplete(final String uuid, final List<Command<AbstractCanvasHandler, CanvasViolation>> commands) {
            getCommandManager().execute(canvasHandler, new CompositeCommand.Builder().addCommands(commands).build());
            buildCallback.onSuccess(uuid);
            // Notify processing ends.
            fireProcessingCompleted();
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            buildCallback.onError(error);
            // Notify processing ends.
            fireProcessingCompleted();
        }
    });
}
Also used : ElementOutOfBoundsException(org.kie.workbench.common.stunner.core.client.canvas.controls.exceptions.ElementOutOfBoundsException) RuleContextBuilder(org.kie.workbench.common.stunner.core.rule.context.impl.RuleContextBuilder) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) Command(org.kie.workbench.common.stunner.core.command.Command) CompositeCommand(org.kie.workbench.common.stunner.core.command.impl.CompositeCommand) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 9 with ClientRuntimeError

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

the class ObserverBuilderControl method onBuildCanvasShape.

@SuppressWarnings("unchecked")
void onBuildCanvasShape(@Observes final BuildCanvasShapeEvent buildCanvasShapeEvent) {
    checkNotNull("buildCanvasShapeEvent", buildCanvasShapeEvent);
    if (null != canvasHandler) {
        final CanvasHandler context = buildCanvasShapeEvent.getCanvasHandler();
        if (null != context && context.equals(canvasHandler)) {
            final Object definition = buildCanvasShapeEvent.getDefinition();
            final double x = buildCanvasShapeEvent.getX();
            final double y = buildCanvasShapeEvent.getY();
            final double _x = x >= 0 ? x - canvasHandler.getAbstractCanvas().getAbsoluteX() : -1;
            final double _y = y >= 0 ? y - canvasHandler.getAbstractCanvas().getAbsoluteY() : -1;
            final ElementBuildRequest<AbstractCanvasHandler> request = new ElementBuildRequestImpl(_x, _y, definition);
            ObserverBuilderControl.this.build(request, new BuildCallback() {

                @Override
                public void onSuccess(final String uuid) {
                    canvasHandler.getCanvas().draw();
                    canvasSelectionEvent.fire(new CanvasSelectionEvent(canvasHandler, uuid));
                }

                @Override
                public void onError(final ClientRuntimeError error) {
                    LOGGER.log(Level.SEVERE, error.toString());
                }
            });
        }
    }
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasSelectionEvent) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) ElementBuildRequestImpl(org.kie.workbench.common.stunner.core.client.canvas.controls.builder.request.ElementBuildRequestImpl)

Example 10 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)

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