Search in sources :

Example 1 with CanDeleteContext

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;
    });
}
Also used : GetNameForDiagramContext(org.osate.ge.businessobjecthandling.GetNameForDiagramContext) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) CanDeleteContext(org.osate.ge.businessobjecthandling.CanDeleteContext) GraphicalConfiguration(org.osate.ge.GraphicalConfiguration) Style(org.osate.ge.graphics.Style) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink) Strings(com.google.common.base.Strings) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Graphic(org.osate.ge.graphics.Graphic) GetGraphicalConfigurationContext(org.osate.ge.businessobjecthandling.GetGraphicalConfigurationContext) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) GetNameContext(org.osate.ge.businessobjecthandling.GetNameContext) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) CanCopyContext(org.osate.ge.businessobjecthandling.CanCopyContext) LabelBuilder(org.osate.ge.graphics.LabelBuilder) GraphicalConfigurationBuilder(org.osate.ge.GraphicalConfigurationBuilder) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) GraphicalExtensionUtil(org.osate.ge.aadl2.GraphicalExtensionUtil) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) StyleBuilder(org.osate.ge.graphics.StyleBuilder) IsApplicableContext(org.osate.ge.businessobjecthandling.IsApplicableContext) ReferenceContext(org.osate.ge.businessobjecthandling.ReferenceContext) Optional(java.util.Optional) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)

Example 2 with CanDeleteContext

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));
}
Also used : EObject(org.eclipse.emf.ecore.EObject) Resource(org.eclipse.emf.ecore.resource.Resource) EmbeddedBusinessObject(org.osate.ge.internal.model.EmbeddedBusinessObject) EObject(org.eclipse.emf.ecore.EObject) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) CanDeleteContext(org.osate.ge.businessobjecthandling.CanDeleteContext)

Aggregations

BusinessObjectHandler (org.osate.ge.businessobjecthandling.BusinessObjectHandler)2 CanDeleteContext (org.osate.ge.businessobjecthandling.CanDeleteContext)2 Strings (com.google.common.base.Strings)1 Optional (java.util.Optional)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 CanonicalBusinessObjectReference (org.osate.ge.CanonicalBusinessObjectReference)1 GraphicalConfiguration (org.osate.ge.GraphicalConfiguration)1 GraphicalConfigurationBuilder (org.osate.ge.GraphicalConfigurationBuilder)1 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)1 GraphicalExtensionUtil (org.osate.ge.aadl2.GraphicalExtensionUtil)1 CanCopyContext (org.osate.ge.businessobjecthandling.CanCopyContext)1 GetGraphicalConfigurationContext (org.osate.ge.businessobjecthandling.GetGraphicalConfigurationContext)1 GetNameContext (org.osate.ge.businessobjecthandling.GetNameContext)1 GetNameForDiagramContext (org.osate.ge.businessobjecthandling.GetNameForDiagramContext)1 IsApplicableContext (org.osate.ge.businessobjecthandling.IsApplicableContext)1 ReferenceContext (org.osate.ge.businessobjecthandling.ReferenceContext)1 CombinedErrorModelSubclause (org.osate.ge.errormodel.combined.CombinedErrorModelSubclause)1 Graphic (org.osate.ge.graphics.Graphic)1 LabelBuilder (org.osate.ge.graphics.LabelBuilder)1