List parts = request.getEditParts();
CompoundCommand result = new CompoundCommand();
for (int i = 0; i < parts.size(); i++) {
EditPart part = (EditPart) parts.get(i);
if (part.getModel() instanceof IActionElement) {
ActionOrphanChildCommand orphan = new ActionOrphanChildCommand();
orphan.setChild((IActionElement) ((EditPart) parts.get(i))
.getModel());
result.add(orphan);
}
else if (part.getModel() instanceof IExceptionHandler) {
ExceptionHandlerOrphanChildCommand orphan = new ExceptionHandlerOrphanChildCommand();
orphan.setChild((IExceptionHandler) ((EditPart) parts.get(i))
.getModel());
result.add(orphan);
}
else if (part.getModel() instanceof IAttributeMapper) {
AttributeMapperOrphanChildCommand orphan = new AttributeMapperOrphanChildCommand();
orphan.setChild((IAttributeMapper) ((EditPart) parts.get(i))
.getModel());
orphan.setParent((ISubflowState) getHost().getModel());
result.add(orphan);
}
else if (part.getModel() instanceof IIf) {
IfOrphanChildCommand orphan = new IfOrphanChildCommand();
orphan.setChild((IIf) ((EditPart) parts.get(i)).getModel());
orphan.setParent((IDecisionState) getHost().getModel());
result.add(orphan);
}
}
return result.unwrap();
}