use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class LocationControlImpl method move.
@Override
@SuppressWarnings("unchecked")
public CommandResult<CanvasViolation> move(final Element[] elements, final Point2D[] locations) {
if (elements.length != locations.length) {
throw new IllegalArgumentException("The length for the elements to move " + "does not match the locations provided.");
}
Command<AbstractCanvasHandler, CanvasViolation> command;
if (elements.length == 1) {
command = createMoveCommand(elements[0], locations[0]);
} else {
final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> builder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>().forward();
int i = 0;
for (final Element element : elements) {
final CanvasCommand<AbstractCanvasHandler> c = createMoveCommand(element, locations[i]);
builder.addCommand(c);
i++;
}
command = builder.build();
}
CommandResult<CanvasViolation> result = getCommandManager().allow(canvasHandler, command);
if (!CommandUtils.isError(result)) {
result = getCommandManager().execute(canvasHandler, command);
if (!CommandUtils.isError(result)) {
List<String> uuids = Arrays.stream(elements).map(Element::getUUID).collect(Collectors.toList());
shapeLocationsChangedEvent.fire(new ShapeLocationsChangedEvent(uuids, canvasHandler));
}
}
return result;
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class TreeExplorer method onElementAdded.
private void onElementAdded(Element element) {
if (isValidTreeItem().test(element)) {
final Element parent = GraphUtils.getParent((Node<?, ? extends Edge>) element);
addItem(parent, (Node) element, true, true);
}
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class TreeExplorer method onElementUpdated.
@SuppressWarnings("unchecked")
private void onElementUpdated(Element element, CanvasHandler canvasHandler) {
if (isValidTreeItem().test(element)) {
final Element lane = GraphUtils.getParent((Node<?, ? extends Edge>) element);
if (view.isItemChanged(element.getUUID(), null != lane ? lane.getUUID() : null, getItemName(element))) {
view.removeItem(element.getUUID());
addItem(lane, (Node) element, true, true);
final boolean hasChildren = GraphUtils.hasChildren((Node<?, ? extends Edge>) element);
if (hasChildren) {
childrenTraverseProcessor.setRootUUID(element.getUUID()).traverse(canvasHandler.getDiagram().getGraph(), new AbstractChildrenTraverseCallback<Node<org.kie.workbench.common.stunner.core.graph.content.view.View, Edge>, Edge<Child, Node>>() {
@Override
public boolean startNodeTraversal(final List<Node<org.kie.workbench.common.stunner.core.graph.content.view.View, Edge>> parents, final Node<org.kie.workbench.common.stunner.core.graph.content.view.View, Edge> node) {
super.startNodeTraversal(parents, node);
addItem(parents.get(parents.size() - 1), node, true, false);
return true;
}
@Override
public void startNodeTraversal(final Node<org.kie.workbench.common.stunner.core.graph.content.view.View, Edge> node) {
super.startNodeTraversal(node);
addItem(node, true, false);
}
});
}
}
}
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class SessionPreviewCanvasHandlerProxyTest method checkNotifyCanvasElementAddedDelegatesToWrapped.
@Test
public void checkNotifyCanvasElementAddedDelegatesToWrapped() {
final Element candidate = mock(Element.class);
proxy.notifyCanvasElementAdded(candidate);
verify(wrapped).notifyCanvasElementAdded(eq(candidate));
}
use of org.kie.workbench.common.stunner.core.graph.Element in project kie-wb-common by kiegroup.
the class SessionPreviewCanvasHandlerProxyTest method checkIsCanvasRootDelegatesToWrapped.
@Test
public void checkIsCanvasRootDelegatesToWrapped() {
final Element parent = mock(Element.class);
proxy.isCanvasRoot(parent);
verify(wrapped).isCanvasRoot(eq(parent));
}
Aggregations