/** @generated */ private Collection<IAdaptable> createConnections( Collection<TaiPanLinkDescriptor> linkDescriptors, Domain2Notation domain2NotationMap) { LinkedList<IAdaptable> adapters = new LinkedList<IAdaptable>(); for (TaiPanLinkDescriptor nextLinkDescriptor : linkDescriptors) { EditPart sourceEditPart = getSourceEditPart(nextLinkDescriptor, domain2NotationMap); EditPart targetEditPart = getTargetEditPart(nextLinkDescriptor, domain2NotationMap); if (sourceEditPart == null || targetEditPart == null) { continue; } CreateConnectionViewRequest.ConnectionViewDescriptor descriptor = new CreateConnectionViewRequest.ConnectionViewDescriptor( nextLinkDescriptor.getSemanticAdapter(), TaiPanVisualIDRegistry.getType(nextLinkDescriptor.getVisualID()), ViewUtil.APPEND, false, ((IGraphicalEditPart) getHost()).getDiagramPreferencesHint()); CreateConnectionViewRequest ccr = new CreateConnectionViewRequest(descriptor); ccr.setType(RequestConstants.REQ_CONNECTION_START); ccr.setSourceEditPart(sourceEditPart); sourceEditPart.getCommand(ccr); ccr.setTargetEditPart(targetEditPart); ccr.setType(RequestConstants.REQ_CONNECTION_END); Command cmd = targetEditPart.getCommand(ccr); if (cmd != null && cmd.canExecute()) { executeCommand(cmd); IAdaptable viewAdapter = (IAdaptable) ccr.getNewObject(); if (viewAdapter != null) { adapters.add(viewAdapter); } } } return adapters; }
/** @generated */ private Collection<IAdaptable> refreshConnections() { Domain2Notation domain2NotationMap = new Domain2Notation(); Collection<TaiPanLinkDescriptor> linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap); Collection existingLinks = new LinkedList(getDiagram().getEdges()); for (Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext(); ) { Edge nextDiagramLink = (Edge) linksIterator.next(); int diagramLinkVisualID = TaiPanVisualIDRegistry.getVisualID(nextDiagramLink); if (diagramLinkVisualID == -1) { if (nextDiagramLink.getSource() != null && nextDiagramLink.getTarget() != null) { linksIterator.remove(); } continue; } EObject diagramLinkObject = nextDiagramLink.getElement(); EObject diagramLinkSrc = nextDiagramLink.getSource().getElement(); EObject diagramLinkDst = nextDiagramLink.getTarget().getElement(); for (Iterator<TaiPanLinkDescriptor> linkDescriptorsIterator = linkDescriptors.iterator(); linkDescriptorsIterator.hasNext(); ) { TaiPanLinkDescriptor nextLinkDescriptor = linkDescriptorsIterator.next(); if (diagramLinkObject == nextLinkDescriptor.getModelElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) { linksIterator.remove(); linkDescriptorsIterator.remove(); break; } } } deleteViews(existingLinks.iterator()); return createConnections(linkDescriptors, domain2NotationMap); }