Search in sources :

Example 1 with SetBoundsCommand

use of org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand 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)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1 ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)1 SetBoundsCommand (org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 EObjectAdapter (org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter)1