Search in sources :

Example 1 with AlignmentRequest

use of org.eclipse.gef.requests.AlignmentRequest in project statecharts by Yakindu.

the class TreeLayoutEditPolicy method getConstraintFor.

@Override
protected Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child) {
    if (request instanceof AlignmentRequest) {
        return super.getConstraintFor(request, child);
    }
    final Rectangle rect = (Rectangle) super.getConstraintFor(request, child);
    final Rectangle cons = getCurrentConstraintFor(child);
    final int newTreePosition = TreeLayoutUtil.getNewTreeNodePosition(request.getLocation(), TreeLayoutUtil.getSiblings((IGraphicalEditPart) child));
    if (cons instanceof TreeLayoutConstraint) {
        final TreeLayoutConstraint treeLayoutConstraint = (TreeLayoutConstraint) cons;
        return new TreeLayoutConstraint(rect, treeLayoutConstraint.isRoot(), newTreePosition);
    }
    return new TreeLayoutConstraint(rect, false, newTreePosition);
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) AlignmentRequest(org.eclipse.gef.requests.AlignmentRequest) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with AlignmentRequest

use of org.eclipse.gef.requests.AlignmentRequest in project archi by archimatetool.

the class AlignmentAction method createAlignmentCommand.

private Command createAlignmentCommand() {
    AlignmentRequest request = new AlignmentRequest(RequestConstants.REQ_ALIGN);
    request.setAlignmentRectangle(calculateAlignmentRectangle(request));
    request.setAlignment(alignment);
    List editparts = getOperationSet(request);
    if (editparts.size() < 2)
        return null;
    CompoundCommand command = new CompoundCommand();
    command.setDebugLabel(getText());
    for (int i = 0; i < editparts.size(); i++) {
        EditPart editpart = (EditPart) editparts.get(i);
        command.add(editpart.getCommand(request));
    }
    return command;
}
Also used : AlignmentRequest(org.eclipse.gef.requests.AlignmentRequest) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) List(java.util.List) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 3 with AlignmentRequest

use of org.eclipse.gef.requests.AlignmentRequest in project archi by archimatetool.

the class NonResizableEditPolicy method getAlignCommand.

/**
 * Returns the command contribution to an alignment request
 *
 * @param request
 *            the alignment request
 * @return the contribution to the alignment
 */
protected Command getAlignCommand(AlignmentRequest request) {
    AlignmentRequest req = new AlignmentRequest(REQ_ALIGN_CHILDREN);
    req.setEditParts(getHost());
    req.setAlignment(request.getAlignment());
    req.setAlignmentRectangle(request.getAlignmentRectangle());
    return getHost().getParent().getCommand(req);
}
Also used : AlignmentRequest(org.eclipse.gef.requests.AlignmentRequest)

Aggregations

AlignmentRequest (org.eclipse.gef.requests.AlignmentRequest)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)1 Point (org.eclipse.draw2d.geometry.Point)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 EditPart (org.eclipse.gef.EditPart)1 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)1 TreeLayoutConstraint (org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint)1