use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class ShowConnectedElementsHandler method getClassifierToConnectionEnd.
private SimpleEntry<Optional<ComponentClassifier>, BusinessObjectNode> getClassifierToConnectionEnd(BusinessObjectNode node) {
BusinessObjectNode connectionEnd = node;
for (; node != null; node = node.getParent()) {
final Optional<ComponentClassifier> classifierOpt = AadlClassifierUtil.getComponentClassifier(node);
if (classifierOpt.isPresent()) {
return new AbstractMap.SimpleEntry<Optional<ComponentClassifier>, BusinessObjectNode>(classifierOpt, connectionEnd);
}
connectionEnd = node;
}
return new AbstractMap.SimpleEntry<Optional<ComponentClassifier>, BusinessObjectNode>(Optional.empty(), connectionEnd);
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class CreateModeTransitionPaletteCommand method getOperation.
@Override
public Optional<Operation> getOperation(final GetCreateConnectionOperationContext ctx) {
if (!ctx.getDestination().getBusinessObject(Mode.class).isPresent()) {
return Optional.empty();
}
final List<ComponentClassifier> potentialOwners = getPotentialOwners(ctx.getSource(), ctx.getDestination(), ctx.getQueryService());
if (potentialOwners.size() == 0) {
return Optional.empty();
}
final BusinessObjectContext container = getOwnerBoc(ctx.getSource(), ctx.getQueryService());
if (container == null) {
return Optional.empty();
}
final Mode srcMode = ctx.getSource().getBusinessObject(Mode.class).get();
final Mode dstMode = ctx.getDestination().getBusinessObject(Mode.class).get();
return Optional.of(Operation.createPromptAndModifyWithExtra(() -> {
// Determine which classifier should own the new element
final ComponentClassifier selectedClassifier = AadlUiUtil.getBusinessObjectToModify(potentialOwners);
if (selectedClassifier == null) {
return Optional.empty();
}
// Prompt for transition triggers
final ModeTransitionTriggerInfo[] selectedTriggers = ModeTransitionTriggerSelectionDialog.promptForTriggers(selectedClassifier, null);
if (selectedTriggers == null) {
return Optional.empty();
}
return Optional.of(new BusinessObjectAndExtra<>(selectedClassifier, selectedTriggers));
}, args -> {
final ComponentClassifier cc = args.getBusinessObject();
// Determine the name for the new mode transition
final String newElementName = AadlNamingUtil.buildUniqueIdentifier(cc, "new_transition");
// Create the new mode transition
final ModeTransition newModeTransition = cc.createOwnedModeTransition();
// Clear the no modes flag
cc.setNoModes(false);
// Set the name
newModeTransition.setName(newElementName);
// Set the source and destination
newModeTransition.setSource(srcMode);
newModeTransition.setDestination(dstMode);
// Create Triggers
for (ModeTransitionTriggerInfo selectedPort : args.getExtra()) {
final ModeTransitionTrigger mtt = newModeTransition.createOwnedTrigger();
mtt.setTriggerPort(selectedPort.port);
mtt.setContext(selectedPort.context);
}
return StepResultBuilder.create().showNewBusinessObject(container, newModeTransition).build();
}));
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class ModeTransitionTriggerSelectionDialog method promptForTriggers.
/**
* Prompts the user to select triggers. Uses the passed in component classifier and mode transition to determine potential and selected choices
* @param cc
* @param mt
* @return an array containing the user's selection or null if the dialog was canceled.
*/
public static ModeTransitionTriggerInfo[] promptForTriggers(final ComponentClassifier cc, final ModeTransition mt) {
final List<ModeTransitionTriggerInfo> ports = getPossibleModeTransitionTriggerPorts(cc);
final ElementSelectionDialog triggerSelectionDlg = new ElementSelectionDialog(Display.getCurrent().getActiveShell(), "Select Trigger Ports", "Select mode transition triggers", ports);
triggerSelectionDlg.setMultipleSelection(true);
// Set initial selections
if (mt != null) {
final List<ModeTransitionTriggerInfo> currentTriggerPorts = new ArrayList<ModeTransitionTriggerInfo>();
for (final ModeTransitionTrigger mtt : mt.getOwnedTriggers()) {
currentTriggerPorts.add(new ModeTransitionTriggerInfo(mtt.getTriggerPort(), mtt.getContext()));
}
triggerSelectionDlg.setInitialSelections(currentTriggerPorts.toArray());
}
if (triggerSelectionDlg.open() == Window.CANCEL) {
return null;
}
final ModeTransitionTriggerInfo[] selectedPorts = triggerSelectionDlg.getAllSelectedElements(ModeTransitionTriggerInfo.class);
if (selectedPorts.length == 0) {
return null;
}
return selectedPorts;
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class PortSpecificationImpl method setClassifier.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setClassifier(ComponentClassifier newClassifier) {
ComponentClassifier oldClassifier = classifier;
classifier = newClassifier;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, Aadl2Package.PORT_SPECIFICATION__CLASSIFIER, oldClassifier, classifier));
}
}
use of org.osate.aadl2.ComponentClassifier 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;
}
Aggregations