Search in sources :

Example 76 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand 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 77 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.

the class MatchSizeAction method createMatchSizeCommand.

/**
 * Create a command to resize the selected objects.
 *
 * @param objects
 *            The objects to be resized.
 * @return The command to resize the selected objects.
 */
private Command createMatchSizeCommand(List objects) {
    if (objects.isEmpty())
        return null;
    if (!(objects.get(0) instanceof GraphicalEditPart))
        return null;
    GraphicalEditPart primarySelection = getPrimarySelectionEditPart(getSelectedObjects());
    if (primarySelection == null)
        return null;
    GraphicalEditPart part = null;
    ChangeBoundsRequest request = null;
    PrecisionDimension preciseDimension = null;
    PrecisionRectangle precisePartBounds = null;
    Command cmd = null;
    CompoundCommand command = new CompoundCommand();
    PrecisionRectangle precisePrimaryBounds = new PrecisionRectangle(primarySelection.getFigure().getBounds().getCopy());
    primarySelection.getFigure().translateToAbsolute(precisePrimaryBounds);
    for (int i = 0; i < objects.size(); i++) {
        part = (GraphicalEditPart) objects.get(i);
        if (!part.equals(primarySelection)) {
            request = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
            precisePartBounds = new PrecisionRectangle(part.getFigure().getBounds().getCopy());
            part.getFigure().translateToAbsolute(precisePartBounds);
            preciseDimension = new PrecisionDimension();
            preciseDimension.setPreciseWidth(getPreciseWidthDelta(precisePartBounds, precisePrimaryBounds));
            preciseDimension.setPreciseHeight(getPreciseHeightDelta(precisePartBounds, precisePrimaryBounds));
            request.setSizeDelta(preciseDimension);
            cmd = part.getCommand(request);
            if (cmd != null)
                command.add(cmd);
        }
    }
    return command;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) PrecisionDimension(org.eclipse.draw2d.geometry.PrecisionDimension) PrecisionRectangle(org.eclipse.draw2d.geometry.PrecisionRectangle) Command(org.eclipse.gef.commands.Command) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 78 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.

the class CommandsTests method testEObjectNonNotifyingCompoundCommand.

@Test
public void testEObjectNonNotifyingCompoundCommand() {
    final boolean[] execute = new boolean[1];
    model.eAdapters().add(new EContentAdapter() {

        @Override
        public void notifyChanged(Notification msg) {
            super.notifyChanged(msg);
            if (msg.getEventType() == EObjectNonNotifyingCompoundCommand.START) {
                assertEquals(model, msg.getNewValue());
                assertEquals(execute[0] ? "Archisurance" : "Hello3", model.getName());
            } else if (msg.getEventType() == EObjectNonNotifyingCompoundCommand.END) {
                assertEquals(model, msg.getNewValue());
                assertEquals(execute[0] ? "Hello3" : "Archisurance", model.getName());
            }
        }
    });
    CompoundCommand compoundCmd = new EObjectNonNotifyingCompoundCommand(model);
    compoundCmd.add(new EObjectFeatureCommand("Rename", model, IArchimatePackage.Literals.NAMEABLE__NAME, "Hello1"));
    compoundCmd.add(new EObjectFeatureCommand("Rename", model, IArchimatePackage.Literals.NAMEABLE__NAME, "Hello2"));
    compoundCmd.add(new EObjectFeatureCommand("Rename", model, IArchimatePackage.Literals.NAMEABLE__NAME, "Hello3"));
    execute[0] = true;
    compoundCmd.execute();
    execute[0] = false;
    compoundCmd.undo();
    execute[0] = true;
    compoundCmd.redo();
}
Also used : Notification(org.eclipse.emf.common.notify.Notification) EContentAdapter(org.eclipse.emf.ecore.util.EContentAdapter) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Test(org.junit.Test)

Example 79 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand in project whole by wholeplatform.

the class WholeDragEditPartsTracker method getCommand.

protected Command getCommand() {
    if (!isShareActive())
        return super.getCommand();
    CompoundCommand command = new CompoundCommand();
    // $NON-NLS-1$
    command.setDebugLabel("Drag Object Tracker");
    Request request = getTargetRequest();
    request.setType(REQ_SHARE);
    if (!isMove()) {
        if (getTargetEditPart() == null)
            command.add(UnexecutableCommand.INSTANCE);
        else
            command.add(getTargetEditPart().getCommand(getTargetRequest()));
    }
    return command;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) Request(org.eclipse.gef.Request) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 80 with CompoundCommand

use of org.eclipse.gef.commands.CompoundCommand 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

CompoundCommand (org.eclipse.gef.commands.CompoundCommand)193 Command (org.eclipse.gef.commands.Command)86 EObject (org.eclipse.emf.ecore.EObject)40 ArrayList (java.util.ArrayList)28 EditPart (org.eclipse.gef.EditPart)28 List (java.util.List)24 EObjectFeatureCommand (com.archimatetool.editor.model.commands.EObjectFeatureCommand)23 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)22 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)18 Point (org.eclipse.draw2d.geometry.Point)16 IElementParameter (org.talend.core.model.process.IElementParameter)16 Combo (org.eclipse.swt.widgets.Combo)15 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)15 Node (org.talend.designer.core.ui.editor.nodes.Node)15 SetWidgetPropertyCommand (org.csstudio.opibuilder.commands.SetWidgetPropertyCommand)14 Rectangle (org.eclipse.draw2d.geometry.Rectangle)14 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)14 INode (org.talend.core.model.process.INode)14 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14