use of org.eclipse.gef.commands.CompoundCommand in project tdi-studio-se by Talend.
the class BusinessReferenceConnectionEditPolicy method createDeleteSemanticCommand.
/**
* @generated
*/
protected Command createDeleteSemanticCommand(GroupRequest deleteRequest) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
EditCommandRequestWrapper semReq = new EditCommandRequestWrapper(new DestroyElementRequest(editingDomain, false), deleteRequest.getExtendedData());
Command semanticCmd = getHost().getCommand(semReq);
if (semanticCmd != null && semanticCmd.canExecute()) {
CompoundCommand cc = new CompoundCommand();
cc.add(semanticCmd);
return cc;
}
return null;
}
use of org.eclipse.gef.commands.CompoundCommand in project cubrid-manager by CUBRID.
the class DeleteAction method buildDeleteCommands.
public Command buildDeleteCommands(List<EditPart> parts) {
if (parts == null || parts.size() == 0) {
return null;
}
GroupRequest delRequest = new GroupRequest(RequestConstants.REQ_DELETE);
delRequest.setEditParts(parts);
CompoundCommand compCommands = new CompoundCommand(RequestConstants.REQ_DELETE);
for (EditPart part : parts) {
Command cmd = part.getCommand(delRequest);
if (cmd != null) {
compCommands.add(cmd);
}
}
return compCommands;
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class ReconnectDiagramConnectionCommand method createBendPointsCommand.
/**
* Adding a circular connection requires some bendpoints
*/
protected Command createBendPointsCommand() {
// Only works for IDiagramModelObject as source and target objects not for connections
if (!(fConnection.getSource() instanceof IDiagramModelObject) && !(fConnection.getTarget() instanceof IDiagramModelObject)) {
return null;
}
IDiagramModelObject source = (IDiagramModelObject) fConnection.getSource();
IDiagramModelObject target = (IDiagramModelObject) fConnection.getTarget();
int width = source.getBounds().getWidth();
if (width == -1) {
width = 100;
}
int height = target.getBounds().getHeight();
if (height == -1) {
height = 60;
}
width = (int) Math.max(100, width * 0.6);
height = (int) Math.max(60, height * 0.6);
CompoundCommand result = new CompoundCommand();
CreateBendpointCommand cmd = new CreateBendpointCommand();
cmd.setDiagramModelConnection(fConnection);
cmd.setRelativeDimensions(new Dimension(width, 0), new Dimension(width, 0));
result.add(cmd);
cmd = new CreateBendpointCommand();
cmd.setDiagramModelConnection(fConnection);
cmd.setRelativeDimensions(new Dimension(width, height), new Dimension(width, height));
result.add(cmd);
cmd = new CreateBendpointCommand();
cmd.setDiagramModelConnection(fConnection);
cmd.setRelativeDimensions(new Dimension(0, height), new Dimension(0, height));
result.add(cmd);
return result;
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class DuplicateCommandHandler method duplicate.
/**
* Perform the duplicate command
*/
public void duplicate() {
// Gather the elements to duplicate
getElementsToDuplicate();
// Create the Commands
createCommands();
// Execute the Commands on the CommandStack(s) - there could be more than one if more than one model open in the Tree
for (Entry<CommandStack, CompoundCommand> entry : fCommandMap.entrySet()) {
entry.getKey().execute(entry.getValue());
}
// Select new objects in Tree
UIRequestManager.INSTANCE.fireRequest(new TreeSelectionRequest(this, new StructuredSelection(fNewObjects), true));
dispose();
}
use of org.eclipse.gef.commands.CompoundCommand in project archi by archimatetool.
the class DuplicateCommandHandler method getCompoundCommand.
/**
* Get, and if need be create, a CompoundCommand to which to add the object to be duplicated command
*/
private CompoundCommand getCompoundCommand(IAdapter object) {
// Get the Command Stack registered to the object
CommandStack stack = (CommandStack) object.getAdapter(CommandStack.class);
if (stack == null) {
// $NON-NLS-1$
System.err.println("CommandStack was null in " + getClass());
return null;
}
// Now get or create a Compound Command
CompoundCommand compoundCommand = fCommandMap.get(stack);
if (compoundCommand == null) {
compoundCommand = new NonNotifyingCompoundCommand(Messages.DuplicateCommandHandler_1);
fCommandMap.put(stack, compoundCommand);
}
return compoundCommand;
}
Aggregations