use of org.kie.workbench.common.stunner.core.graph.command.GraphCommandResultBuilder in project kie-wb-common by kiegroup.
the class UpdateElementPositionCommand method checkBounds.
@SuppressWarnings("unchecked")
private CommandResult<RuleViolation> checkBounds(final GraphCommandExecutionContext context) {
final Element<? extends View<?>> element = getNodeNotNull(context);
final Graph<DefinitionSet, Node> graph = (Graph<DefinitionSet, Node>) getGraph(context);
final BoundsImpl newBounds = getTargetBounds(element);
final GraphCommandResultBuilder result = new GraphCommandResultBuilder();
final Bounds parentBounds = getParentBounds(element, graph);
if (GraphUtils.checkBoundsExceeded(parentBounds, newBounds)) {
((View) element.getContent()).setBounds(newBounds);
} else {
result.addViolation(new BoundsExceededViolation(parentBounds).setUUID(element.getUUID()));
}
return result.build();
}
Aggregations