Search in sources :

Example 21 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class ShowConnectedElementsHandler method enabledConnectionEnds.

private boolean enabledConnectionEnds(final BusinessObjectNode selectedNode, final Context context1, final Context context2, final ConnectedElement connectedElement1, final ConnectedElement connectedElement2) {
    if (context1 == null || !(context1 instanceof Subcomponent)) {
        if (context2 != null) {
            final RelativeBusinessObjectReference contextRef = getRelativeBusinessObjectReference(context2);
            BusinessObjectNode contextNode = selectedNode.getChild(contextRef);
            if (contextNode == null) {
                contextNode = createNode(selectedNode, contextRef, context2);
            }
            enableConnectedElements(contextNode, connectedElement1);
        }
        enableConnectedElements(selectedNode, connectedElement2);
        return true;
    }
    return false;
}
Also used : BusinessObjectNode(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode) Subcomponent(org.osate.aadl2.Subcomponent) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference)

Example 22 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class AadlBusinessObjectProvider method getChildBusinessObjects.

@Override
public Stream<?> getChildBusinessObjects(final BusinessObjectProviderContext ctx) {
    final Object bo = ctx.getBusinessObjectContext().getBusinessObject();
    // An IProject is specified as the business object for contextless diagrams.
    if (bo instanceof IProject) {
        // Special handling for project
        final IProject project = (IProject) bo;
        // Perform an incremental project build to ensure new packages are included.
        try {
            project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
        } catch (CoreException e) {
            throw new RuntimeException(e);
        }
        Stream<Object> packages = getPackages(project);
        // If no packages were found, assume that the project needs to be built. This can happen if the Eclipse process is forcefully terminated.
        if (packages == null) {
            try {
                project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
            } catch (CoreException e) {
                throw new RuntimeException(e);
            }
            packages = getPackages(project);
        }
        return packages;
    } else if (bo instanceof AadlPackage) {
        return getChildren((AadlPackage) bo, ctx.getExtensionRegistry());
    } else if (bo instanceof Classifier) {
        return getChildren((Classifier) bo, true, ctx.getExtensionRegistry());
    } else if (bo instanceof FeatureGroup) {
        final FeatureGroupType fgt = AadlFeatureUtil.getFeatureGroupType(ctx.getBusinessObjectContext(), (FeatureGroup) bo);
        return fgt == null ? Stream.empty() : AadlFeatureUtil.getAllFeatures(fgt).stream();
    } else if (bo instanceof Subcomponent) {
        return getChildren((Subcomponent) bo, ctx.getBusinessObjectContext(), ctx.getExtensionRegistry());
    } else if (bo instanceof SubprogramCall) {
        return getChildren((SubprogramCall) bo);
    } else if (bo instanceof SubprogramCallSequence) {
        return getChildren((SubprogramCallSequence) bo);
    } else if (bo instanceof ModeTransition) {
        final ModeTransition mt = ((ModeTransition) bo);
        final String modeTransitionTriggersDesc = mt.getOwnedTriggers().stream().map(mtt -> mttHandler.getName(mtt)).collect(Collectors.joining(","));
        return Stream.concat(mt.getOwnedTriggers().stream(), Stream.of(new Tag(Tag.KEY_MODE_TRANSITION_TRIGGERS, modeTransitionTriggersDesc)));
    } else if (bo instanceof ComponentInstance) {
        return getChildren((ComponentInstance) bo);
    } else if (bo instanceof FeatureInstance) {
        return ((FeatureInstance) bo).getFeatureInstances().stream();
    } else if (bo instanceof Connection) {
        if (!((Connection) bo).isAllBidirectional()) {
            return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
        }
    } else if (bo instanceof ConnectionInstance) {
        if (!((ConnectionInstance) bo).isBidirectional()) {
            return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
        }
    }
    return Stream.empty();
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) FeatureGroup(org.osate.aadl2.FeatureGroup) AadlPackage(org.osate.aadl2.AadlPackage) FeatureInstance(org.osate.aadl2.instance.FeatureInstance) SubprogramCallSequence(org.osate.aadl2.SubprogramCallSequence) FeatureGroupType(org.osate.aadl2.FeatureGroupType) Connection(org.osate.aadl2.Connection) ModeTransition(org.osate.aadl2.ModeTransition) Classifier(org.osate.aadl2.Classifier) SubprogramClassifier(org.osate.aadl2.SubprogramClassifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) EObject(org.eclipse.emf.ecore.EObject) Tag(org.osate.ge.aadl2.internal.model.Tag) SubprogramCall(org.osate.aadl2.SubprogramCall)

Example 23 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class AadlBusinessObjectProvider method getChildren.

private static Stream<?> getChildren(final Subcomponent sc, final BusinessObjectContext scBoc, final ExtensionRegistryService extRegistryService) {
    final ComponentClassifier cc = AadlSubcomponentUtil.getComponentClassifier(scBoc, sc);
    if (cc == null) {
        return null;
    }
    Stream<?> results = getChildren(cc, false, extRegistryService);
    final String scTypeTxt = AadlSubcomponentUtil.getSubcomponentTypeDescription(sc, scBoc);
    if (scTypeTxt != null) {
        results = Stream.concat(results, Stream.of(new Tag(Tag.KEY_SUBCOMPONENT_TYPE, scTypeTxt)));
    }
    return results;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) Tag(org.osate.ge.aadl2.internal.model.Tag)

Example 24 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class AadlSubcomponentUtil method getArrayComponentImplementationReferences.

private static List<ComponentImplementationReference> getArrayComponentImplementationReferences(final Subcomponent sc) {
    Subcomponent tmpSc = sc;
    List<ComponentImplementationReference> refs;
    do {
        refs = tmpSc.getImplementationReferences();
        tmpSc = tmpSc.getRefined();
    } while (tmpSc != null && refs.size() == 0);
    return refs;
}
Also used : ComponentImplementationReference(org.osate.aadl2.ComponentImplementationReference) ThreadGroupSubcomponent(org.osate.aadl2.ThreadGroupSubcomponent) SubprogramSubcomponent(org.osate.aadl2.SubprogramSubcomponent) BusSubcomponent(org.osate.aadl2.BusSubcomponent) AbstractSubcomponent(org.osate.aadl2.AbstractSubcomponent) ThreadSubcomponent(org.osate.aadl2.ThreadSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DeviceSubcomponent(org.osate.aadl2.DeviceSubcomponent) ProcessorSubcomponent(org.osate.aadl2.ProcessorSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) MemorySubcomponent(org.osate.aadl2.MemorySubcomponent) ProcessSubcomponent(org.osate.aadl2.ProcessSubcomponent) SubprogramGroupSubcomponent(org.osate.aadl2.SubprogramGroupSubcomponent) VirtualProcessorSubcomponent(org.osate.aadl2.VirtualProcessorSubcomponent) SystemSubcomponent(org.osate.aadl2.SystemSubcomponent) VirtualBusSubcomponent(org.osate.aadl2.VirtualBusSubcomponent)

Example 25 with Subcomponent

use of org.osate.aadl2.Subcomponent in project osate2 by osate.

the class SubcomponentHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final BusinessObjectContext scBoc = ctx.getBusinessObjectContext();
    final Subcomponent sc = scBoc.getBusinessObject(Subcomponent.class).get();
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(getGraphicalRepresentation(sc, scBoc)).style(StyleBuilder.create(AadlInheritanceUtil.isInherited(scBoc) ? Styles.INHERITED_ELEMENT : Style.EMPTY, getClassifierStyle(sc, scBoc)).labelsTop().labelsHorizontalCenter().build()).build());
}
Also used : Subcomponent(org.osate.aadl2.Subcomponent) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Aggregations

Subcomponent (org.osate.aadl2.Subcomponent)115 ComponentClassifier (org.osate.aadl2.ComponentClassifier)53 Classifier (org.osate.aadl2.Classifier)44 ComponentImplementation (org.osate.aadl2.ComponentImplementation)40 NamedElement (org.osate.aadl2.NamedElement)38 Feature (org.osate.aadl2.Feature)34 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)31 DataSubcomponent (org.osate.aadl2.DataSubcomponent)30 ArrayList (java.util.ArrayList)28 EObject (org.eclipse.emf.ecore.EObject)23 Connection (org.osate.aadl2.Connection)22 SubprogramSubcomponent (org.osate.aadl2.SubprogramSubcomponent)21 FeatureGroup (org.osate.aadl2.FeatureGroup)18 Property (org.osate.aadl2.Property)18 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)17 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)17 AadlPackage (org.osate.aadl2.AadlPackage)15 ComponentType (org.osate.aadl2.ComponentType)15 FeatureGroupType (org.osate.aadl2.FeatureGroupType)15 List (java.util.List)14