Search in sources :

Example 1 with Edge

use of org.eclipse.gmf.runtime.notation.Edge in project tdi-studio-se by Talend.

the class BusinessReorientConnectionViewCommand method doExecuteWithResult.

/**
     * @generated
     */
protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) {
    //$NON-NLS-1$
    assert null != edgeAdaptor : "Null child in BusinessReorientConnectionViewCommand";
    Edge edge = (Edge) getEdgeAdaptor().getAdapter(Edge.class);
    //$NON-NLS-1$
    assert null != edge : "Null edge in BusinessReorientConnectionViewCommand";
    View tempView = edge.getSource();
    edge.setSource(edge.getTarget());
    edge.setTarget(tempView);
    return CommandResult.newOKCommandResult();
}
Also used : Edge(org.eclipse.gmf.runtime.notation.Edge) View(org.eclipse.gmf.runtime.notation.View)

Example 2 with Edge

use of org.eclipse.gmf.runtime.notation.Edge in project tdi-studio-se by Talend.

the class BusinessProcessCanonicalEditPolicy method refreshConnections.

/**
     * @generated
     */
private Collection refreshConnections() {
    try {
        collectAllLinks(getDiagram());
        Collection existingLinks = new LinkedList(getDiagram().getEdges());
        for (Iterator diagramLinks = existingLinks.iterator(); diagramLinks.hasNext(); ) {
            Edge nextDiagramLink = (Edge) diagramLinks.next();
            EObject diagramLinkObject = nextDiagramLink.getElement();
            EObject diagramLinkSrc = nextDiagramLink.getSource().getElement();
            EObject diagramLinkDst = nextDiagramLink.getTarget().getElement();
            int diagramLinkVisualID = BusinessVisualIDRegistry.getVisualID(nextDiagramLink);
            for (Iterator modelLinkDescriptors = myLinkDescriptors.iterator(); modelLinkDescriptors.hasNext(); ) {
                LinkDescriptor nextLinkDescriptor = (LinkDescriptor) modelLinkDescriptors.next();
                if (diagramLinkObject == nextLinkDescriptor.getLinkElement() && diagramLinkSrc == nextLinkDescriptor.getSource() && diagramLinkDst == nextLinkDescriptor.getDestination() && diagramLinkVisualID == nextLinkDescriptor.getVisualID()) {
                    diagramLinks.remove();
                    modelLinkDescriptors.remove();
                }
            }
        }
        deleteViews(existingLinks.iterator());
        return createConnections(myLinkDescriptors);
    } finally {
        myLinkDescriptors.clear();
        myEObject2ViewMap.clear();
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Iterator(java.util.Iterator) Collection(java.util.Collection) Edge(org.eclipse.gmf.runtime.notation.Edge) LinkedList(java.util.LinkedList)

Example 3 with Edge

use of org.eclipse.gmf.runtime.notation.Edge in project statecharts by Yakindu.

the class SimulationImageRenderer method highlightElements.

public void highlightElements(final List<? extends EObject> objects, final Diagram diagram) {
    AbstractTransactionalCommand cmd = new AbstractTransactionalCommand(TransactionUtil.getEditingDomain(diagram), "", null) {

        @Override
        protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
            // Init colors from preferences
            RGB rgbForeGround = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.STATE_FOREGROUND_HIGHLIGHTING_COLOR);
            RGB rgbBackGround = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.STATE_BACKGROUND_HIGHLIGHTING_COLOR);
            RGB rgbTransitionActive = PreferenceConverter.getColor(SimulationActivator.getDefault().getPreferenceStore(), SimulationPreferenceConstants.TRANSITION_HIGHLIGHTING_COLOR);
            Color color = new Color(Display.getDefault(), rgbForeGround);
            Integer foreGround = FigureUtilities.colorToInteger(color);
            color.dispose();
            color = new Color(Display.getDefault(), rgbBackGround);
            Integer background = FigureUtilities.colorToInteger(color);
            color.dispose();
            color = new Color(Display.getDefault(), rgbTransitionActive);
            Integer transitionActive = FigureUtilities.colorToInteger(color);
            color.dispose();
            // Set styling
            TreeIterator<EObject> eAllContents = diagram.eAllContents();
            while (eAllContents.hasNext()) {
                EObject next = eAllContents.next();
                if (next instanceof View) {
                    for (EObject elementToHighlight : objects) {
                        EObject element = null;
                        if (next instanceof Node) {
                            element = ((Node) next).getElement();
                        } else if (next instanceof Edge) {
                            element = ((Edge) next).getElement();
                        }
                        if (element == null) {
                            // next instanceof BasicDecorationNode || next instanceof Shape
                            continue;
                        }
                        if (EcoreUtil.getURI(elementToHighlight).equals(EcoreUtil.getURI(element))) {
                            if (next instanceof Node) {
                                ShapeStyle style = (ShapeStyle) ((Node) next).getStyle(NotationPackage.Literals.SHAPE_STYLE);
                                if (style != null) {
                                    style.setFillColor(background);
                                    style.setLineColor(foreGround);
                                }
                            } else if (next instanceof Edge) {
                                ConnectorStyle style = (ConnectorStyle) ((View) next).getStyle(NotationPackage.Literals.CONNECTOR_STYLE);
                                if (style != null) {
                                    style.setLineColor(transitionActive);
                                }
                            }
                        }
                    }
                }
            }
            return CommandResult.newOKCommandResult();
        }
    };
    try {
        cmd.execute(new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Color(org.eclipse.swt.graphics.Color) Node(org.eclipse.gmf.runtime.notation.Node) AbstractTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand) RGB(org.eclipse.swt.graphics.RGB) View(org.eclipse.gmf.runtime.notation.View) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConnectorStyle(org.eclipse.gmf.runtime.notation.ConnectorStyle) EObject(org.eclipse.emf.ecore.EObject) ShapeStyle(org.eclipse.gmf.runtime.notation.ShapeStyle) ExecutionException(org.eclipse.core.commands.ExecutionException) Edge(org.eclipse.gmf.runtime.notation.Edge)

Example 4 with Edge

use of org.eclipse.gmf.runtime.notation.Edge in project statecharts by Yakindu.

the class ExtractSubdiagramRefactoring method createEntryExitPoints.

@SuppressWarnings("unchecked")
protected void createEntryExitPoints(Diagram subdiagram) {
    TreeIterator<EObject> eAllContents = subdiagram.eAllContents();
    List<Edge> entryPointsToCreate = new ArrayList<Edge>();
    List<Edge> exitPointstoCreate = new ArrayList<Edge>();
    while (eAllContents.hasNext()) {
        EObject next = eAllContents.next();
        if (next instanceof View) {
            EList<Edge> targetEdges = ((View) next).getTargetEdges();
            for (Edge edge : targetEdges) {
                if (!EcoreUtil.isAncestor(subdiagram, edge.getSource()))
                    entryPointsToCreate.add(edge);
            }
            EList<Edge> sourceEdges = ((View) next).getSourceEdges();
            for (Edge edge : sourceEdges) {
                if (!EcoreUtil.isAncestor(subdiagram, edge.getTarget()))
                    exitPointstoCreate.add(edge);
            }
        }
    }
    for (Edge edge : entryPointsToCreate) {
        createEntryPoint(edge, subdiagram);
    }
    for (Edge edge : exitPointstoCreate) {
        createExitPoint(edge, subdiagram);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) Edge(org.eclipse.gmf.runtime.notation.Edge) View(org.eclipse.gmf.runtime.notation.View)

Example 5 with Edge

use of org.eclipse.gmf.runtime.notation.Edge in project statecharts by Yakindu.

the class NotationClipboardOperationHelper method getOverrideChildPasteOperation.

/**
 * By default, don't provide any child paste override behaviour.
 *
 * @return <code>null</code>, always
 */
public OverridePasteChildOperation getOverrideChildPasteOperation(PasteChildOperation overriddenChildPasteOperation) {
    if (shouldAllowPaste(overriddenChildPasteOperation)) {
        EObject eObject = overriddenChildPasteOperation.getEObject();
        if (eObject instanceof org.eclipse.gmf.runtime.notation.Node) {
            org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) eObject;
            EObject element = node.getElement();
            if ((element != null)) {
                return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, true);
            } else {
                return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, false);
            }
        } else if (eObject instanceof Edge) {
            return new ConnectorViewPasteOperation(overriddenChildPasteOperation);
        } else if (eObject instanceof Diagram) {
            return new DiagramPasteOperation(overriddenChildPasteOperation);
        }
    }
    return null;
}
Also used : Diagram(org.eclipse.gmf.runtime.notation.Diagram) EObject(org.eclipse.emf.ecore.EObject) Edge(org.eclipse.gmf.runtime.notation.Edge)

Aggregations

Edge (org.eclipse.gmf.runtime.notation.Edge)10 View (org.eclipse.gmf.runtime.notation.View)6 EObject (org.eclipse.emf.ecore.EObject)5 Diagram (org.eclipse.gmf.runtime.notation.Diagram)3 Node (org.eclipse.gmf.runtime.notation.Node)3 ArrayList (java.util.ArrayList)2 ConnectorStyle (org.eclipse.gmf.runtime.notation.ConnectorStyle)2 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Point (org.eclipse.draw2d.geometry.Point)1 PointList (org.eclipse.draw2d.geometry.PointList)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 AbstractTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand)1 LayoutConstraint (org.eclipse.gmf.runtime.notation.LayoutConstraint)1