Search in sources :

Example 11 with BehaviorTransition

use of org.osate.ba.aadlba.BehaviorTransition in project osate2 by osate.

the class AadlBaNameResolver method behaviorTransitionResolver.

/**
 * Document: AADL Behavior Annex draft
 * Version : 0.94
 * Type : Naming rule
 * Section : D.3 Behavior Specification
 * Object : Check naming rule D.3.(N2)
 * Keys : empty execution condition
 *
 * Resolves the names in behavior annex's transitions.
 *
 * @return {@code true} if all names are resolved. {@code false} otherwise.
 */
private boolean behaviorTransitionResolver() {
    boolean result = true;
    for (BehaviorTransition tmp : _ba.getTransitions()) {
        DeclarativeBehaviorTransition trans = (DeclarativeBehaviorTransition) tmp;
        result &= transDestStateResolver(trans);
        result &= transSrcStateResolver(trans);
        BehaviorCondition cond = trans.getCondition();
        // as no condition means always true.
        if (cond != null) {
            // Case of a dispatch condition
            if (cond instanceof DispatchCondition) {
                result &= dispatchConditionResolver((DispatchCondition) cond);
            } else // Case of mode switch condition
            if (cond instanceof ModeSwitchTriggerLogicalExpression) {
                result &= modeSwitchTriggerLogicalExpression((ModeSwitchTriggerLogicalExpression) cond);
            } else // ModeSwitchTriggerLogicalExpression
            // Case of a execute condition
            {
                if (cond instanceof ValueExpression) {
                    result &= valueExpressionResolver((ValueExpression) cond);
                }
            }
        }
        BehaviorActionBlock block = trans.getActionBlock();
        // Behavior actions of an behavior transition may not exist.
        if (block != null) {
            result &= behaviorActionBlockResolver(block);
        }
    }
    return result;
}
Also used : DispatchCondition(org.osate.ba.aadlba.DispatchCondition) ModeSwitchTriggerLogicalExpression(org.osate.ba.aadlba.ModeSwitchTriggerLogicalExpression) DeclarativeBehaviorTransition(org.osate.ba.declarative.DeclarativeBehaviorTransition) BehaviorCondition(org.osate.ba.aadlba.BehaviorCondition) ValueExpression(org.osate.ba.aadlba.ValueExpression) BehaviorActionBlock(org.osate.ba.aadlba.BehaviorActionBlock) BehaviorTransition(org.osate.ba.aadlba.BehaviorTransition) DeclarativeBehaviorTransition(org.osate.ba.declarative.DeclarativeBehaviorTransition)

Example 12 with BehaviorTransition

use of org.osate.ba.aadlba.BehaviorTransition in project osate2 by osate.

the class BehaviorTransitionPropertySection method refresh.

@Override
public void refresh() {
    final Optional<BusinessObjectContext> optSelectedBoc = selectedBos.bocStream().filter(boc -> isBehaviorTransition(boc) && ProjectUtil.getProjectForBo(boc.getBusinessObject()).isPresent()).findAny();
    if (optSelectedBoc.isPresent()) {
        final BusinessObjectContext selectedBoc = optSelectedBoc.orElseThrow();
        final boolean isSingleSelection = selectedBos.bocStream().limit(2).count() == 1;
        if (!isSingleSelection) {
            setControlsToMultipleSelected();
        } else {
            final BehaviorTransition behaviorTransition = (BehaviorTransition) selectedBoc.getBusinessObject();
            conditionTextEditor.setEditorTextValue(BehaviorTransitionEmbeddedTextUtil.createConditionTextValue(behaviorTransition));
            actionBlockTextEditor.setEditorTextValue(BehaviorActionBlockEmbeddedTextValue.create(behaviorTransition));
        }
    }
}
Also used : SwtUtil(org.osate.ge.swt.SwtUtil) AbstractPropertySection(org.eclipse.ui.views.properties.tabbed.AbstractPropertySection) IFilter(org.eclipse.jface.viewers.IFilter) GridLayoutFactory(org.eclipse.jface.layout.GridLayoutFactory) TabbedPropertySheetPage(org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage) DeclarativeBehaviorTransition(org.osate.ba.declarative.DeclarativeBehaviorTransition) ProjectUtil(org.osate.ge.ProjectUtil) Adapters(org.eclipse.core.runtime.Adapters) BusinessObjectSelection(org.osate.ge.BusinessObjectSelection) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BehaviorTransition(org.osate.ba.aadlba.BehaviorTransition) Composite(org.eclipse.swt.widgets.Composite) EmbeddedTextEditor(org.osate.ge.ba.ui.EmbeddedTextEditor) SWT(org.eclipse.swt.SWT) PropertySectionUtil(org.osate.ge.ui.PropertySectionUtil) Optional(java.util.Optional) ISelection(org.eclipse.jface.viewers.ISelection) BehaviorTransitionEmbeddedTextUtil(org.osate.ge.ba.util.BehaviorTransitionEmbeddedTextUtil) Label(org.eclipse.swt.widgets.Label) BusinessObjectContext(org.osate.ge.BusinessObjectContext) DeclarativeBehaviorTransition(org.osate.ba.declarative.DeclarativeBehaviorTransition) BehaviorTransition(org.osate.ba.aadlba.BehaviorTransition)

Example 13 with BehaviorTransition

use of org.osate.ba.aadlba.BehaviorTransition in project osate2 by osate.

the class BehaviorTransitionHandler method rename.

@Override
public void rename(final RenameContext ctx) {
    final BehaviorTransition behaviorTransition = ctx.getBusinessObject(BehaviorTransition.class).orElseThrow();
    final String newName = ctx.getNewName();
    // An unnamed transition's name must be set to null
    behaviorTransition.setName(newName.isEmpty() ? null : newName);
}
Also used : DeclarativeBehaviorTransition(org.osate.ba.declarative.DeclarativeBehaviorTransition) BehaviorTransition(org.osate.ba.aadlba.BehaviorTransition)

Aggregations

BehaviorTransition (org.osate.ba.aadlba.BehaviorTransition)13 DeclarativeBehaviorTransition (org.osate.ba.declarative.DeclarativeBehaviorTransition)10 BehaviorAnnex (org.osate.ba.aadlba.BehaviorAnnex)5 BehaviorState (org.osate.ba.aadlba.BehaviorState)5 BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)3 Optional (java.util.Optional)2 NamedElement (org.osate.aadl2.NamedElement)2 BehaviorActionBlock (org.osate.ba.aadlba.BehaviorActionBlock)2 DispatchCondition (org.osate.ba.aadlba.DispatchCondition)2 ValueExpression (org.osate.ba.aadlba.ValueExpression)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Adapters (org.eclipse.core.runtime.Adapters)1 AbstractEnumerator (org.eclipse.emf.common.util.AbstractEnumerator)1 BasicEList (org.eclipse.emf.common.util.BasicEList)1 Enumerator (org.eclipse.emf.common.util.Enumerator)1 EObject (org.eclipse.emf.ecore.EObject)1 EcoreUtil (org.eclipse.emf.ecore.util.EcoreUtil)1 GridLayoutFactory (org.eclipse.jface.layout.GridLayoutFactory)1 IFilter (org.eclipse.jface.viewers.IFilter)1