Search in sources :

Example 16 with IGraphicalEditPart

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

the class BarResizeEditPolicy method getResizeCommand.

@Override
protected Command getResizeCommand(final ChangeBoundsRequest request) {
    GraphicalEditPart editPart = (IGraphicalEditPart) getHost();
    Rectangle locationAndSize = new PrecisionRectangle(editPart.getFigure().getBounds());
    editPart.getFigure().translateToAbsolute(locationAndSize);
    final Rectangle origRequestedBounds = request.getTransformedRectangle(locationAndSize);
    final Rectangle modified = origRequestedBounds.getCopy();
    checkAndPrepareConstraint(request, modified);
    // final Dimension sizeDelta = request.getSizeDelta();
    Dimension newDelta = new Dimension(modified.width - locationAndSize.width, modified.height - locationAndSize.height);
    // ((IGraphicalEditPart) getHost()).getFigure()
    // .translateToAbsolute(newDelta);
    request.setSizeDelta(newDelta);
    final Point moveDelta = request.getMoveDelta();
    request.setMoveDelta(new Point(moveDelta.x - origRequestedBounds.x + modified.x, moveDelta.y - origRequestedBounds.y + modified.y));
    return super.getResizeCommand(request);
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Rectangle(org.eclipse.draw2d.geometry.Rectangle) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 17 with IGraphicalEditPart

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

the class InitializeTreeNodeAnnotationsCommand method annotateElements.

private CompositeTransactionalCommand annotateElements(List<IGraphicalEditPart> elements) {
    final CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(getEditingDomain(), "AnnotateChildren");
    cmd.add(new SetTreeNodesPositionAnnotationCommand(getEditingDomain(), TreeLayoutUtil.getViews(elements)));
    for (final IGraphicalEditPart editPart : elements) {
        final List<IGraphicalEditPart> children = TreeLayoutUtil.getOrderedTreeChildren(editPart);
        if (!children.isEmpty()) {
            cmd.add(annotateElements(children));
        }
    }
    return cmd;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)

Example 18 with IGraphicalEditPart

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

the class UpdateAnnotationsOnReorientRelationshipCommand method doExecuteWithResult.

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    // Update annotations of old connection end;
    final IGraphicalEditPart oldEnd = UIUtils.getEditPart(request.getOldRelationshipEnd());
    if (oldEnd != null) {
        final List<IGraphicalEditPart> treeChildren = TreeLayoutUtil.getOrderedTreeChildren(oldEnd);
        treeChildren.remove(sourceEditPart);
        TreeLayoutUtil.setTreeNodesPositionAnnotation(TreeLayoutUtil.getViews(treeChildren));
    }
    // Update annotations of new connection end;
    final IGraphicalEditPart newEnd = UIUtils.getEditPart(request.getNewRelationshipEnd());
    if (newEnd != null) {
        final List<IGraphicalEditPart> treeChildren = TreeLayoutUtil.getOrderedTreeChildren(newEnd);
        treeChildren.add(sourceEditPart);
        TreeLayoutUtil.setTreeNodesPositionAnnotation(TreeLayoutUtil.getViews(treeChildren));
        // Update parentAnnotation to new end
        TreeLayoutUtil.setTreeNodeParentAnnotation(sourceEditPart.getNotationView(), newEnd.getNotationView());
    }
    return CommandResult.newOKCommandResult();
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 19 with IGraphicalEditPart

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

the class EnlargeContainerEditPolicy method showChildrenFeedback.

@SuppressWarnings("unchecked")
protected /**
 * containerFeedbackBounds as absolute
 *
 * @param containerEditPart
 * @param containerFigure
 * @param containerFeedbackBounds
 */
void showChildrenFeedback(final IGraphicalEditPart containerEditPart, final IFigure containerFigure, final Rectangle containerFeedbackBounds, ChangeBoundsRequest request) {
    Rectangle originalBounds = getOriginalBounds(containerFigure);
    Point moveDelta = new Point(containerFeedbackBounds.width - originalBounds.width, containerFeedbackBounds.height - originalBounds.height);
    List<IGraphicalEditPart> children = containerEditPart.getParent().getChildren();
    for (IGraphicalEditPart childPart : children) {
        if (request.getEditParts().contains(childPart)) {
            continue;
        }
        if (childPart == containerEditPart)
            continue;
        showChildFeedback(childPart, moveDelta, containerFeedbackBounds);
    }
}
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)

Example 20 with IGraphicalEditPart

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

the class EnlargeContainerEditPolicy method collectContainerHierachy.

protected List<IGraphicalEditPart> collectContainerHierachy() {
    List<IGraphicalEditPart> result = new ArrayList<IGraphicalEditPart>();
    IGraphicalEditPart containerEditPart = (IGraphicalEditPart) getHost();
    while (containerEditPart != null) {
        containerEditPart = getContainer(containerEditPart);
        if (containerEditPart != null)
            result.add(containerEditPart);
    }
    return result;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ArrayList(java.util.ArrayList)

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