Search in sources :

Example 1 with DeleteDiagramModelCommand

use of com.archimatetool.editor.model.commands.DeleteDiagramModelCommand in project archi by archimatetool.

the class DeleteCommandHandler method createCommands.

/**
 * Create the Delete Commands
 */
private void createCommands() {
    /*
         *  We need to ensure that the Delete Diagram Model Commands are called first in order to close
         *  any open diagram editors before removing their models from parent folders.
         */
    for (Object object : fElementsToDelete) {
        if (object instanceof IDiagramModel) {
            CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
            if (compoundCommand != null) {
                Command cmd = new DeleteDiagramModelCommand((IDiagramModel) object);
                compoundCommand.add(cmd);
            } else {
                // $NON-NLS-1$
                System.err.println("Could not get CompoundCommand in " + getClass());
            }
        }
    }
    /*
         * Then the other types
         */
    for (Object object : fElementsToDelete) {
        if (object instanceof IDiagramModel) {
            // already done
            continue;
        }
        CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
        if (compoundCommand == null) {
            // sanity check
            // $NON-NLS-1$
            System.err.println("Could not get CompoundCommand in " + getClass());
            continue;
        }
        if (object instanceof IFolder) {
            Command cmd = new DeleteFolderCommand((IFolder) object);
            compoundCommand.add(cmd);
        } else if (object instanceof IArchimateElement) {
            Command cmd = new DeleteArchimateElementCommand((IArchimateElement) object);
            compoundCommand.add(cmd);
        } else if (object instanceof IArchimateRelationship) {
            Command cmd = new DeleteArchimateRelationshipCommand((IArchimateRelationship) object);
            compoundCommand.add(cmd);
        } else if (object instanceof IDiagramModelObject) {
            Command cmd = DiagramCommandFactory.createDeleteDiagramObjectCommand((IDiagramModelObject) object);
            compoundCommand.add(cmd);
        } else if (object instanceof IDiagramModelConnection) {
            Command cmd = DiagramCommandFactory.createDeleteDiagramConnectionCommand((IDiagramModelConnection) object);
            compoundCommand.add(cmd);
        }
    }
}
Also used : DeleteArchimateElementCommand(com.archimatetool.editor.model.commands.DeleteArchimateElementCommand) DeleteArchimateRelationshipCommand(com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) DeleteFolderCommand(com.archimatetool.editor.model.commands.DeleteFolderCommand) IDiagramModel(com.archimatetool.model.IDiagramModel) DeleteArchimateRelationshipCommand(com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand) DeleteArchimateElementCommand(com.archimatetool.editor.model.commands.DeleteArchimateElementCommand) DeleteDiagramModelCommand(com.archimatetool.editor.model.commands.DeleteDiagramModelCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) DeleteFolderCommand(com.archimatetool.editor.model.commands.DeleteFolderCommand) Command(org.eclipse.gef.commands.Command) DeleteDiagramModelCommand(com.archimatetool.editor.model.commands.DeleteDiagramModelCommand) IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) EObject(org.eclipse.emf.ecore.EObject) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IFolder(com.archimatetool.model.IFolder)

Aggregations

DeleteArchimateElementCommand (com.archimatetool.editor.model.commands.DeleteArchimateElementCommand)1 DeleteArchimateRelationshipCommand (com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand)1 DeleteDiagramModelCommand (com.archimatetool.editor.model.commands.DeleteDiagramModelCommand)1 DeleteFolderCommand (com.archimatetool.editor.model.commands.DeleteFolderCommand)1 IArchimateElement (com.archimatetool.model.IArchimateElement)1 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)1 IDiagramModel (com.archimatetool.model.IDiagramModel)1 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)1 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)1 IFolder (com.archimatetool.model.IFolder)1 EObject (org.eclipse.emf.ecore.EObject)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1