Java Code Examples for org.eclipse.gmf.runtime.notation.Edge#getElement()
The following examples show how to use
org.eclipse.gmf.runtime.notation.Edge#getElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConnectorViewPasteOperation.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public void paste() throws Exception { //basically delay... connectorView = (Edge) getEObject(); sourceView = connectorView.getSource(); targetView = connectorView.getTarget(); EObject element = connectorView.getElement(); if (element != null) { if (element.eIsProxy()) { element = ClipboardSupportUtil.resolve(element, getParentPasteProcess().getLoadedIDToEObjectMapCopy()); } if (element.eIsProxy() == false) { pasteSemanticElement = true; } } }
Example 2
Source File: ExtractSubdiagramRefactoring.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void createEntryPoint(Edge edge, Diagram subdiagram) { Transition transition = (Transition) edge.getElement(); Region entryPointContainer = getEntryPointContainer(transition); Entry entryPoint = createSemanticEntryPoint(transition); // re-wire old transition to targeting the selected state transition.setTarget((State) subdiagram.getElement()); View oldTarget = edge.getTarget(); edge.setTarget(getContextObject()); // create node for entry point View entryPointContainerView = helper.getViewForSemanticElement(entryPointContainer, subdiagram); View entryPointRegionCompartment = ViewUtil.getChildBySemanticHint(entryPointContainerView, SemanticHints.REGION_COMPARTMENT); Node entryNode = ViewService.createNode(entryPointRegionCompartment, entryPoint, SemanticHints.ENTRY, preferencesHint); ViewService.createEdge(entryNode, oldTarget, entryPoint.getOutgoingTransitions().get(0), SemanticHints.TRANSITION, preferencesHint); addEntryPointSpec(transition, entryPoint); }
Example 3
Source File: WorkflowCanonicalEditPolicy.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ private Collection<IAdaptable> refreshConnections() { Domain2Notation domain2NotationMap = new Domain2Notation(); Collection<CrossflowLinkDescriptor> linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap); Collection existingLinks = new LinkedList(getDiagram().getEdges()); for (Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext();) { Edge nextDiagramLink = (Edge) linksIterator.next(); int diagramLinkVisualID = CrossflowVisualIDRegistry.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<CrossflowLinkDescriptor> linkDescriptorsIterator = linkDescriptors .iterator(); linkDescriptorsIterator.hasNext();) { CrossflowLinkDescriptor 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); }
Example 4
Source File: RegionCompartmentCanonicalEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected boolean shouldIncludeConnection(Edge connection, Collection<View> children) { // Connections should only be included, when the source vertex is // contained in the region this edit policy belongs to EObject element = (EObject) connection.getElement(); if (element instanceof Transition) { Vertex source = ((Transition) element).getSource(); if (!getSemanticHost().getVertices().contains(source)) { return false; } } return super.shouldIncludeConnection(connection, children); }
Example 5
Source File: ExtractSubdiagramRefactoring.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void createExitPoint(Edge edge, Diagram subdiagram) { Transition transition = (Transition) edge.getElement(); // create semantic exit point Region exitPointContainer = getExitPointContainer(transition); Exit exitPoint = createSemanticExitPoint(transition); // create node for exit point View exitPointContainerView = helper.getViewForSemanticElement(exitPointContainer, subdiagram); View exitPointRegionCompartment = ViewUtil.getChildBySemanticHint(exitPointContainerView, SemanticHints.REGION_COMPARTMENT); Node exitNode = ViewService.createNode(exitPointRegionCompartment, exitPoint, SemanticHints.EXIT, preferencesHint); // re-wire existing transition to new exit point Vertex oldTransitionTarget = transition.getTarget(); transition.setTarget(exitPoint); View oldEdgeTarget = edge.getTarget(); edge.setTarget(exitNode); // create transition from selected state to former transition target Transition exitPointTransition = SGraphFactory.eINSTANCE.createTransition(); exitPointTransition.setSource((State) subdiagram.getElement()); exitPointTransition.setTarget(oldTransitionTarget); ViewService.createEdge(getContextObject(), oldEdgeTarget, exitPointTransition, SemanticHints.TRANSITION, preferencesHint); addExitPointSpec(exitPointTransition, exitPoint); }
Example 6
Source File: PoolItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getDestroyElementCommand(DestroyElementRequest req) { View view = (View) getHost().getModel(); CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); cmd.setTransactionNestingEnabled(false); for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) { Edge incomingLink = (Edge) it.next(); if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) { DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false); cmd.add(new DestroyElementCommand(r)); cmd.add(new DeleteCommand(getEditingDomain(), incomingLink)); continue; } } EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ if (annotation == null) { // there are indirectly referenced children, need extra commands: false addDestroyChildNodesCommand(cmd); addDestroyShortcutsCommand(cmd, view); // delete host element cmd.add(new DestroyElementCommand(req)); } else { cmd.add(new DeleteCommand(getEditingDomain(), view)); } final EObject pool = req.getElementToDestroy(); if (pool instanceof Pool) { for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) { if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) { cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false))); } } } return getGEFWrapper(cmd.reduce()); }
Example 7
Source File: SubProcessEvent2ItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getDestroyElementCommand(DestroyElementRequest req) { View view = (View) getHost().getModel(); CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); cmd.setTransactionNestingEnabled(false); for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) { Edge incomingLink = (Edge) it.next(); if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) { DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false); cmd.add(new DestroyElementCommand(r)); cmd.add(new DeleteCommand(getEditingDomain(), incomingLink)); continue; } } EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ if (annotation == null) { // there are indirectly referenced children, need extra commands: false addDestroyChildNodesCommand(cmd); addDestroyShortcutsCommand(cmd, view); // delete host element cmd.add(new DestroyElementCommand(req)); } else { cmd.add(new DeleteCommand(getEditingDomain(), view)); } final EObject pool = req.getElementToDestroy(); if (pool instanceof Pool) { for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) { if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) { cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false))); } } } return getGEFWrapper(cmd.reduce()); }
Example 8
Source File: LaneItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getDestroyElementCommand(DestroyElementRequest req) { View view = (View) getHost().getModel(); CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); cmd.setTransactionNestingEnabled(false); for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) { Edge incomingLink = (Edge) it.next(); if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) { DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false); cmd.add(new DestroyElementCommand(r)); cmd.add(new DeleteCommand(getEditingDomain(), incomingLink)); continue; } } EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ if (annotation == null) { // there are indirectly referenced children, need extra commands: false addDestroyChildNodesCommand(cmd); addDestroyShortcutsCommand(cmd, view); // delete host element cmd.add(new DestroyElementCommand(req)); } else { cmd.add(new DeleteCommand(getEditingDomain(), view)); } final EObject pool = req.getElementToDestroy(); if (pool instanceof Pool) { for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) { if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) { cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false))); } } } return getGEFWrapper(cmd.reduce()); }
Example 9
Source File: SubProcessEventItemSemanticEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected Command getDestroyElementCommand(DestroyElementRequest req) { View view = (View) getHost().getModel(); CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), null); cmd.setTransactionNestingEnabled(false); for (Iterator<?> it = view.getTargetEdges().iterator(); it.hasNext();) { Edge incomingLink = (Edge) it.next(); if (ProcessVisualIDRegistry.getVisualID(incomingLink) == TextAnnotationAttachmentEditPart.VISUAL_ID) { DestroyElementRequest r = new DestroyElementRequest(incomingLink.getElement(), false); cmd.add(new DestroyElementCommand(r)); cmd.add(new DeleteCommand(getEditingDomain(), incomingLink)); continue; } } EAnnotation annotation = view.getEAnnotation("Shortcut"); //$NON-NLS-1$ if (annotation == null) { // there are indirectly referenced children, need extra commands: false addDestroyChildNodesCommand(cmd); addDestroyShortcutsCommand(cmd, view); // delete host element cmd.add(new DestroyElementCommand(req)); } else { cmd.add(new DeleteCommand(getEditingDomain(), view)); } final EObject pool = req.getElementToDestroy(); if (pool instanceof Pool) { for (MessageFlow f : ModelHelper.getMainProcess(pool).getMessageConnections()) { if (pool.equals(ModelHelper.getParentProcess(f.getSource()))) { cmd.add(new DestroyElementCommand(new DestroyElementRequest(f, false))); } } } return getGEFWrapper(cmd.reduce()); }
Example 10
Source File: MainProcessCanonicalEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ private Collection<IAdaptable> refreshConnections() { Domain2Notation domain2NotationMap = new Domain2Notation(); Collection<ProcessLinkDescriptor> linkDescriptors = collectAllLinks(getDiagram(), domain2NotationMap); Collection existingLinks = new LinkedList(getDiagram().getEdges()); for (Iterator linksIterator = existingLinks.iterator(); linksIterator.hasNext();) { Edge nextDiagramLink = (Edge) linksIterator.next(); int diagramLinkVisualID = ProcessVisualIDRegistry.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<ProcessLinkDescriptor> linkDescriptorsIterator = linkDescriptors .iterator(); linkDescriptorsIterator.hasNext();) { ProcessLinkDescriptor 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); }
Example 11
Source File: ConnectorViewPostPasteChildOperation.java From statecharts with Eclipse Public License 1.0 | 4 votes |
/** * @return * @throws Exception */ private EObject doPaste() throws Exception { View sourceView = getConnectorViewPasteOperation().getSourceView(); View targetView = getConnectorViewPasteOperation().getTargetView(); if ((sourceView == null) || (targetView == null)) { return null; } EObject sourceViewContainer = sourceView.eContainer(); EObject targetViewContainer = targetView.eContainer(); if ((sourceViewContainer == null) || (targetViewContainer == null)) { return null; } if (sourceViewContainer.equals(targetViewContainer) == false) { //not in the same container, let's try to see if they are in the // same diagram at least Diagram sourceViewDiagram = NotationClipboardOperationHelper .getContainingDiagram((View) sourceViewContainer); Diagram targetViewDiagram = NotationClipboardOperationHelper .getContainingDiagram((View) targetViewContainer); if ((sourceViewDiagram == null) || (targetViewDiagram == null) || (sourceViewDiagram.equals(targetViewDiagram) == false)) { return null; } } Edge connectorView = getConnectorViewPasteOperation() .getConnectorView(); if (pasteSemanticElement) { EObject semanticElement = connectorView.getElement(); if (semanticElement != null) { if (semanticElement.eIsProxy()) { semanticElement = ClipboardSupportUtil.resolve(semanticElement, getParentPasteProcess().getLoadedIDToEObjectMapCopy()); } String loadedId = getLoadedEObjectID(semanticElement); if (loadedId != null) { //even if we failed to paste the semantic element, we'll // proceed to paste the edge view doPasteSemanticElement(); //should have been pasted by now, if not then return String newId = getEObjectID(semanticElement); if (newId == null) { return null; } } } } EObject pastedElement = null; Diagram pasteTargetDiagram = NotationClipboardOperationHelper .getContainingDiagram((View) sourceViewContainer); if (pasteTargetDiagram != null) { //if we reached here then we should paste the connector and set // refs to it accordingly pastedElement = ClipboardSupportUtil.appendEObjectAt( pasteTargetDiagram, getContainmentFeature(), connectorView); if (pastedElement != null) { ClipboardSupportUtil.appendEObjectAt(sourceView, NotationPackage.eINSTANCE.getView_SourceEdges(), connectorView); ClipboardSupportUtil.appendEObjectAt(targetView, NotationPackage.eINSTANCE.getView_TargetEdges(), connectorView); } } return pastedElement; }