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));
}
}
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));
}
}
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);
}
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;
}
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);
});
});
}
Aggregations