Search in sources :

Example 1 with DnDCompoundCommand

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;
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) EditPart(org.eclipse.gef.EditPart) List(java.util.List) DnDCompoundCommand(org.whole.lang.ui.commands.DnDCompoundCommand)

Example 2 with DnDCompoundCommand

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();
    }
}
Also used : UnexecutableCommand(org.eclipse.gef.commands.UnexecutableCommand) Command(org.eclipse.gef.commands.Command) DnDCompoundCommand(org.whole.lang.ui.commands.DnDCompoundCommand)

Aggregations

DnDCompoundCommand (org.whole.lang.ui.commands.DnDCompoundCommand)2 List (java.util.List)1 EditPart (org.eclipse.gef.EditPart)1 Command (org.eclipse.gef.commands.Command)1 UnexecutableCommand (org.eclipse.gef.commands.UnexecutableCommand)1 ChangeBoundsRequest (org.eclipse.gef.requests.ChangeBoundsRequest)1