@SuppressWarnings("unchecked") public static Element<? extends Definition<?>> getElement(final AbstractCanvasHandler canvasHandler, final String uuid) { if (Objects.isNull(canvasHandler) || Objects.isNull(uuid)) { return null; } final Index<?, ?> index = canvasHandler.getGraphIndex(); if (Objects.isNull(index)) { return null; } return index.get(uuid); }
@SuppressWarnings("unchecked") protected Node<?, Edge> getNode(final AbstractCanvasHandler context, final String uuid) { return context.getGraphIndex().getNode(uuid); }
private Edge getEdge(final String uuid) { return canvasHandler.getGraphIndex().getEdge(uuid); }
@Override public void saveContainer(String id) { HashMap<String, String> map = new HashMap<>(); //setting the node id in case it exists on graph if (canvasHandler.getGraphIndex().get(id) != null) { map.put(DEFAULT_NODE_ID, id); map.put(svgNodeId, id); } context.saveGroup(map); }
@SuppressWarnings("unchecked") public ToolboxControl<AbstractCanvasHandler, Element> show(final String uuid) { if (showToolboxPredicate.test(uuid)) { final Node node = canvasHandler.getGraphIndex().getNode(uuid); // Only nodes have toolbox/es, discard processing for edges. if (null != node) { return show(node); } } return this; }
public static Edge getEdge(final AbstractCanvasHandler canvasHandler, final WiresConnector connector) { if (connector instanceof ShapeView) { final ShapeView view = (ShapeView) connector; return canvasHandler.getGraphIndex().getEdge(view.getUUID()); } return null; }
@SuppressWarnings("unchecked") private Element<? extends View<?>> getViewElement(final String uuid) { return getCanvasHandler().getGraphIndex().get(uuid); } }
private boolean existNode(final Node node, final AbstractCanvasHandler context) { return null != context.getGraphIndex().getNode(node.getUUID()); }
private boolean existsOnCanvas(Node<? extends View<?>, Edge> node) { return Objects.nonNull(getCanvasHandler().getGraphIndex().getNode(node.getUUID())); } }
private void call(final FormGenerationService service) { final AbstractCanvasHandler canvasHandler = getCanvasHandler(); final Index index = canvasHandler.getGraphIndex(); final String[] selectedItems = getSelectedItems() .stream() .map(index::get) .filter(acceptor) .map(Element::getUUID) .toArray(String[]::new); if (selectedItems.length > 0) { service.generateSelectedForms(getCanvasHandler().getDiagram(), selectedItems); } else { formGenerationNotifier.showNotification(translationService.getValue(FormsClientConstants.FormsNoItemsSelectedForGeneration)); } }
protected Element<? extends View<?>> getElement(String uuid) { AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) getSession().getCanvasHandler(); return canvasHandler.getGraphIndex().get(uuid); }
private Element<?> getParentOfParent(AbstractCanvasHandler context, Node parent) { final Element parentOfParent = GraphUtils.getParent(parent); return (GraphUtils.isRootNode((Element<? extends View<?>>) parentOfParent, context.getGraphIndex().getGraph()) ? context.getGraphIndex().getNode(context.getDiagram().getMetadata().getCanvasRootUUID()) : parentOfParent); }
public static Node getNode(final AbstractCanvasHandler canvasHandler, final WiresContainer shape) { if (null == shape) { return null; } if (shape instanceof ShapeView) { final ShapeView view = (ShapeView) shape; return canvasHandler.getGraphIndex().getNode(view.getUUID()); } else if (shape instanceof WiresLayer) { final String canvasRoot = canvasHandler.getDiagram().getMetadata().getCanvasRootUUID(); if (null != canvasRoot) { return canvasHandler.getGraphIndex().getNode(canvasRoot); } } return null; }
@SuppressWarnings("unchecked") private boolean isBoundaryEvent(final String uuid) { final AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(); final Node node = canvasHandler.getGraphIndex().getNode(uuid); return GraphUtils.isDockedNode(node); } }
@Override @SuppressWarnings("unchecked") public Node<View<?>, Edge> getAt(final double x, final double y) { final WiresCanvas canvas = (WiresCanvas) canvasHandler.getAbstractCanvas(); final LienzoLayer lienzoLayer = canvas.getView().getLayer(); final String viewUUID = LienzoLayerUtils.getUUID_At(lienzoLayer, x, y); if (null != viewUUID && viewUUID.trim().length() > 0) { final Shape<?> shape = canvas.getShape(viewUUID); if (null != shape) { return canvasHandler.getGraphIndex().getNode(shape.getUUID()); } } return null; }
protected Optional<AbstractCanvasGraphCommand> getUpdateStunnerTitleCommand(final String value) { AbstractCanvasGraphCommand command = null; if (getNodeUUID().isPresent()) { final String uuid = getNodeUUID().get(); final AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(); final Element<?> element = canvasHandler.getGraphIndex().get(uuid); if (element.getContent() instanceof Definition) { final Definition definition = (Definition) element.getContent(); final String nameId = definitionUtils.getNameIdentifier(definition.getDefinition()); if (nameId != null) { command = (AbstractCanvasGraphCommand) canvasCommandFactory.updatePropertyValue(element, nameId, value); } } } return Optional.ofNullable(command); }
final ShapeView shapeView = (ShapeView) container; final String uuid = shapeView.getUUID(); elements[i] = canvasHandler.getGraphIndex().get(uuid); locations[i] = new Point2D(points[i].getX(), points[i].getY());
@SuppressWarnings("unchecked") public static void moveViewConnectorsToTop(final AbstractCanvasHandler canvasHandler, final Node<?, Edge> node) { final Set<String> connectorIds = new HashSet<>(); // Obtain all view connectors for the node and its children. appendViewConnectorIds(connectorIds, node); new ChildrenTraverseProcessorImpl(new TreeWalkTraverseProcessorImpl()) .setRootUUID(node.getUUID()) .traverse(canvasHandler.getGraphIndex().getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() { @Override public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> childNode) { appendViewConnectorIds(connectorIds, childNode); return true; } }); // Update connector's view. connectorIds.forEach(id -> moveShapeToTop(canvasHandler, id)); }
@SuppressWarnings("unchecked") private boolean isParentAnEventSubProcess(final String uuid) { AbstractCanvasHandler canvasHandler = (AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(); Node node = canvasHandler.getGraphIndex().getNode(uuid); Element<?> parent = GraphUtils.getParent(node); if (null != parent && null != parent.asNode() && parent.asNode().getContent() instanceof View) { return ((Node<View<?>, Edge>) parent.asNode()) .getContent() .getDefinition() .getClass() .equals(EventSubprocess.class); } return false; } }
sessionCommandManager.execute(canvasHandler, canvasCommandFactory.delete(selectedItems.stream() .map(uuid -> canvasHandler.getGraphIndex().get(uuid)) .filter(Objects::nonNull) .collect(Collectors.toList())));