Search in sources :

Example 41 with IGraphicalEditPart

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

the class EnlargeContainerEditPolicy method getCommand.

@SuppressWarnings("unchecked")
@Override
public Command getCommand(Request request) {
    if (!RequestConstants.REQ_RESIZE.equals(request.getType()) && !RequestConstants.REQ_MOVE.equals(request.getType())) {
        return null;
    }
    if (request instanceof SetPreferredSizeRequest) {
        showSourceFeedback(request);
    }
    ChangeBoundsRequest cbr = (ChangeBoundsRequest) request;
    CompoundCommand result = new CompoundCommand();
    // Update Bounds of the container hierachy
    for (IGraphicalEditPart currentContainer : containerHierachy) {
        IFigure figure = currentContainer.getFigure();
        SetBoundsCommand boundsCommand = new SetBoundsCommand(getHost().getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(currentContainer.getNotationView()), figure.getBounds());
        result.add(new ICommandProxy(boundsCommand));
        // Update child bounds of elements that stand in the way...
        List<IGraphicalEditPart> children = currentContainer.getParent().getChildren();
        for (IGraphicalEditPart childPart : children) {
            if (cbr.getEditParts().contains(childPart))
                continue;
            IFigure childFigure = childPart.getFigure();
            if (childPart == currentContainer)
                continue;
            SetBoundsCommand childBoundsCommand = new SetBoundsCommand(getHost().getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(childPart.getNotationView()), childFigure.getBounds());
            result.add(new ICommandProxy(childBoundsCommand));
        }
    }
    return result;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) SetBoundsCommand(org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand) EObjectAdapter(org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IFigure(org.eclipse.draw2d.IFigure)

Example 42 with IGraphicalEditPart

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

the class EnlargeContainerEditPolicy method showContainerFeedback.

protected void showContainerFeedback(ChangeBoundsRequest request) {
    for (int level = 1; level <= containerHierachy.size(); level++) {
        IGraphicalEditPart containerEditPart = containerHierachy.get(level - 1);
        IFigure containerFigure = containerEditPart.getFigure();
        Rectangle feedbackBounds = getOriginalBounds(containerFigure);
        containerFigure.getParent().translateToAbsolute(feedbackBounds);
        feedbackBounds = calculateFeedbackBounds(request, feedbackBounds, level, containerFigure);
        showChildrenFeedback(containerEditPart, containerFigure, feedbackBounds, request);
        containerFigure.translateToRelative(feedbackBounds);
        setBounds(containerFigure, feedbackBounds);
    }
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 43 with IGraphicalEditPart

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

the class InitialPointsConnectionBendpointEditPolicy method getBendpointsChangedCommand.

@Override
protected Command getBendpointsChangedCommand(Connection connection, Edge edge) {
    Point ptRef1 = connection.getSourceAnchor().getReferencePoint();
    getConnection().translateToRelative(ptRef1);
    Point ptRef2 = connection.getTargetAnchor().getReferencePoint();
    getConnection().translateToRelative(ptRef2);
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    SetConnectionBendpointsAndLabelCommmand sbbCommand = new SetConnectionBendpointsAndLabelCommmand(editingDomain);
    sbbCommand.setEdgeAdapter(new EObjectAdapter(edge));
    sbbCommand.setNewPointList(connection.getPoints(), ptRef1, ptRef2);
    return new ICommandProxy(sbbCommand);
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) SetConnectionBendpointsAndLabelCommmand(org.yakindu.sct.ui.editor.commands.SetConnectionBendpointsAndLabelCommmand) Point(org.eclipse.draw2d.geometry.Point) EObjectAdapter(org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter)

Aggregations

IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)43 ArrayList (java.util.ArrayList)10 EObject (org.eclipse.emf.ecore.EObject)10 View (org.eclipse.gmf.runtime.notation.View)10 List (java.util.List)8 Point (org.eclipse.draw2d.geometry.Point)8 Rectangle (org.eclipse.draw2d.geometry.Rectangle)7 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)7 ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)7 IFigure (org.eclipse.draw2d.IFigure)6 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)5 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)4 Command (org.eclipse.gef.commands.Command)4 CompositeTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)3 EObjectAdapter (org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter)3 IElementType (org.eclipse.gmf.runtime.emf.type.core.IElementType)3 Iterator (java.util.Iterator)2 Connection (org.eclipse.draw2d.Connection)2 RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2