Search in sources :

Example 11 with EndToEndFlow

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);
    }
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) InvalidModelException(org.osate.aadl2.properties.InvalidModelException) EndToEndFlow(org.osate.aadl2.EndToEndFlow)

Example 12 with EndToEndFlow

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;
}
Also used : EndToEndFlow(org.osate.aadl2.EndToEndFlow) ComponentImplementation(org.osate.aadl2.ComponentImplementation) BasicEList(org.eclipse.emf.common.util.BasicEList) Classifier(org.osate.aadl2.Classifier)

Example 13 with EndToEndFlow

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;
}
Also used : EndToEndFlow(org.osate.aadl2.EndToEndFlow)

Example 14 with EndToEndFlow

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;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) Image(org.eclipse.swt.graphics.Image) InternalDiagramEditor(org.osate.ge.internal.ui.editor.InternalDiagramEditor) BusinessObjectContext(org.osate.ge.BusinessObjectContext) FlowImplementationSelectionDialog(org.osate.ge.aadl2.ui.internal.editor.FlowContributionItemUtil.FlowImplementationSelectionDialog) AgeEmfUtil(org.osate.ge.internal.util.AgeEmfUtil) HighlightableFlowInfo(org.osate.ge.aadl2.ui.internal.editor.FlowContributionItem.HighlightableFlowInfo) Composite(org.eclipse.swt.widgets.Composite) IEditorPart(org.eclipse.ui.IEditorPart) ControlContribution(org.eclipse.jface.action.ControlContribution) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FlowSpecification(org.osate.aadl2.FlowSpecification) Button(org.eclipse.swt.widgets.Button) PlatformUI(org.eclipse.ui.PlatformUI) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) Display(org.eclipse.swt.widgets.Display) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) ISharedImages(org.eclipse.ui.ISharedImages) List(java.util.List) Window(org.eclipse.jface.window.Window) FlowImplementation(org.osate.aadl2.FlowImplementation) SWT(org.eclipse.swt.SWT) AadlModificationService(org.osate.ge.internal.services.AadlModificationService) Optional(java.util.Optional) SelectionEvent(org.eclipse.swt.events.SelectionEvent) NamedElement(org.osate.aadl2.NamedElement) Control(org.eclipse.swt.widgets.Control) EndToEndFlow(org.osate.aadl2.EndToEndFlow) ComponentImplementation(org.osate.aadl2.ComponentImplementation) EndToEndFlow(org.osate.aadl2.EndToEndFlow) Optional(java.util.Optional) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) FlowImplementation(org.osate.aadl2.FlowImplementation) FlowImplementationSelectionDialog(org.osate.ge.aadl2.ui.internal.editor.FlowContributionItemUtil.FlowImplementationSelectionDialog) AadlModificationService(org.osate.ge.internal.services.AadlModificationService) FlowSpecification(org.osate.aadl2.FlowSpecification) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EcoreUtil(org.eclipse.emf.ecore.util.EcoreUtil) NamedElement(org.osate.aadl2.NamedElement) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 15 with EndToEndFlow

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();
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) EList(org.eclipse.emf.common.util.EList) EndToEndFlowInstance(org.osate.aadl2.instance.EndToEndFlowInstance)

Aggregations

EndToEndFlow (org.osate.aadl2.EndToEndFlow)16 EndToEndFlowSegment (org.osate.aadl2.EndToEndFlowSegment)7 FlowSpecification (org.osate.aadl2.FlowSpecification)6 NamedElement (org.osate.aadl2.NamedElement)6 ComponentImplementation (org.osate.aadl2.ComponentImplementation)5 Connection (org.osate.aadl2.Connection)5 EndToEndFlowElement (org.osate.aadl2.EndToEndFlowElement)5 FlowSegment (org.osate.aadl2.FlowSegment)5 FlowElement (org.osate.aadl2.FlowElement)4 List (java.util.List)3 Optional (java.util.Optional)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Button (org.eclipse.swt.widgets.Button)3 ConnectedElement (org.osate.aadl2.ConnectedElement)3 BusinessObjectContext (org.osate.ge.BusinessObjectContext)3 Objects (java.util.Objects)2 Collectors (java.util.stream.Collectors)2 BasicEList (org.eclipse.emf.common.util.BasicEList)2 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2