use of org.osate.aadl2.EndToEndFlow in project osate2 by osate.
the class EndToEndFlowImpl method getPropertyValueInternal.
// XXX: [AADL 1 -> AADL 2] Added to make property lookup work.
public final void getPropertyValueInternal(final Property pn, final PropertyAcc pas, final boolean fromInstanceSlaveCall, final boolean all) throws InvalidModelException {
final ComponentImplementation partOf = (ComponentImplementation) getContainingClassifier();
if (partOf == null) {
throw new InvalidModelException(this, "End to End Flow is not part of a component");
}
// First check the container's contained property associations
if (!fromInstanceSlaveCall && pas.addLocalContained(this, partOf)) {
if (!all) {
return;
}
}
// Next check the flow sequence's properties subclause
if (pas.addLocal(this)) {
if (!all) {
return;
}
}
// Next find the value by walking up the connection's refinement
// sequence
EndToEndFlow refined = getRefined();
while (refined != null) {
if (!fromInstanceSlaveCall && pas.addLocalContained(refined, refined.getContainingClassifier())) {
if (!all) {
return;
}
}
if (pas.addLocal(refined)) {
if (!all) {
return;
}
}
refined = refined.getRefined();
}
/*
* if still not set, and the property is "inherit", try the containing
* component implementation.
*/
if (!fromInstanceSlaveCall && pn.isInherit()) {
partOf.getPropertyValueInternal(pn, pas, fromInstanceSlaveCall, all);
}
}
use of org.osate.aadl2.EndToEndFlow in project osate2 by osate.
the class ComponentImplementationImpl method getAllEndToEndFlows.
/**
* get list of all end to end flows of a component impl, including ancestor
* features In case of refined end to end flows the refined end to end flow
* is returned in the list.
*
* @return Lis of end to end flows
*/
// XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
public EList<EndToEndFlow> getAllEndToEndFlows() {
final EList<Classifier> ancestors = getSelfPlusAllExtended();
final BasicEList<EndToEndFlow> returnlist = new BasicEList<EndToEndFlow>();
// Process from farthest ancestor to self
for (ListIterator<Classifier> li = ancestors.listIterator(ancestors.size()); li.hasPrevious(); ) {
final ComponentImplementation current = (ComponentImplementation) li.previous();
final EList<EndToEndFlow> currentItems = current.getOwnedEndToEndFlows();
if (currentItems != null) {
for (Iterator<EndToEndFlow> i = currentItems.iterator(); i.hasNext(); ) {
final EndToEndFlow fe = i.next();
final EndToEndFlow rfe = fe.getRefined();
if (rfe != null) {
returnlist.remove(rfe);
}
returnlist.add(fe);
}
}
}
return returnlist;
}
use of org.osate.aadl2.EndToEndFlow in project osate2 by osate.
the class ComponentImplementationImpl method createOwnedEndToEndFlow.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EndToEndFlow createOwnedEndToEndFlow() {
EndToEndFlow newOwnedEndToEndFlow = (EndToEndFlow) create(Aadl2Package.eINSTANCE.getEndToEndFlow());
getOwnedEndToEndFlows().add(newOwnedEndToEndFlow);
return newOwnedEndToEndFlow;
}
use of org.osate.aadl2.EndToEndFlow in project osate2 by osate.
the class DeleteFlowContributionItem method createControl.
@Override
protected Control createControl(final Composite parent) {
deleteFlowBtn = new Button(parent, SWT.PUSH);
deleteFlowBtn.setImage(deleteImage);
deleteFlowBtn.setToolTipText("Delete");
updateButton();
deleteFlowBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (editor != null && selectedFlow != null) {
final AadlModificationService aadlModificationService = Objects.requireNonNull((AadlModificationService) editor.getAdapter(AadlModificationService.class), "Unable to retrieve modification service");
getFlowToRemove().ifPresent(ne -> aadlModificationService.modify(ne, EcoreUtil::remove));
}
}
/**
* Get the flow to modify/remove
* @return the flow to modify/remove
*/
private Optional<NamedElement> getFlowToRemove() {
final NamedElement selectedFlowSegment = selectedFlow.getFlowSegment();
final BusinessObjectContext container = selectedFlow.getContainer();
final ComponentImplementation componentImpl = FlowContributionItemUtil.getComponentImplementation(container);
if (selectedFlowSegment instanceof EndToEndFlow) {
final ComponentImplementation endToEndFlowContainer = AgeEmfUtil.resolveOrNull(selectedFlowSegment.getContainingComponentImpl(), ComponentImplementation.class, componentImpl.eResource().getResourceSet());
return Optional.of(AgeEmfUtil.resolveOrNull(selectedFlowSegment, EndToEndFlow.class, endToEndFlowContainer.eResource().getResourceSet()));
} else if (selectedFlowSegment instanceof FlowSpecification) {
final FlowSpecification flowSpecification = AgeEmfUtil.resolveOrNull(selectedFlowSegment, FlowSpecification.class, componentImpl.eResource().getResourceSet());
// If there are multiple flow implementations for the flow spec, choose desired one.
final List<FlowImplementation> flowImpls = componentImpl.getOwnedFlowImplementations().stream().filter(fi -> fi.getSpecification() == flowSpecification).collect(Collectors.toList());
return getFlowImplementation(flowImpls);
} else {
throw new RuntimeException("Unexpected flow type: " + selectedFlow.getFlowSegment());
}
}
private Optional<NamedElement> getFlowImplementation(final List<FlowImplementation> flowImpls) {
if (flowImpls.size() == 1) {
return Optional.of(flowImpls.get(0));
} else {
final FlowImplementationSelectionDialog dlg = new FlowImplementationSelectionDialog(Display.getCurrent().getActiveShell(), flowImpls, "Select", "Choose the flow implementation to delete.");
if (dlg.open() == Window.OK) {
return Optional.ofNullable(dlg.getSelectedFlowImplementation());
}
}
return Optional.empty();
}
});
return deleteFlowBtn;
}
use of org.osate.aadl2.EndToEndFlow in project osate2 by osate.
the class CreateEndToEndFlowsSwitch method instantiateEndToEndFlow.
protected void instantiateEndToEndFlow(ComponentInstance ci, EndToEndFlow ete, HashMap<EndToEndFlow, List<ETEInfo>> ete2info) {
EndToEndFlowInstance etei = InstanceFactory.eINSTANCE.createEndToEndFlowInstance();
resetETECloneCount();
created = new ArrayList<ETEInfo>();
ete2info.put(ete, created);
this.ete2info = ete2info;
etei.setName(ete.getName());
etei.setEndToEndFlow(ete);
ci.getEndToEndFlows().add(etei);
addETEI.add(etei);
created.add(myInfo = new ETEInfo(etei));
EList<EList<ModeInstance>> ml = etei.getModesList();
ml.clear();
ml.add(getModeInstances(ci, ete));
processETE(ci, etei, ete);
ml.clear();
}
Aggregations