use of org.osate.aadl2.Feature in project osate2 by osate.
the class AadlFeatureUtil method getAllFeatures.
public static EList<Feature> getAllFeatures(final FeatureGroupType fgt) {
final EList<Feature> owned = getAllOwnedFeatures(fgt);
final FeatureGroupType inverseFgt = fgt.getInverse();
if (owned.isEmpty() && !Aadl2Util.isNull(inverseFgt)) {
return getAllOwnedFeatures(inverseFgt);
}
return owned;
}
use of org.osate.aadl2.Feature in project osate2 by osate.
the class SystemInstanceImpl method leadsOutof.
/**
* Does the connection instance lead out of the flow specific feature
* instance The connection may start in a subcomponent
*
* @param conni ConnectionInstance
* @param cfi FeatureInstance the source feature instance
* @param ffi The feature instance involved in the flow
* @return true if connection goes through the ffi
*/
private boolean leadsOutof(ConnectionInstance conni, FeatureInstance cfi, FeatureInstance ffi) {
if (cfi == ffi) {
return true;
}
ComponentInstance flowci = ffi.getContainingComponentInstance();
ComponentInstance connci = cfi.getContainingComponentInstance();
while (connci != null) {
if (flowci == connci) {
return true;
}
connci = connci.getContainingComponentInstance();
}
return false;
}
use of org.osate.aadl2.Feature in project osate2 by osate.
the class ErrorModelValidator method caseErrorModelSubclause.
@Check(CheckType.FAST)
public void caseErrorModelSubclause(ErrorModelSubclause subclause) {
if (EcoreUtil2.getContainerOfType(subclause, FeatureGroupType.class) != null) {
error("Error model subclauses are not permitted in feature group types.", EcoreUtil2.getContainerOfType(subclause, DefaultAnnexSubclause.class), Aadl2Package.eINSTANCE.getNamedElement_Name());
return;
}
checkSubclauseAssociationToClassifier(subclause);
checkDuplicateSubclause(subclause);
checkOnePropagationAndContainmentPoint(subclause);
Collection<NamedElement> names = EMV2Util.getAllNamedElements(subclause);
List<NamedElement> doubles = EMV2Util.findDoubleNamedElementsInList(names);
for (NamedElement namedElement : doubles) {
if (!(namedElement instanceof ErrorPropagation)) {
error(namedElement, "Subclause has more than one element with the name '" + namedElement.getName() + "'.");
}
}
Collection<ErrorPropagation> ins = EMV2Util.getAllIncomingErrorPropagations(subclause.getContainingClassifier());
for (ErrorPropagation errorPropagation : ins) {
checkTypePropagationAndContainment(errorPropagation);
}
Collection<ErrorPropagation> outs = EMV2Util.getAllOutgoingErrorPropagations(subclause.getContainingClassifier());
for (ErrorPropagation errorPropagation : outs) {
checkTypePropagationAndContainment(errorPropagation);
}
checkUseBehavior(subclause);
}
use of org.osate.aadl2.Feature in project osate2 by osate.
the class EMV2Util method getOutgoingErrorPropagation.
/**
* Get outgoing error propagation associated with feature instance or its enclosing feature instance
* Find it for the current feature instance or any enclosing feature instances
* @param fi feature instance
* @return error propagation
*/
public static ErrorPropagation getOutgoingErrorPropagation(FeatureInstance fi) {
if (!fi.getFlowDirection().outgoing()) {
return null;
}
ComponentInstance ci = fi.getContainingComponentInstance();
FeatureInstance current = fi;
ErrorPropagation res = EMV2Util.findOutgoingErrorPropagation(ci.getComponentClassifier(), getFeatureInstancePath(current));
while (res == null && current.getOwner() instanceof FeatureInstance) {
current = (FeatureInstance) current.getOwner();
res = EMV2Util.findOutgoingErrorPropagation(ci.getComponentClassifier(), getFeatureInstancePath(current));
}
return res;
}
use of org.osate.aadl2.Feature in project osate2 by osate.
the class CreateEndToEndFlowSpecificationTool method update.
/**
* Update the diagram and tool dialog
* @param selectedBocs - the selected bocs
*/
private void update(final List<BusinessObjectContext> selectedBocs) {
if (createFlowDialog != null) {
if (createFlowDialog.getShell() != null && !createFlowDialog.getShell().isDisposed() && createFlowDialog.elementSelectionDlg == null) {
// If the selection is qualified, add it
if (selectedBocs.size() > 1) {
createFlowDialog.setErrorMessage("Multiple elements selected. Select a single element. " + " " + getDialogMessage());
} else if (selectedBocs.size() == 1) {
// Get the selected boc
final BusinessObjectContext selectedBoc = (BusinessObjectContext) selectedBocs.get(0);
if (!modeFeatureSelections.contains(selectedBoc) && createFlowDialog.addSelectedElement(selectedBoc)) {
// Insert flow segments before first mode feature
final Color color;
if (selectedBoc.getBusinessObject() instanceof ModeFeature) {
modeFeatureSelections.add(selectedBoc);
color = Color.MAGENTA.brighter();
} else {
segmentSelections.add(new SegmentData(selectedBoc, new ArrayList<>()));
if (segmentSelections.size() == 1) {
// Set default name on first selection if one does not exist
createFlowDialog.getOwnerComponentImplementation().ifPresent(ci -> {
createFlowDialog.setTitle("Creating End To End Flow in: " + ci.getQualifiedName());
if (createFlowDialog.endToEndFlowName.isEmpty()) {
createFlowDialog.setEndToEndFlowName(ci);
}
});
color = Color.ORANGE.darker();
} else {
color = Color.MAGENTA.darker();
}
}
setColor(selectedBoc, color);
}
createFlowDialog.updateSegments();
final boolean isValid = createFlowDialog.isEndToEndFlowValid(createEndToEndFlow());
createFlowDialog.updateWidgets(isValid);
createFlowDialog.setErrorMessage(null);
createFlowDialog.setMessage(getDialogMessage());
} else {
createFlowDialog.updateSegments();
}
} else if (createFlowDialog.elementSelectionDlg != null && createFlowDialog.elementSelectionDlg.getShell() != null && !createFlowDialog.elementSelectionDlg.getShell().isDisposed() && createFlowDialog.elementSelectionDlg.getShell().isVisible()) {
final CreateFlowsToolsDialog.ElementSelectionDialog elementSelectionDlg = createFlowDialog.elementSelectionDlg;
// Selecting an element for editing end to end flows
if (selectedBocs.size() > 1) {
elementSelectionDlg.setErrorMessage("Multiple elements are selected.\n " + elementSelectionDlg.getMessage());
elementSelectionDlg.setSelection(null);
} else if (selectedBocs.size() == 1) {
elementSelectionDlg.setErrorMessage(null);
final BusinessObjectContext selectedBoc = selectedBocs.get(0);
elementSelectionDlg.setSelection(selectedBoc);
}
}
}
}
Aggregations