use of org.whole.lang.ui.commands.DnDCompoundCommand in project whole by wholeplatform.
the class EditPartTransferDropTargetListener method getCommand.
@SuppressWarnings("unchecked")
protected Command getCommand() {
EditPart targetEditPart = getTargetEditPart();
if (targetEditPart == null)
return UnexecutableCommand.INSTANCE;
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
DnDCompoundCommand command = new DnDCompoundCommand();
boolean cloning = isCloning();
boolean moving = isMoving();
if (cloning)
request.setType(REQ_CLONE);
else if (moving)
request.setType(REQ_MOVE);
else
request.setType(REQ_ORPHAN);
// create REQ_MOVE and REQ_ORPHAN requests
if (!cloning)
for (EditPart editPart : ((List<EditPart>) request.getEditParts())) command.addSourceCommand(editPart, editPart.getCommand(request));
// create REQ_CLONE request
if (!moving) {
request.setType(REQ_CLONE);
command.addTargetCommand(targetEditPart, targetEditPart.getCommand(request));
}
return command;
}
use of org.whole.lang.ui.commands.DnDCompoundCommand in project whole by wholeplatform.
the class EditPartTransferDropTargetListener method handleDrop.
@Override
protected void handleDrop() {
updateTargetRequest();
updateTargetEditPart();
if (getTargetEditPart() != null) {
Command command = getCommand();
if (command != null && command.canExecute())
((DnDCompoundCommand) command).executeCompounds();
else
getCurrentEvent().detail = DND.DROP_NONE;
} else
getCurrentEvent().detail = DND.DROP_NONE;
if (getCurrentEvent().detail != DND.DROP_NONE) {
getViewer().setSelection(StructuredSelection.EMPTY);
getViewer().getControl().setFocus();
}
}
Aggregations