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