use of org.kie.workbench.common.stunner.core.client.canvas.controls.exceptions.ElementOutOfBoundsException 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();
}
});
}
Aggregations