use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class RegisterNodeCommand method check.
@SuppressWarnings("unchecked")
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
final Graph graph = getGraph(context);
final Collection<RuleViolation> cardinalityRuleViolations = doEvaluate(context, RuleContextBuilder.GraphContexts.cardinality(graph, Optional.of(getCandidate()), Optional.of(CardinalityContext.Operation.ADD)));
return new GraphCommandResultBuilder(cardinalityRuleViolations).build();
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class RegisterNodeCommand method execute.
@Override
@SuppressWarnings("unchecked")
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
final CommandResult<RuleViolation> results = allow(context);
if (!results.getType().equals(CommandResult.Type.ERROR)) {
final Graph graph = getGraph(context);
graph.addNode(candidate);
getMutableIndex(context).addNode(candidate);
}
return results;
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetChildNodeCommand method execute.
@Override
@SuppressWarnings("unchecked")
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
final CommandResult<RuleViolation> results = allow(context);
if (!results.getType().equals(CommandResult.Type.ERROR)) {
final Node<?, Edge> parent = getParent(context);
final Node<?, Edge> candidate = getCandidate(context);
final String uuid = UUID.uuid();
final Edge<Child, Node> edge = new EdgeImpl<>(uuid);
edge.setContent(new Child());
edge.setSourceNode(parent);
edge.setTargetNode(candidate);
parent.getOutEdges().add(edge);
candidate.getInEdges().add(edge);
getMutableIndex(context).addEdge(edge);
}
return results;
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetChildNodeCommand method check.
@SuppressWarnings("unchecked")
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext context) {
final Element<? extends Definition<?>> parent = (Element<? extends Definition<?>>) getParent(context);
final Node<Definition<?>, Edge> candidate = (Node<Definition<?>, Edge>) getCandidate(context);
final Collection<RuleViolation> containmentRuleViolations = doEvaluate(context, RuleContextBuilder.GraphContexts.containment(getGraph(context), parent, candidate));
return new GraphCommandResultBuilder(containmentRuleViolations).build();
}
use of org.kie.workbench.common.stunner.core.rule.RuleViolation in project kie-wb-common by kiegroup.
the class SetConnectionSourceNodeCommand method execute.
@Override
@SuppressWarnings("unchecked")
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext context) {
final CommandResult<RuleViolation> results = allow(context);
if (!results.getType().equals(CommandResult.Type.ERROR)) {
final Edge<? extends View, Node> edge = getEdge(context);
final Node<?, Edge> sourceNode = getSourceNode(context);
final Node<? extends View<?>, Edge> lastSourceNode = edge.getSourceNode();
// New connection being made
if (null != lastSourceNode) {
this.lastSourceNodeUUID = lastSourceNode.getUUID();
lastSourceNode.getOutEdges().remove(edge);
}
if (null != sourceNode) {
sourceNode.getOutEdges().add(edge);
}
edge.setSourceNode(sourceNode);
// Magnet being moved on node
ViewConnector connectionContent = (ViewConnector) edge.getContent();
lastConnection = (Connection) connectionContent.getSourceConnection().orElse(null);
connectionContent.setSourceConnection(connection);
}
return results;
}
Aggregations