Search in sources :

Example 1 with MoveObjectCommand

use of com.archimatetool.editor.views.tree.commands.MoveObjectCommand in project archi by archimatetool.

the class TreeModelViewerDragDropHandler method moveTreeObjects.

/**
 * Move Tree Objects
 */
void moveTreeObjects(IFolder newParent, Object[] objects) {
    final CompoundCommand compoundCommand = new NonNotifyingCompoundCommand() {

        @Override
        public String getLabel() {
            return getCommands().size() > 1 ? Messages.TreeModelViewerDragDropHandler_0 : super.getLabel();
        }
    };
    for (Object object : objects) {
        if (object instanceof IFolder) {
            // This first - folders go in folders
            if (!newParent.getFolders().contains(object)) {
                compoundCommand.add(new MoveFolderCommand(newParent, (IFolder) object));
            }
        } else if (object instanceof IArchimateModelObject) {
            if (!newParent.getElements().contains(object)) {
                compoundCommand.add(new MoveObjectCommand(newParent, (IArchimateModelObject) object));
            }
        }
    }
    CommandStack stack = (CommandStack) newParent.getAdapter(CommandStack.class);
    stack.execute(compoundCommand);
}
Also used : NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) CommandStack(org.eclipse.gef.commands.CommandStack) IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) MoveFolderCommand(com.archimatetool.editor.views.tree.commands.MoveFolderCommand) IArchimateModelObject(com.archimatetool.model.IArchimateModelObject) EObject(org.eclipse.emf.ecore.EObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) IFolder(com.archimatetool.model.IFolder) MoveObjectCommand(com.archimatetool.editor.views.tree.commands.MoveObjectCommand)

Aggregations

NonNotifyingCompoundCommand (com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)1 MoveFolderCommand (com.archimatetool.editor.views.tree.commands.MoveFolderCommand)1 MoveObjectCommand (com.archimatetool.editor.views.tree.commands.MoveObjectCommand)1 IArchimateModelObject (com.archimatetool.model.IArchimateModelObject)1 IFolder (com.archimatetool.model.IFolder)1 EObject (org.eclipse.emf.ecore.EObject)1 CommandStack (org.eclipse.gef.commands.CommandStack)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1