if (event.stateMask == SWT.MOD1 && event.keyCode == SWT.DEL) {
final List<? extends EditorPart> objects = viewer.getSelectedEditParts();
if (objects == null || objects.isEmpty())
return true;
final GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
final CompoundCommand compoundCmd = new CompoundCommand("Delete"); //$NON-NLS-1$
for (int i = 0; i < objects.size(); i++) {
final EditPart object = (EditPart) objects.get(i);
deleteReq.setEditParts(object);
final Command cmd = object.getCommand(deleteReq);
if (cmd != null)
compoundCmd.add(cmd);
}
getCommandStack().execute(compoundCmd);
return true;
}
if (event.stateMask == SWT.MOD3
&& (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT
|| event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
final List<? extends EditorPart> objects = viewer.getSelectedEditParts();
if (objects == null || objects.isEmpty())
return true;
// move request
final GroupRequest moveReq = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
final CompoundCommand compoundCmd = new CompoundCommand("Move"); //$NON-NLS-1$
for (int i = 0; i < objects.size(); i++) {
final EditPart object = (EditPart) objects.get(i);
moveReq.setEditParts(object);
final LocationCommand cmd = (LocationCommand) object.getCommand(moveReq);
if (cmd != null) {
cmd.setLocation(new Point(event.keyCode == SWT.ARROW_LEFT ? -1
: event.keyCode == SWT.ARROW_RIGHT ? 1 : 0,
event.keyCode == SWT.ARROW_DOWN ? 1
: event.keyCode == SWT.ARROW_UP ? -1 : 0));
cmd.setRelative(true);
compoundCmd.add(cmd);
}
}
getCommandStack().execute(compoundCmd);
return true;
}