Search in sources :

Example 1 with ICommandProxy

use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project tdi-studio-se by Talend.

the class BusinessItemDragDropEditPolicy method getDropObjectsCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy#getDropObjectsCommand(org.eclipse.gmf
     * .runtime.diagram.ui.requests.DropObjectsRequest)
     */
@Override
public Command getDropObjectsCommand(DropObjectsRequest dropObjectsRequest) {
    BusinessItem businessItem = new ElementHelper().getElement(getHost());
    if (businessItem != null) {
        CreateAssignmentCommand createAssignmentCommand = new CreateAssignmentCommand(((IGraphicalEditPart) getHost()).getEditingDomain());
        createAssignmentCommand.setBusinessItem(businessItem);
        createAssignmentCommand.setItems(dropObjectsRequest.getObjects());
        return new ICommandProxy(createAssignmentCommand);
    }
    return UnexecutableCommand.INSTANCE;
}
Also used : ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CreateAssignmentCommand(org.talend.designer.business.diagram.custom.commands.CreateAssignmentCommand) BusinessItem(org.talend.designer.business.model.business.BusinessItem) ElementHelper(org.talend.designer.business.diagram.custom.util.ElementHelper)

Example 2 with ICommandProxy

use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project tdi-studio-se by Talend.

the class BusinessProcessCanonicalEditPolicy method refreshSemantic.

/**
     * @generated
     */
protected void refreshSemantic() {
    List createdViews = new LinkedList();
    createdViews.addAll(refreshSemanticChildren());
    List createdConnectionViews = new LinkedList();
    createdConnectionViews.addAll(refreshSemanticConnections());
    createdConnectionViews.addAll(refreshConnections());
    if (createdViews.size() > 1) {
        // perform a layout of the container
        DeferredLayoutCommand layoutCmd = new DeferredLayoutCommand(host().getEditingDomain(), createdViews, host());
        executeCommand(new ICommandProxy(layoutCmd));
    }
    createdViews.addAll(createdConnectionViews);
    makeViewsImmutable(createdViews);
}
Also used : ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList) DeferredLayoutCommand(org.eclipse.gmf.runtime.diagram.ui.commands.DeferredLayoutCommand)

Example 3 with ICommandProxy

use of org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy in project tdi-studio-se by Talend.

the class BusinessBaseItemSemanticEditPolicy method getSemanticCommand.

/**
     * @generated
     */
protected Command getSemanticCommand(IEditCommandRequest request) {
    IEditCommandRequest completedRequest = completeRequest(request);
    Object editHelperContext = completedRequest.getEditHelperContext();
    if (editHelperContext instanceof View || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) {
        // no semantic commands are provided for pure design elements
        return null;
    }
    if (editHelperContext == null) {
        editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel());
    }
    IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext);
    if (elementType == ElementTypeRegistry.getInstance().getType("org.eclipse.gmf.runtime.emf.type.core.default")) {
        //$NON-NLS-1$ 
        elementType = null;
    }
    Command epCommand = getSemanticCommandSwitch(completedRequest);
    if (epCommand != null) {
        ICommand command = epCommand instanceof ICommandProxy ? ((ICommandProxy) epCommand).getICommand() : new CommandProxy(epCommand);
        completedRequest.setParameter(BusinessBaseEditHelper.EDIT_POLICY_COMMAND, command);
    }
    Command ehCommand = null;
    if (elementType != null) {
        ICommand command = elementType.getEditCommand(completedRequest);
        if (command != null) {
            if (!(command instanceof CompositeTransactionalCommand)) {
                TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
                command = new CompositeTransactionalCommand(editingDomain, null).compose(command);
            }
            ehCommand = new ICommandProxy(command);
        }
    }
    boolean shouldProceed = true;
    if (completedRequest instanceof DestroyRequest) {
        shouldProceed = shouldProceed((DestroyRequest) completedRequest);
    }
    if (shouldProceed) {
        if (completedRequest instanceof DestroyRequest) {
            TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
            Command deleteViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View) getHost().getModel()));
            ehCommand = ehCommand == null ? deleteViewCommand : ehCommand.chain(deleteViewCommand);
        }
        return ehCommand;
    }
    return null;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) DestroyRequest(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyRequest) IEditCommandRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) View(org.eclipse.gmf.runtime.notation.View) IElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType) DeleteCommand(org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy) IEditHelperContext(org.eclipse.gmf.runtime.emf.type.core.IEditHelperContext) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) CompositeTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand) UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) DeleteCommand(org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand) Command(org.eclipse.gef.commands.Command) ICommand(org.eclipse.gmf.runtime.common.core.command.ICommand) EObject(org.eclipse.emf.ecore.EObject)

Example 4 with ICommandProxy

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

the class CompartmentLayoutEditPolicy method createMoveChildCommand.

@Override
@SuppressWarnings("rawtypes")
protected Command createMoveChildCommand(EditPart child, EditPart after) {
    int newIndex;
    int displacement;
    int childIndex = getHost().getChildren().indexOf(child);
    int afterIndex = getHost().getChildren().indexOf(after);
    if (afterIndex == -1) {
        newIndex = getHost().getChildren().size() - 1;
        displacement = newIndex - childIndex;
    } else {
        newIndex = afterIndex;
        displacement = afterIndex - childIndex;
        if (childIndex <= afterIndex) {
            newIndex--;
            displacement--;
        }
    }
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    RepositionEObjectCommand command = new CompartmentRepositionEObjectCommand(child, editingDomain, "", (EList) ((View) child.getParent().getModel()).getElement().eGet(feature), ((View) child.getModel()).getElement(), displacement, newIndex);
    eraseLayoutTargetFeedback(null);
    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) CompartmentRepositionEObjectCommand(org.yakindu.base.gmf.runtime.commands.CompartmentRepositionEObjectCommand) RepositionEObjectCommand(org.eclipse.gmf.runtime.emf.commands.core.commands.RepositionEObjectCommand) CompartmentRepositionEObjectCommand(org.yakindu.base.gmf.runtime.commands.CompartmentRepositionEObjectCommand)

Example 5 with ICommandProxy

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

the class TreeLayoutEditPolicy method getCreateCommand.

@Override
protected Command getCreateCommand(CreateRequest request) {
    final CompoundCommand cmd = new CompoundCommand();
    cmd.add(super.getCreateCommand(request));
    if (request instanceof CreateViewAndElementRequest) {
        final CreateViewAndElementRequest req = (CreateViewAndElementRequest) request;
        if (shouldUpdateAnnotationsOnCreation(req)) {
            cmd.add(new ICommandProxy(new UpdateAnnotationsOnCreationCommand(getHost().getEditingDomain(), req)));
        }
    }
    return cmd;
}
Also used : ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) CreateViewAndElementRequest(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) UpdateAnnotationsOnCreationCommand(org.yakindu.base.gmf.runtime.treelayout.commands.UpdateAnnotationsOnCreationCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

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