Search in sources :

Example 16 with Node

use of org.eclipse.gmf.runtime.notation.Node in project InformationSystem by ObeoNetwork.

the class RequirementsServices method isBorderedNode.

/**
 * Checks whether a DNode is a bordered node
 * @param semanticDecorator
 * @return
 */
private boolean isBorderedNode(DSemanticDecorator semanticDecorator) {
    if (semanticDecorator instanceof DNode) {
        Collection<EObject> inverseReferences = new EObjectQuery((DNode) semanticDecorator).getInverseReferences(org.eclipse.gmf.runtime.notation.NotationPackage.Literals.VIEW__ELEMENT);
        Iterator<EObject> iterator = inverseReferences.iterator();
        if (iterator.hasNext()) {
            EObject next = iterator.next();
            if (next instanceof Node) {
                return new NodeQuery((Node) next).isBorderedNode();
            }
        }
    }
    return false;
}
Also used : EObjectQuery(org.eclipse.sirius.diagram.business.api.query.EObjectQuery) DNode(org.eclipse.sirius.diagram.DNode) EObject(org.eclipse.emf.ecore.EObject) Node(org.eclipse.gmf.runtime.notation.Node) DNode(org.eclipse.sirius.diagram.DNode) NodeQuery(org.eclipse.sirius.diagram.ui.business.api.query.NodeQuery)

Example 17 with Node

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

the class PositionalGeneralViewPasteOperation method getPostPasteOperation.

public PasteChildOperation getPostPasteOperation() {
    return new PostPasteChildOperation(this, EMPTY_ARRAY) {

        public void paste() throws Exception {
            // unset connectors before pasting so that it won't affect
            // real connectors especially if they happen to belong to the
            // same
            // target diagram
            Node view = (Node) getEObject();
            view.eUnset(NotationPackage.eINSTANCE.getView_SourceEdges());
            view.eUnset(NotationPackage.eINSTANCE.getView_TargetEdges());
            // now paste view
            EObject pastedElement = doPasteInto(getParentEObject());
            // did we succeed?
            if (pastedElement != null) {
                setPastedElement(pastedElement);
                addPastedElement(pastedElement);
            } else {
                addPasteFailuresObject(getEObject());
            }
        }

        protected boolean shouldPasteAlwaysCopyObject(ObjectInfo alwaysCopyObjectInfo) {
            return PositionalGeneralViewPasteOperation.this.shouldPasteAlwaysCopyObject(alwaysCopyObjectInfo);
        }

        /*
			 * (non-Javadoc)
			 * 
			 * @see org.eclipse.gmf.runtime.emf.core.internal.copypaste.
			 * PasteChildOperation
			 * #makeAuxiliaryChildPasteProcess(org.eclipse.gmf
			 * .runtime.emf.core.internal.copypaste.ObjectInfo)
			 */
        @SuppressWarnings("restriction")
        protected PasteChildOperation makeAuxiliaryChildPasteProcess(ObjectInfo auxiliaryChildEObjectInfo) {
            EObject semanticPasteTarget = NotationClipboardOperationHelper.getSemanticPasteTarget((View) getPastedElement());
            if (semanticPasteTarget == null) {
                return null;
            }
            return new PasteChildOperation(getParentPasteProcess().clone(semanticPasteTarget), auxiliaryChildEObjectInfo);
        }

        public PasteChildOperation getPostPasteOperation() {
            List operations = getAlwaysCopyObjectPasteOperations();
            return new PostPasteChildOperation(this, operations);
        }
    };
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) EObject(org.eclipse.emf.ecore.EObject) PostPasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation) PasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PasteChildOperation) OverridePasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.OverridePasteChildOperation) List(java.util.List) PostPasteChildOperation(org.eclipse.gmf.runtime.emf.clipboard.core.PostPasteChildOperation) ObjectInfo(org.eclipse.gmf.runtime.emf.clipboard.core.ObjectInfo)

Example 18 with Node

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

the class CreateSubdiagramCommand method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    Node state = unwrap(HandlerUtil.getCurrentSelection(event));
    if (state == null)
        return null;
    CreateSubDiagramCommand cmd = new CreateSubDiagramCommand(state);
    executeCommand(cmd);
    return null;
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node)

Example 19 with Node

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

the class SetLabelsOffsetOperation method updateGMFLabelsOffset.

/**
 * Update the offset ({@link Bounds}) of the labels {@link Node}. This method
 * must be called after setting the newPointList and the labelToUpdate. If the
 * methods {@link #setLabelsToUpdate(ConnectionEditPart)} or
 * {@link #setLabelsToUpdate(ConnectionEditPart, PointList)} are not called,
 * this method has no effect.
 */
public void updateGMFLabelsOffset() {
    if (labelsWithNewOffset != null) {
        // Update Bounds of the three labels Node (Center, Begin and End)
        Set<Entry<Node, Point>> entries = labelsWithNewOffset.entrySet();
        for (Entry<Node, Point> entry : entries) {
            LayoutConstraint layoutConstraint = entry.getKey().getLayoutConstraint();
            if (layoutConstraint instanceof Location) {
                Location bounds = (Location) layoutConstraint;
                bounds.setX(entry.getValue().x);
                bounds.setY(entry.getValue().y);
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) Node(org.eclipse.gmf.runtime.notation.Node) LayoutConstraint(org.eclipse.gmf.runtime.notation.LayoutConstraint) Point(org.eclipse.draw2d.geometry.Point) Location(org.eclipse.gmf.runtime.notation.Location)

Example 20 with Node

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

the class SetLabelsOffsetOperation method computeGMFLabelOffset.

/**
 * Update {@link Bounds} of a label {@link Node}.
 *
 * @param labelEdgeEditPart
 *            the editPart of the edge label to be updated
 * @param connectionEditPart
 *            The connection having these labels
 */
private void computeGMFLabelOffset(LabelEditPart labelEditPartToUpdate, ConnectionEditPart connectionEditPart) {
    Point newLabelOffset = null;
    Node labelNodeToUpdate = (Node) labelEditPartToUpdate.getModel();
    if (connectionEditPart.getModel() instanceof Edge) {
        PointList oldBendpoints = oldBendPointsList;
        if (oldBendpoints == null) {
            oldBendpoints = connectionEditPart.getConnectionFigure().getPoints();
        }
        boolean isEdgeWithObliqueRoutingStyle = isEdgeWithObliqueRoutingStyle(connectionEditPart);
        LayoutConstraint layoutConstraint = labelNodeToUpdate.getLayoutConstraint();
        if (layoutConstraint instanceof Location) {
            Location point = (Location) layoutConstraint;
            newLabelOffset = new EdgeLabelQuery(oldBendpoints, newPointList, isEdgeWithObliqueRoutingStyle, new Point(point.getX(), point.getY()), labelEditPartToUpdate.getFigure().getSize(), labelEditPartToUpdate.getKeyPoint(), false).calculateGMFLabelOffset();
        }
    }
    if (newLabelOffset != null) {
        labelsWithNewOffset.put(labelNodeToUpdate, newLabelOffset);
    }
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) EdgeLabelQuery(org.yakindu.base.xtext.utils.gmf.routing.EdgeLabelQuery) Node(org.eclipse.gmf.runtime.notation.Node) LayoutConstraint(org.eclipse.gmf.runtime.notation.LayoutConstraint) Point(org.eclipse.draw2d.geometry.Point) Edge(org.eclipse.gmf.runtime.notation.Edge) Location(org.eclipse.gmf.runtime.notation.Location)

Aggregations

Node (org.eclipse.gmf.runtime.notation.Node)24 EObject (org.eclipse.emf.ecore.EObject)6 Location (org.eclipse.gmf.runtime.notation.Location)6 View (org.eclipse.gmf.runtime.notation.View)6 State (org.yakindu.sct.model.sgraph.State)4 IMapMode (org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode)3 Bounds (org.eclipse.gmf.runtime.notation.Bounds)3 Diagram (org.eclipse.gmf.runtime.notation.Diagram)3 Edge (org.eclipse.gmf.runtime.notation.Edge)3 Region (org.yakindu.sct.model.sgraph.Region)3 Transition (org.yakindu.sct.model.sgraph.Transition)3 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 Point (org.eclipse.draw2d.geometry.Point)2 LayoutConstraint (org.eclipse.gmf.runtime.notation.LayoutConstraint)2 ShapeStyle (org.eclipse.gmf.runtime.notation.ShapeStyle)2 Entry (org.yakindu.sct.model.sgraph.Entry)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1