use of org.osate.ge.businessobjecthandling.CanDeleteContext in project osate2 by osate.
the class ErrorPropagationHandler method canDelete.
@Override
public boolean canDelete(final CanDeleteContext ctx) {
final ErrorPropagation bo = ctx.getBusinessObject(ErrorPropagation.class).get();
// Don't allow deleting if there exists an error flow that references the error propagation
final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(bo.getContainingClassifier());
return !combined.getFlows().anyMatch(f -> {
if (f instanceof ErrorSource) {
final ErrorSource src = (ErrorSource) f;
return src.getSourceModelElement() == bo;
} else if (f instanceof ErrorSink) {
final ErrorSink snk = (ErrorSink) f;
return snk.getIncoming() == bo;
} else if (f instanceof ErrorPath) {
final ErrorPath path = (ErrorPath) f;
return path.getIncoming() == bo || path.getOutgoing() == bo;
}
return false;
});
}
use of org.osate.ge.businessobjecthandling.CanDeleteContext in project osate2 by osate.
the class DeleteHandler method canDelete.
private boolean canDelete(final DiagramElement de) {
final Object bo = de.getBusinessObject();
final BusinessObjectHandler boHandler = de.getBusinessObjectHandler();
if (boHandler == null) {
return false;
}
// Don't allow proxies.
if (bo instanceof EObject) {
final EObject eobj = ((EObject) bo);
if (eobj.eIsProxy()) {
return false;
}
// Prevent deletion of resources which are part of plugins
final Resource res = eobj.eResource();
if (res != null && res.getURI().isPlatformPlugin()) {
return false;
}
}
return boHandler.canDelete(new CanDeleteContext(bo));
}
Aggregations