use of org.osate.aadl2.SubcomponentType in project osate2 by osate.
the class SubcomponentImpl method getSubcomponentType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
public SubcomponentType getSubcomponentType() {
SubcomponentType subcomponentType = basicGetSubcomponentType();
subcomponentType = subcomponentType != null && ((EObject) subcomponentType).eIsProxy() ? (SubcomponentType) eResolveProxy((InternalEObject) subcomponentType) : subcomponentType;
return subcomponentType == null || subcomponentType.eIsProxy() ? null : subcomponentType;
}
use of org.osate.aadl2.SubcomponentType in project osate2 by osate.
the class AadlSubcomponentUtil method setClassifier.
public static void setClassifier(final Subcomponent sc, final SubcomponentType selectedSubcomponentType) {
// Import as necessary
if (selectedSubcomponentType != null) {
// Import its package if necessary
final AadlPackage pkg = (AadlPackage) sc.getElementRoot();
if (selectedSubcomponentType instanceof ComponentClassifier && selectedSubcomponentType.getNamespace() != null && pkg != null) {
final PackageSection section = pkg.getPublicSection();
final AadlPackage selectedClassifierPkg = (AadlPackage) selectedSubcomponentType.getNamespace().getOwner();
if (selectedClassifierPkg != null && pkg != selectedClassifierPkg) {
AadlImportsUtil.addImportIfNeeded(section, selectedClassifierPkg);
}
}
}
if (sc instanceof SystemSubcomponent) {
((SystemSubcomponent) sc).setSystemSubcomponentType((SystemSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof AbstractSubcomponent) {
((AbstractSubcomponent) sc).setAbstractSubcomponentType((AbstractSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof ThreadGroupSubcomponent) {
((ThreadGroupSubcomponent) sc).setThreadGroupSubcomponentType((ThreadGroupSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof ThreadSubcomponent) {
((ThreadSubcomponent) sc).setThreadSubcomponentType((ThreadSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof SubprogramSubcomponent) {
((SubprogramSubcomponent) sc).setSubprogramSubcomponentType((SubprogramSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof SubprogramGroupSubcomponent) {
((SubprogramGroupSubcomponent) sc).setSubprogramGroupSubcomponentType((SubprogramGroupSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof DataSubcomponent) {
((DataSubcomponent) sc).setDataSubcomponentType((DataSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof VirtualBusSubcomponent) {
((VirtualBusSubcomponent) sc).setVirtualBusSubcomponentType((VirtualBusSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof VirtualProcessorSubcomponent) {
((VirtualProcessorSubcomponent) sc).setVirtualProcessorSubcomponentType((VirtualProcessorSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof BusSubcomponent) {
((BusSubcomponent) sc).setBusSubcomponentType((BusSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof ProcessSubcomponent) {
((ProcessSubcomponent) sc).setProcessSubcomponentType((ProcessSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof ProcessorSubcomponent) {
((ProcessorSubcomponent) sc).setProcessorSubcomponentType((ProcessorSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof DeviceSubcomponent) {
((DeviceSubcomponent) sc).setDeviceSubcomponentType((DeviceSubcomponentType) selectedSubcomponentType);
} else if (sc instanceof MemorySubcomponent) {
((MemorySubcomponent) sc).setMemorySubcomponentType((MemorySubcomponentType) selectedSubcomponentType);
} else {
throw new RuntimeException("Unexpected type: " + sc.getClass().getName());
}
}
use of org.osate.aadl2.SubcomponentType in project osate2 by osate.
the class AadlSubcomponentUtil method getAllSubcomponentType.
// Helper Methods
private static SubcomponentType getAllSubcomponentType(Subcomponent sc) {
SubcomponentType scType;
do {
scType = sc.getSubcomponentType();
sc = sc.getRefined();
} while (sc != null && scType == null);
return scType;
}
use of org.osate.aadl2.SubcomponentType in project osate2 by osate.
the class AadlSubcomponentUtil method getSubcomponentTypeDescription.
/**
* Returns null if it is unable to build a non-empty string.
* @param sc
* @return
*/
public static String getSubcomponentTypeDescription(final Subcomponent sc, final BusinessObjectContext scBoc) {
// Get top level component implementation.
NamedElement implRoot = null;
for (BusinessObjectContext tmpBoc = scBoc.getParent(); tmpBoc != null; tmpBoc = tmpBoc.getParent()) {
if (tmpBoc.getBusinessObject() instanceof ComponentImplementation) {
implRoot = ((ComponentImplementation) tmpBoc.getBusinessObject()).getElementRoot();
}
}
String retVal = "";
final SubcomponentType scType = getAllSubcomponentType(sc);
if (scType != null) {
retVal += scType.getElementRoot() == implRoot ? scType.getName() : scType.getQualifiedName();
}
// Add text for each of the implementation references (for arrays)
final List<ComponentImplementationReference> implRefs = getArrayComponentImplementationReferences(sc);
if (implRefs.size() != 0) {
retVal += "\n(";
for (int i = 0; i < implRefs.size(); i++) {
final ComponentImplementationReference ref = implRefs.get(i);
if (ref.getImplementation() != null) {
if (ref.getImplementation().eIsProxy()) {
retVal += "<unresolved>";
} else {
retVal += ref.getImplementation().getElementRoot() == implRoot ? ref.getImplementation().getName() : ref.getImplementation().getQualifiedName();
}
}
if (i == (implRefs.size() - 1)) {
retVal += ")";
} else {
retVal += ",\n";
}
}
}
return retVal.length() == 0 ? null : retVal;
}
use of org.osate.aadl2.SubcomponentType in project osate2 by osate.
the class SubcomponentPrototypeBindingsModel method flush.
@Override
public void flush() {
// Get any subcomponent. Will be used to resolve selected classifier
final Subcomponent currentSc = getBusinessObjectSelection().boStream(Subcomponent.class).findFirst().orElse(null);
if (currentSc == null) {
throw new RuntimeException("Unable to retrieve subcomponent");
}
// Get the actual object.
final NamedElementOrDescription classifier = getClassifier(null);
EObject classifierValue = classifier == null ? null : classifier.getResolvedValue(getResourceSet());
if (classifierValue != null && !(classifierValue instanceof SubcomponentType)) {
throw new RuntimeException("Unexpected value: " + classifierValue);
}
final SubcomponentType newSubcomponentType = (SubcomponentType) classifierValue;
getBusinessObjectSelection().modify(Subcomponent.class, sc -> {
// Set subcomponent type
AadlSubcomponentUtil.setClassifier(sc, newSubcomponentType);
// Update prototype bindings
sc.getOwnedPrototypeBindings().clear();
createNewBindings(null, newSubcomponentType, sc, sc.getOwnedPrototypeBindings());
});
}
Aggregations