@Override public boolean containmentAllowed(final WiresContainer wiresContainer, final WiresShape[] wiresShapes) { final WiresShape wiresShape = wiresShapes[0]; if (!isWiresViewAccept(wiresContainer, wiresShape)) { return false; } final Node childNode = WiresUtils.getNode(getCanvasHandler(), wiresShape); final Node parentNode = WiresUtils.getNode(getCanvasHandler(), wiresContainer); return allow(parentNode, new Node[]{childNode}); }
protected Command<AbstractCanvasHandler, CanvasViolation> makeAddMutationCommand(final WiresShape shape, final WiresContainer container, final OptionalInt index, final Optional<WiresContainer> originalContainer, final OptionalInt originalIndex) { final Node parent = WiresUtils.getNode(getCanvasHandler(), container); final Node child = WiresUtils.getNode(getCanvasHandler(), shape); final Optional<Node> originalParent = originalContainer.flatMap((c) -> Optional.ofNullable(WiresUtils.getNode(getCanvasHandler(), c))); // Set relationship. return getSetEdgeCommand(parent, child, index, originalParent, originalIndex); } }
private Node toNode(final WiresContainer shape) { return WiresUtils.getNode(getCanvasHandler(), shape); } };
public static Node getNode(final AbstractCanvasHandler canvasHandler, final WiresMagnet magnet) { if (null == magnet) { return null; } final WiresShape shape = magnet.getMagnets().getWiresShape(); return getNode(canvasHandler, shape); }
@Override public boolean dockingAllowed(final WiresContainer wiresContainer, final WiresShape wiresShape) { if (!isWiresViewAccept(wiresContainer, wiresShape)) { return false; } final Node childNode = WiresUtils.getNode(getCanvasHandler(), wiresShape); final Node parentNode = WiresUtils.getNode(getCanvasHandler(), wiresContainer); return allow(parentNode, childNode); }
@Override public boolean acceptDocking(final WiresContainer wiresContainer, final WiresShape wiresShape) { if (!isWiresViewAccept(wiresContainer, wiresShape)) { return false; } final Node childNode = WiresUtils.getNode(getCanvasHandler(), wiresShape); final Node parentNode = WiresUtils.getNode(getCanvasHandler(), wiresContainer); return accept(parentNode, childNode); }
@Override @SuppressWarnings("unchecked") public boolean headConnectionAllowed(final WiresConnection head, final WiresShape shape) { final Edge<ViewConnector<?>, Node> edge = WiresUtils.getEdge(getCanvasHandler(), head.getConnector()); final Node sourceNode = WiresUtils.getNode(getCanvasHandler(), shape); return allowSource(sourceNode, edge, createConnection(sourceNode)); }
@Override @SuppressWarnings("unchecked") public boolean tailConnectionAllowed(final WiresConnection tail, final WiresShape shape) { final Edge<ViewConnector<?>, Node> edge = WiresUtils.getEdge(getCanvasHandler(), tail.getConnector()); final Node targetNode = WiresUtils.getNode(getCanvasHandler(), shape); return allowTarget(targetNode, edge, createConnection(targetNode)); } };
@Override @SuppressWarnings("unchecked") public boolean acceptHead(final WiresConnection head, final WiresMagnet wiresMagnet) { final Edge edge = WiresUtils.getEdge(getCanvasHandler(), head.getConnector()); final Node sourceNode = WiresUtils.getNode(getCanvasHandler(), wiresMagnet); final Connection connection = createConnection(head, wiresMagnet); return acceptSource(sourceNode, edge, connection); }
@Override @SuppressWarnings("unchecked") public boolean acceptTail(final WiresConnection tail, final WiresMagnet wiresMagnet) { final WiresConnection head = tail.getConnector().getHeadConnection(); final Edge edge = WiresUtils.getEdge(getCanvasHandler(), head.getConnector()); final Node targetNode = WiresUtils.getNode(getCanvasHandler(), wiresMagnet); final Connection connection = createConnection(tail, wiresMagnet); return acceptTarget(targetNode, edge, connection); }