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();
}
});
}
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)));
}
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();
}
});
}
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());
}
});
}
}
}
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);
}
});
}
Aggregations