*/
public void deleteOtherElements(final IGraphicalEditPart diagramEditPart) {
if (editingDomain == null)
throw new RuntimeException("Cannot delete related elements; we do not have an editing domain.");
ICommand command = new AbstractTransactionalCommand(editingDomain, "delete related elements", Collections.EMPTY_LIST) {
@Override
protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
try {
// we don't want to just delete related elements;
// we want to delete _all_ elements
for (GeneratedElement selected : selectedElements) {
EcoreCreateElementsHelper helper = new EmfInferenceHandler(
editingDomain,
Collections.EMPTY_LIST,
monitor,
info,
selected.eResource() );
// get all elements to delete
List<EObject> toDelete = new GeneratedElementDeleter(selected).getElementsToDelete();
for (EObject d : toDelete) {
deleteElement(helper, d, monitor, info, diagramEditPart);
}
}
if (diagramEditPart != null)
diagramEditPart.refresh();
} catch (InferenceException e) {
throw new ExecutionException(e.getMessage(), e);
}
return CommandResult.newOKCommandResult();
}
};
try {
command.execute(new NullProgressMonitor(), null);
} catch (ExecutionException e) {
throw new RuntimeException(e.getMessage(), e);
}
}