Search in sources :

Example 1 with GraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart in project statecharts by Yakindu.

the class GroupStatesIntoCompositeRefactoring method setContextStates.

protected void setContextStates() {
    contextStates = Lists.newArrayList();
    List<GraphicalEditPart> contextObjects = getContextObjects();
    for (GraphicalEditPart editPart : contextObjects) {
        EObject element = editPart.resolveSemanticElement();
        contextStates.add((State) element);
    }
}
Also used : EObject(org.eclipse.emf.ecore.EObject) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 2 with GraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart in project statecharts by Yakindu.

the class GroupStatesIntoCompositeRefactoring method moveSelectedStateNodesTo.

protected void moveSelectedStateNodesTo(View containerView, Bounds compositeBounds) {
    for (GraphicalEditPart editPart : getContextObjects()) {
        Node stateNode = (Node) editPart.getNotationView();
        ViewUtil.insertChildView(containerView, stateNode, ViewUtil.APPEND, true);
        Bounds newBounds = NotationFactory.eINSTANCE.createBounds();
        Bounds oldBounds = (Bounds) stateNode.getLayoutConstraint();
        // FIXME use bounds of region view
        newBounds.setX(oldBounds.getX() - compositeBounds.getX() - 7);
        // FIXME use bounds of region view
        newBounds.setY(oldBounds.getY() - compositeBounds.getY() - 34);
        ((Node) editPart.getNotationView()).setLayoutConstraint(newBounds);
    }
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) Bounds(org.eclipse.gmf.runtime.notation.Bounds) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 3 with GraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart in project statecharts by Yakindu.

the class TransitionPriorityDecorationProvider method createDecorators.

@Override
public void createDecorators(IDecoratorTarget decoratorTarget) {
    EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
    if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) {
        EditDomain ed = editPart.getViewer().getEditDomain();
        if (!(ed instanceof DiagramEditDomain)) {
            return;
        }
        if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof TransitionEditPart) {
            IDecorator decorator = createStatusDecorator(decoratorTarget);
            decorators.add(decorator);
            decoratorTarget.installDecorator(getDecoratorKey(), decorator);
        }
    }
}
Also used : AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) TransitionEditPart(org.yakindu.sct.ui.editor.editparts.TransitionEditPart) DiagramEditDomain(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) EditDomain(org.eclipse.gef.EditDomain) TransitionEditPart(org.yakindu.sct.ui.editor.editparts.TransitionEditPart) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) DiagramEditDomain(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IDecorator(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator)

Example 4 with GraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart in project statecharts by Yakindu.

the class RegionPriorityDecorationProvider method createDecorators.

@Override
public void createDecorators(IDecoratorTarget decoratorTarget) {
    EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
    if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) {
        EditDomain ed = editPart.getViewer().getEditDomain();
        if (!(ed instanceof DiagramEditDomain)) {
            return;
        }
        if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof RegionEditPart) {
            IDecorator decorator = createStatusDecorator(decoratorTarget);
            decorators.add(decorator);
            decoratorTarget.installDecorator(getDecoratorKey(), decorator);
        }
    }
}
Also used : AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) DiagramEditDomain(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) EditDomain(org.eclipse.gef.EditDomain) RegionEditPart(org.yakindu.sct.ui.editor.editparts.RegionEditPart) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) AbstractConnectionEditPart(org.eclipse.gef.editparts.AbstractConnectionEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) DiagramEditDomain(org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain) RegionEditPart(org.yakindu.sct.ui.editor.editparts.RegionEditPart) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) IDecorator(org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator)

Example 5 with GraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart in project statecharts by Yakindu.

the class GroupStatesIntoCompositeRefactoring method setCompositeStateLayoutConstraint.

/**
 * Iterates through all {@link StateEditPart}s of the current selection and
 * computes layout constraints for the composite node.
 *
 * @param compositeStateNode
 *            node of the composite state
 */
protected void setCompositeStateLayoutConstraint(Node compositeStateNode) {
    Rectangle newbounds = null;
    for (GraphicalEditPart editPart : getContextObjects()) {
        Rectangle childBounds = editPart.getFigure().getBounds();
        if (newbounds == null)
            newbounds = childBounds.getCopy();
        newbounds.union(childBounds);
    }
    newbounds.expand(new Insets(PADDING, PADDING, PADDING, PADDING));
    Bounds bounds = NotationFactory.eINSTANCE.createBounds();
    bounds.setX(newbounds.x);
    bounds.setY(newbounds.y);
    bounds.setWidth(newbounds.width);
    bounds.setHeight(newbounds.height);
    compositeStateNode.setLayoutConstraint(bounds);
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Bounds(org.eclipse.gmf.runtime.notation.Bounds) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Aggregations

GraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart)6 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)5 EditDomain (org.eclipse.gef.EditDomain)2 EditPart (org.eclipse.gef.EditPart)2 AbstractConnectionEditPart (org.eclipse.gef.editparts.AbstractConnectionEditPart)2 DiagramEditDomain (org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditDomain)2 IDecorator (org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator)2 Bounds (org.eclipse.gmf.runtime.notation.Bounds)2 Insets (org.eclipse.draw2d.geometry.Insets)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 EObject (org.eclipse.emf.ecore.EObject)1 Node (org.eclipse.gmf.runtime.notation.Node)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 RegionEditPart (org.yakindu.sct.ui.editor.editparts.RegionEditPart)1 TransitionEditPart (org.yakindu.sct.ui.editor.editparts.TransitionEditPart)1