Search in sources :

Example 21 with Node

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

the class ExtractSubdiagramRefactoring method setPreferredSize.

protected void setPreferredSize() {
    Node node = (Node) getContextObject();
    Bounds bounds = (Bounds) node.getLayoutConstraint();
    bounds.setWidth(-1);
    bounds.setHeight(-1);
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) Bounds(org.eclipse.gmf.runtime.notation.Bounds)

Example 22 with Node

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

the class ExtractSubdiagramRefactoring method createSubdiagram.

/**
 * Creates a new {@link Diagram} and copies child elements
 */
protected Diagram createSubdiagram() {
    View contextView = getContextObject();
    State contextElement = (State) contextView.getElement();
    Diagram subdiagram = ViewService.createDiagram(contextElement, StatechartDiagramEditor.ID, preferencesHint);
    View figureCompartment = ViewUtil.getChildBySemanticHint(contextView, SemanticHints.STATE_FIGURE_COMPARTMENT);
    getResource().getContents().add(subdiagram);
    boolean isHorizontal = isHorizontal(figureCompartment);
    int offset = 0;
    int subregions = figureCompartment.getChildren().size();
    while (figureCompartment.getChildren().size() > 0) {
        Node child = (Node) figureCompartment.getChildren().get(0);
        if (subregions > 1) {
            Rectangle actualBounds = getActualBounds(child);
            if (actualBounds != Rectangle.SINGLETON) {
                Bounds modelBounds = (Bounds) child.getLayoutConstraint();
                modelBounds.setWidth(actualBounds.width());
                modelBounds.setHeight(actualBounds.height());
                if (isHorizontal) {
                    modelBounds.setX(offset);
                    offset += actualBounds.width();
                } else {
                    modelBounds.setY(offset);
                    offset += actualBounds.height();
                }
            }
        }
        subdiagram.insertChild(child);
    }
    return subdiagram;
}
Also used : State(org.yakindu.sct.model.sgraph.State) Node(org.eclipse.gmf.runtime.notation.Node) Bounds(org.eclipse.gmf.runtime.notation.Bounds) Rectangle(org.eclipse.draw2d.geometry.Rectangle) View(org.eclipse.gmf.runtime.notation.View) PreferencesHint(org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 23 with Node

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

the class ExtractSubdiagramRefactoring method createExitPoint.

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);
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) Node(org.eclipse.gmf.runtime.notation.Node) Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) View(org.eclipse.gmf.runtime.notation.View) Exit(org.yakindu.sct.model.sgraph.Exit)

Example 24 with Node

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

the class GroupStatesIntoCompositeRefactoring method createNodeForCompositeState.

protected Node createNodeForCompositeState(State compositeState) {
    Node compositeStateNode = ViewService.createNode(parentRegionView, compositeState, SemanticHints.STATE, preferencesHint);
    setCompositeStateLayoutConstraint(compositeStateNode);
    return compositeStateNode;
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node)

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