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;
}
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;
}
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();
}
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;
}
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;
}
Aggregations