Search in sources :

Example 11 with ICommandProxy

use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.

the class CompartmentLayoutEditPolicy method getCreateCommand.

@SuppressWarnings("unchecked")
@Override
protected Command getCreateCommand(CreateRequest request) {
    if (request instanceof CreateViewAndElementRequest) {
        TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
        CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label);
        Iterator<?> descriptors = ((CreateViewRequest) request).getViewDescriptors().iterator();
        while (descriptors.hasNext()) {
            CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors.next();
            int feedBackIndex = getFeedbackIndexFor(request);
            // obtain CreateElementRequest and add initial region feedback
            // index to request map. This index is needed to add the
            // semantic element at the correct listIndex
            CreateElementRequest createElementRequest = (CreateElementRequest) ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter().getAdapter(CreateElementRequest.class);
            if (createElementRequest != null) {
                createElementRequest.getParameters().put(RequestParameterKeys.RegionFeedbackIndex, feedBackIndex);
            }
            CreateCommand createCommand = new CompartmentChildCreateCommand(editingDomain, descriptor, (View) (getHost().getModel()), feedBackIndex);
            cc.compose(createCommand);
        }
        return new ICommandProxy(cc.reduce());
    }
    return null;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) CompartmentChildCreateCommand(org.yakindu.base.gmf.runtime.commands.CompartmentChildCreateCommand) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CompartmentChildCreateCommand(org.yakindu.base.gmf.runtime.commands.CompartmentChildCreateCommand) CreateCommand(org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand) CreateElementRequest(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) CreateViewAndElementRequest(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) CreateViewRequest(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)

Example 12 with ICommandProxy

use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project statecharts by Yakindu.

the class CompartmentLayoutEditPolicy method createAddCommand.

@Override
protected Command createAddCommand(EditPart child, EditPart after) {
    int index = getHost().getChildren().indexOf(after);
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    AddCommand command = new CompartmentAddCommand(editingDomain, new EObjectAdapter((View) getHost().getModel()), new EObjectAdapter((View) child.getModel()), index);
    return new ICommandProxy(command);
}
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) EObjectAdapter(org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter) View(org.eclipse.gmf.runtime.notation.View) AddCommand(org.eclipse.gmf.runtime.diagram.core.commands.AddCommand)

Example 13 with ICommandProxy

use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy 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 14 with ICommandProxy

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

ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)14 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)7 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)6 Command (org.eclipse.gef.commands.Command)3 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)3 EObjectAdapter (org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter)3 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)2 ICommand (org.eclipse.gmf.runtime.common.core.command.ICommand)2 CreateViewAndElementRequest (org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest)2 CompositeTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)2 SetValueCommand (org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand)2 SetRequest (org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)2 View (org.eclipse.gmf.runtime.notation.View)2 SetConnectionBendpointsAndLabelCommmand (org.yakindu.sct.ui.editor.commands.SetConnectionBendpointsAndLabelCommmand)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1 IFigure (org.eclipse.draw2d.IFigure)1 Point (org.eclipse.draw2d.geometry.Point)1 PointList (org.eclipse.draw2d.geometry.PointList)1 EObject (org.eclipse.emf.ecore.EObject)1