Search in sources :

Example 6 with ComponentClassifier

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);
}
Also used : BusinessObjectNode(org.osate.ge.internal.diagram.runtime.updating.BusinessObjectNode) ComponentClassifier(org.osate.aadl2.ComponentClassifier) SimpleEntry(java.util.AbstractMap.SimpleEntry)

Example 7 with ComponentClassifier

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();
    }));
}
Also used : Element(org.osate.aadl2.Element) BusinessObjectAndExtra(org.osate.ge.operations.BusinessObjectAndExtra) GetCreateConnectionOperationContext(org.osate.ge.palette.GetCreateConnectionOperationContext) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger) ComponentClassifier(org.osate.aadl2.ComponentClassifier) BusinessObjectContext(org.osate.ge.BusinessObjectContext) AadlImages(org.osate.ge.aadl2.internal.AadlImages) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) CanStartConnectionContext(org.osate.ge.palette.CanStartConnectionContext) CreateConnectionPaletteCommand(org.osate.ge.palette.CreateConnectionPaletteCommand) AadlUiUtil(org.osate.ge.aadl2.ui.internal.AadlUiUtil) ModeTransition(org.osate.aadl2.ModeTransition) Aadl2Package(org.osate.aadl2.Aadl2Package) Subcomponent(org.osate.aadl2.Subcomponent) ModeTransitionTriggerSelectionDialog(org.osate.ge.aadl2.ui.internal.dialogs.ModeTransitionTriggerSelectionDialog) Operation(org.osate.ge.operations.Operation) Collectors(java.util.stream.Collectors) Mode(org.osate.aadl2.Mode) List(java.util.List) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) QueryService(org.osate.ge.services.QueryService) AadlCategories(org.osate.ge.aadl2.AadlCategories) ModeTransitionTriggerInfo(org.osate.ge.aadl2.ui.internal.dialogs.ModeTransitionTriggerSelectionDialog.ModeTransitionTriggerInfo) Optional(java.util.Optional) AadlNamingUtil(org.osate.ge.aadl2.internal.AadlNamingUtil) ExecutableQuery(org.osate.ge.query.ExecutableQuery) Collections(java.util.Collections) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Mode(org.osate.aadl2.Mode) BusinessObjectAndExtra(org.osate.ge.operations.BusinessObjectAndExtra) ModeTransition(org.osate.aadl2.ModeTransition) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ModeTransitionTriggerInfo(org.osate.ge.aadl2.ui.internal.dialogs.ModeTransitionTriggerSelectionDialog.ModeTransitionTriggerInfo) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 8 with ComponentClassifier

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;
}
Also used : ArrayList(java.util.ArrayList) ModeTransitionTrigger(org.osate.aadl2.ModeTransitionTrigger)

Example 9 with ComponentClassifier

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));
    }
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 10 with ComponentClassifier

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;
}
Also used : ComponentClassifier(org.osate.aadl2.ComponentClassifier) Tag(org.osate.ge.aadl2.internal.model.Tag)

Aggregations

ComponentClassifier (org.osate.aadl2.ComponentClassifier)76 Subcomponent (org.osate.aadl2.Subcomponent)26 Classifier (org.osate.aadl2.Classifier)22 EObject (org.eclipse.emf.ecore.EObject)19 NamedElement (org.osate.aadl2.NamedElement)19 ComponentImplementation (org.osate.aadl2.ComponentImplementation)16 ArrayList (java.util.ArrayList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)14 AadlPackage (org.osate.aadl2.AadlPackage)13 FeatureGroupType (org.osate.aadl2.FeatureGroupType)12 List (java.util.List)11 ComponentPrototype (org.osate.aadl2.ComponentPrototype)11 Element (org.osate.aadl2.Element)11 ComponentType (org.osate.aadl2.ComponentType)10 Feature (org.osate.aadl2.Feature)9 Mode (org.osate.aadl2.Mode)8 BusinessObjectContext (org.osate.ge.BusinessObjectContext)8 Collectors (java.util.stream.Collectors)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 ComponentCategory (org.osate.aadl2.ComponentCategory)7