use of org.osate.ge.businessobjecthandling.CanCopyContext in project osate2 by osate.
the class CopyAction method allBusinessObjectsAreCopyable.
/**
* Returns true if all business object are copyable. A business object is copyable if it is an embedded business object or
* if it is an EObject contained in a many feature.
* @param diagramElements
* @return
*/
private static boolean allBusinessObjectsAreCopyable(final Collection<DiagramElement> diagramElements) {
return diagramElements.stream().allMatch(de -> {
if (!de.getBusinessObjectHandler().canCopy(new CanCopyContext(de.getBusinessObject()))) {
return false;
}
final Object bo = de.getBusinessObject();
if (bo instanceof EmbeddedBusinessObject) {
return true;
}
if (!(bo instanceof EObject)) {
return false;
}
final EObject eObj = (EObject) bo;
final EStructuralFeature containgFeature = eObj.eContainingFeature();
return containgFeature != null && containgFeature.isMany();
});
}
Aggregations