Source:
private void addDeleteDiagramElementFromTool(final DCommand cmd) { final EObject semanticContainer = ((DSemanticDecorator) diagramElement).getTarget(); final EObject viewContainer = diagramElement.eContainer(); boolean delete = true; if (tool.getPrecondition() != null && !StringUtil.isEmpty(tool.getPrecondition().trim())) { delete = false; final IInterpreter interpreter = InterpreterUtil.getInterpreter(diagramElement); interpreter.setVariable(IInterpreterSiriusVariables.CONTAINER_VIEW, viewContainer); interpreter.setVariable(IInterpreterSiriusVariables.VIEW, diagramElement); interpreter.setVariable(IInterpreterSiriusVariables.ELEMENT, semanticContainer); try { delete = false; delete = interpreter.evaluateBoolean(semanticContainer, tool.getPrecondition()); } catch (final EvaluationException e) { RuntimeLoggerManager.INSTANCE.error(tool, ToolPackage.eINSTANCE.getAbstractToolDescription_Precondition(), e); } interpreter.unSetVariable(IInterpreterSiriusVariables.CONTAINER_VIEW); interpreter.unSetVariable(IInterpreterSiriusVariables.VIEW); interpreter.unSetVariable(IInterpreterSiriusVariables.ELEMENT); } if (delete) { cmd.getTasks().addAll(buildDeleteFromToolTask(semanticContainer, viewContainer).getTasks()); cmd.getTasks().add(new DeleteDRepresentationElementsTask(modelAccessor, cmd, taskHelper, diagramElement) { @Override protected void addDialectSpecificAdditionalDeleteSubTasks(DSemanticDecorator decorator, List<ICommandTask> subTasks) { if (decorator instanceof EdgeTarget) { EdgeTarget edgeTarget = (EdgeTarget) decorator; for (final DEdge edge : Iterables.concat(edgeTarget.getIncomingEdges(), edgeTarget.getOutgoingEdges())) { subTasks.add(new DeleteEObjectTask(edge, modelAccessor)); } } } }); if (diagramElement instanceof DEdge) { Option<EdgeMapping> edgeMapping = new IEdgeMappingQuery(((DEdge) diagramElement).getActualMapping()).getEdgeMapping(); if (edgeMapping.some() && !edgeMapping.get().isUseDomainElement()) { cmd.getTasks().add(new DeleteEObjectTask(diagramElement, modelAccessor)); } } } else { cmd.getTasks().add(UnexecutableTask.INSTANCE); } }

Target:
private void addDeleteDiagramElementFromTool(final DCommand cmd) { final EObject semanticContainer = ((DSemanticDecorator) diagramElement).getTarget(); final EObject viewContainer = diagramElement.eContainer(); cmd.getTasks().addAll(buildDeleteFromToolTask(semanticContainer, viewContainer).getTasks()); cmd.getTasks().add(new DeleteDRepresentationElementsTask(modelAccessor, cmd, taskHelper, diagramElement) { @Override protected void addDialectSpecificAdditionalDeleteSubTasks(DSemanticDecorator decorator, List<ICommandTask> subTasks) { if (decorator instanceof EdgeTarget) { EdgeTarget edgeTarget = (EdgeTarget) decorator; for (final DEdge edge : Iterables.concat(edgeTarget.getIncomingEdges(), edgeTarget.getOutgoingEdges())) { subTasks.add(new DeleteEObjectTask(edge, modelAccessor)); } } } }); if (diagramElement instanceof DEdge) { Option<EdgeMapping> edgeMapping = new IEdgeMappingQuery(((DEdge) diagramElement).getActualMapping()).getEdgeMapping(); if (edgeMapping.some() && !edgeMapping.get().isUseDomainElement()) { cmd.getTasks().add(new DeleteEObjectTask(diagramElement, modelAccessor)); } } }