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;
}
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();
}
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;
}
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;
}
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());
}
Aggregations