Search in sources :

Example 6 with AadlGraphicalEditorException

use of org.osate.ge.aadl2.AadlGraphicalEditorException in project osate2 by osate.

the class CreateErrorPropagationPaletteCommand method buildFeatureReference.

/**
 * Builds a {@link FeatureorPPReference} based on a name path. Throws an exception if unable to find any of the
 * referenced features.
 */
private FeatureorPPReference buildFeatureReference(final ResourceSet resourceSet, final List<URI> path) {
    FeatureorPPReference topPpRef = null;
    FeatureorPPReference lastPpRef = null;
    for (final URI pathSegmentUri : path) {
        final EObject pathSegment = resourceSet.getEObject(pathSegmentUri, true);
        if (!(pathSegment instanceof Feature)) {
            throw new AadlGraphicalEditorException("Unexpected path segment: " + pathSegment);
        }
        final FeatureorPPReference ppRef = ErrorModelFactory.eINSTANCE.createFeatureorPPReference();
        ppRef.setFeatureorPP((Feature) pathSegment);
        if (lastPpRef == null) {
            topPpRef = ppRef;
        } else {
            lastPpRef.setNext(ppRef);
        }
        lastPpRef = ppRef;
    }
    return topPpRef;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) URI(org.eclipse.emf.common.util.URI) Feature(org.osate.aadl2.Feature) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 7 with AadlGraphicalEditorException

use of org.osate.ge.aadl2.AadlGraphicalEditorException in project osate2 by osate.

the class CreatePropagatonPathPaletteCommand method createQualifiedPropagationPoint.

/**
 * Creates a {@link QualifiedPropagationPoint} for referencing a business object context using business objects contained
 * in the same resource as the specified subclause. Throws an exception on error.
 * @param subclause is the subclause used to find the resource set.
 * @param boc is the business object context which contains the element to reference
 * @param classifierSource is the classifier which serves as the root of the path.
 * @return the new {@link QualifiedPropagationPoint} instance.
 */
private static QualifiedPropagationPoint createQualifiedPropagationPoint(final ErrorModelSubclause subclause, final BusinessObjectContext boc, final BusinessObjectContext classifierSource) {
    final List<URI> path = ErrorModelGeUtil.createQualifiedPropagationPointPath(boc, classifierSource, new ArrayList<>());
    QualifiedPropagationPoint result = null;
    QualifiedPropagationPoint lastSegmentRef = null;
    final ResourceSet rs = subclause.eResource().getResourceSet();
    for (final URI pathSegmentUri : path) {
        final EObject pathSegment = rs.getEObject(pathSegmentUri, true);
        // Create the QualifiedPropagationPoint instance for the path segment
        final QualifiedPropagationPoint newPoint = ErrorModelFactory.eINSTANCE.createQualifiedPropagationPoint();
        if (pathSegment instanceof Subcomponent) {
            final SubcomponentElement scElement = ErrorModelFactory.eINSTANCE.createSubcomponentElement();
            scElement.setSubcomponent((Subcomponent) pathSegment);
            newPoint.setSubcomponent(scElement);
        } else if (pathSegment instanceof NamedElement) {
            newPoint.setPropagationPoint((NamedElement) pathSegment);
        } else {
            throw new AadlGraphicalEditorException("Unexpected path segment: " + pathSegment);
        }
        if (result == null) {
            result = newPoint;
        } else {
            lastSegmentRef.setNext(newPoint);
        }
        lastSegmentRef = newPoint;
    }
    return result;
}
Also used : SubcomponentElement(org.osate.xtext.aadl2.errormodel.errorModel.SubcomponentElement) EObject(org.eclipse.emf.ecore.EObject) Subcomponent(org.osate.aadl2.Subcomponent) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) QualifiedPropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedPropagationPoint) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) URI(org.eclipse.emf.common.util.URI) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

AadlGraphicalEditorException (org.osate.ge.aadl2.AadlGraphicalEditorException)7 URI (org.eclipse.emf.common.util.URI)5 EObject (org.eclipse.emf.ecore.EObject)5 Optional (java.util.Optional)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 Display (org.eclipse.swt.widgets.Display)3 Feature (org.osate.aadl2.Feature)3 NamedElement (org.osate.aadl2.NamedElement)3 BusinessObjectContext (org.osate.ge.BusinessObjectContext)3 Operation (org.osate.ge.operations.Operation)3 StepResultBuilder (org.osate.ge.operations.StepResultBuilder)3 BasePaletteCommand (org.osate.ge.palette.BasePaletteCommand)3 ErrorModelFactory (org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory)3 FeatureorPPReference (org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)3 Objects (com.google.common.base.Objects)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BiConsumer (java.util.function.BiConsumer)2 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 AadlPackage (org.osate.aadl2.AadlPackage)2