Search in sources :

Example 11 with FeaturePrototype

use of org.osate.aadl2.FeaturePrototype in project osate2 by osate.

the class AbstractFeatureImpl method setFeaturePrototype.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setFeaturePrototype(FeaturePrototype newFeaturePrototype) {
    FeaturePrototype oldFeaturePrototype = featurePrototype;
    featurePrototype = newFeaturePrototype;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.ABSTRACT_FEATURE__FEATURE_PROTOTYPE, oldFeaturePrototype, featurePrototype));
    }
}
Also used : FeaturePrototype(org.osate.aadl2.FeaturePrototype) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 12 with FeaturePrototype

use of org.osate.aadl2.FeaturePrototype in project osate2 by osate.

the class FeaturePrototypeReferenceImpl method setPrototype.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setPrototype(FeaturePrototype newPrototype) {
    FeaturePrototype oldPrototype = prototype;
    prototype = newPrototype;
    if (eNotificationRequired()) {
        eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.FEATURE_PROTOTYPE_REFERENCE__PROTOTYPE, oldPrototype, prototype));
    }
}
Also used : FeaturePrototype(org.osate.aadl2.FeaturePrototype) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 13 with FeaturePrototype

use of org.osate.aadl2.FeaturePrototype in project osate2 by osate.

the class PrototypesModel method getConstrainingClassifier.

@Override
public NamedElementOrDescription getConstrainingClassifier(final EditablePrototype prototype) {
    final Prototype p = prototype.prototype;
    final NamedElement namedElement;
    if (p instanceof ComponentPrototype) {
        namedElement = ((ComponentPrototype) p).getConstrainingClassifier();
    } else if (p instanceof FeatureGroupPrototype) {
        namedElement = ((FeatureGroupPrototype) p).getConstrainingFeatureGroupType();
    } else if (p instanceof FeaturePrototype) {
        namedElement = ((FeaturePrototype) p).getConstrainingClassifier();
    } else {
        namedElement = null;
    }
    return namedElement == null ? null : new NamedElementOrDescription(namedElement);
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) MemoryPrototype(org.osate.aadl2.MemoryPrototype) Prototype(org.osate.aadl2.Prototype) ThreadPrototype(org.osate.aadl2.ThreadPrototype) VirtualProcessorPrototype(org.osate.aadl2.VirtualProcessorPrototype) SystemPrototype(org.osate.aadl2.SystemPrototype) VirtualBusPrototype(org.osate.aadl2.VirtualBusPrototype) ProcessPrototype(org.osate.aadl2.ProcessPrototype) ThreadGroupPrototype(org.osate.aadl2.ThreadGroupPrototype) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) NamedElement(org.osate.aadl2.NamedElement) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 14 with FeaturePrototype

use of org.osate.aadl2.FeaturePrototype in project osate2 by osate.

the class PrototypesModel method getConstrainingClassifierOptions.

@Override
public Stream<NamedElementOrDescription> getConstrainingClassifierOptions(final EditablePrototype prototype) {
    if (prototype.prototype.eResource() == null) {
        return Stream.empty();
    }
    // Check the type of the prototype and get the EClass of the constraining classifier / constraining feature group type
    final Prototype p = prototype.prototype;
    final EClass filterEClass;
    if (p instanceof ComponentPrototype || p instanceof FeaturePrototype) {
        filterEClass = Aadl2Package.eINSTANCE.getComponentClassifier();
    } else if (p instanceof FeatureGroupPrototype) {
        filterEClass = Aadl2Package.eINSTANCE.getFeatureGroupType();
    } else {
        filterEClass = null;
    }
    // null is always a valid option
    Stream<NamedElementOrDescription> options = Stream.of((NamedElementOrDescription) null);
    // Concatenate all classifiers that match the supported EClass
    if (filterEClass != null) {
        options = Stream.concat(options, AadlModelAccessUtil.getAllEObjectsByType(prototype.prototype.eResource(), filterEClass).stream().map(NamedElementOrDescription::new));
    }
    return options;
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) EClass(org.eclipse.emf.ecore.EClass) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) MemoryPrototype(org.osate.aadl2.MemoryPrototype) Prototype(org.osate.aadl2.Prototype) ThreadPrototype(org.osate.aadl2.ThreadPrototype) VirtualProcessorPrototype(org.osate.aadl2.VirtualProcessorPrototype) SystemPrototype(org.osate.aadl2.SystemPrototype) VirtualBusPrototype(org.osate.aadl2.VirtualBusPrototype) ProcessPrototype(org.osate.aadl2.ProcessPrototype) ThreadGroupPrototype(org.osate.aadl2.ThreadGroupPrototype) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Example 15 with FeaturePrototype

use of org.osate.aadl2.FeaturePrototype in project osate2 by osate.

the class PrototypesModel method setPrototypeType.

@Override
public void setPrototypeType(final EditablePrototype prototype, final PrototypeType value) {
    // Check if the type is different by comparing EClass values
    final EClass currentEClass = prototype.prototype.eClass();
    final EClass newEClass = prototypeTypeToEClass(value);
    if (newEClass == currentEClass) {
        return;
    }
    modifyOwningClassifier("Set Prototype Type", prototype, c -> {
        getPrototypeByName(c, prototype.name).ifPresent(p -> {
            // Store location in list
            final int index = c.getOwnedPrototypes().indexOf(p);
            if (index == -1) {
                throw new RuntimeException("Unable to get index of prototype being modified");
            }
            // Store fields
            final String name = p.getName();
            final Prototype refined = p.getRefined();
            ComponentClassifier cc = null;
            FeatureGroupType fgt = null;
            boolean in = false;
            boolean out = false;
            boolean array = false;
            if (p instanceof ComponentPrototype) {
                final ComponentPrototype cp = (ComponentPrototype) p;
                cc = cp.getConstrainingClassifier();
                array = cp.isArray();
            } else if (p instanceof FeatureGroupPrototype) {
                final FeatureGroupPrototype fp = (FeatureGroupPrototype) p;
                fgt = fp.getConstrainingFeatureGroupType();
            } else if (p instanceof FeaturePrototype) {
                final FeaturePrototype fp = (FeaturePrototype) p;
                cc = fp.getConstrainingClassifier();
                in = fp.isIn();
                out = fp.isOut();
            }
            // Create new prototype
            final Prototype newPrototype = (Prototype) EcoreUtil.create(newEClass);
            c.getOwnedPrototypes().add(index, newPrototype);
            if (refined == null) {
                newPrototype.setName(name);
            } else {
                newPrototype.setRefined(refined);
            }
            // Set fields
            if (newPrototype instanceof ComponentPrototype) {
                final ComponentPrototype cp = (ComponentPrototype) newPrototype;
                cp.setConstrainingClassifier(cc);
                cp.setArray(array);
            } else if (newPrototype instanceof FeatureGroupPrototype) {
                final FeatureGroupPrototype fp = (FeatureGroupPrototype) newPrototype;
                fp.setConstrainingFeatureGroupType(fgt);
            } else if (newPrototype instanceof FeaturePrototype) {
                final FeaturePrototype fp = (FeaturePrototype) newPrototype;
                fp.setConstrainingClassifier(cc);
                fp.setIn(in);
                fp.setOut(out);
            }
            // Move property associations
            newPrototype.getOwnedPropertyAssociations().addAll(p.getOwnedPropertyAssociations());
            // Remove old prototype
            EcoreUtil.remove(p);
        });
    });
}
Also used : FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) ComponentClassifier(org.osate.aadl2.ComponentClassifier) EClass(org.eclipse.emf.ecore.EClass) FeatureGroupPrototype(org.osate.aadl2.FeatureGroupPrototype) BusPrototype(org.osate.aadl2.BusPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) ProcessorPrototype(org.osate.aadl2.ProcessorPrototype) SubprogramPrototype(org.osate.aadl2.SubprogramPrototype) EditablePrototype(org.osate.ge.aadl2.ui.internal.viewmodels.PrototypesModel.EditablePrototype) DataPrototype(org.osate.aadl2.DataPrototype) MemoryPrototype(org.osate.aadl2.MemoryPrototype) Prototype(org.osate.aadl2.Prototype) ThreadPrototype(org.osate.aadl2.ThreadPrototype) VirtualProcessorPrototype(org.osate.aadl2.VirtualProcessorPrototype) SystemPrototype(org.osate.aadl2.SystemPrototype) VirtualBusPrototype(org.osate.aadl2.VirtualBusPrototype) ProcessPrototype(org.osate.aadl2.ProcessPrototype) ThreadGroupPrototype(org.osate.aadl2.ThreadGroupPrototype) SubprogramGroupPrototype(org.osate.aadl2.SubprogramGroupPrototype) ComponentPrototype(org.osate.aadl2.ComponentPrototype) DevicePrototype(org.osate.aadl2.DevicePrototype) AbstractPrototype(org.osate.aadl2.AbstractPrototype) FeaturePrototype(org.osate.aadl2.FeaturePrototype) FeatureGroupType(org.osate.aadl2.FeatureGroupType) ComponentPrototype(org.osate.aadl2.ComponentPrototype)

Aggregations

FeaturePrototype (org.osate.aadl2.FeaturePrototype)16 FeatureGroupPrototype (org.osate.aadl2.FeatureGroupPrototype)11 ComponentPrototype (org.osate.aadl2.ComponentPrototype)10 DataPrototype (org.osate.aadl2.DataPrototype)7 Prototype (org.osate.aadl2.Prototype)7 AbstractPrototype (org.osate.aadl2.AbstractPrototype)5 BusPrototype (org.osate.aadl2.BusPrototype)5 ComponentClassifier (org.osate.aadl2.ComponentClassifier)5 DevicePrototype (org.osate.aadl2.DevicePrototype)5 MemoryPrototype (org.osate.aadl2.MemoryPrototype)5 ProcessPrototype (org.osate.aadl2.ProcessPrototype)5 ProcessorPrototype (org.osate.aadl2.ProcessorPrototype)5 SubprogramGroupPrototype (org.osate.aadl2.SubprogramGroupPrototype)5 SubprogramPrototype (org.osate.aadl2.SubprogramPrototype)5 SystemPrototype (org.osate.aadl2.SystemPrototype)5 ThreadGroupPrototype (org.osate.aadl2.ThreadGroupPrototype)5 ThreadPrototype (org.osate.aadl2.ThreadPrototype)5 VirtualBusPrototype (org.osate.aadl2.VirtualBusPrototype)5 VirtualProcessorPrototype (org.osate.aadl2.VirtualProcessorPrototype)5 EClass (org.eclipse.emf.ecore.EClass)4