Search in sources :

Example 1 with EnumerationType

use of org.yakindu.base.types.EnumerationType in project statecharts by Yakindu.

the class ExecutionContextLabelProvider method getEnumName.

protected String getEnumName(Object element, Object value) {
    EnumerationType enumType = (EnumerationType) ((ExecutionSlot) element).getType().getOriginType();
    String text = enumType.getEnumerator().get(((Long) value).intValue()).getName();
    return text;
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) EnumerationType(org.yakindu.base.types.EnumerationType)

Example 2 with EnumerationType

use of org.yakindu.base.types.EnumerationType in project statecharts by Yakindu.

the class EnumerationEditingSupport method convertValue.

@Override
protected Object convertValue(Object element, Object value) {
    if (element instanceof ExecutionSlot) {
        if (value != null && value instanceof Integer) {
            int index = ((Integer) value).intValue();
            EnumerationType e = getEnumerationType((ExecutionSlot) element);
            if (index < 0) {
                return new Long(e.getEnumerator().iterator().next().getLiteralValue());
            }
            return new Long(e.getEnumerator().get(index).getLiteralValue());
        }
    }
    return null;
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) EnumerationType(org.yakindu.base.types.EnumerationType)

Example 3 with EnumerationType

use of org.yakindu.base.types.EnumerationType in project statecharts by Yakindu.

the class STextScopeProvider method scope_FeatureCall_feature.

public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
    Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
    Expression owner = context.getOwner();
    EObject element = null;
    if (owner instanceof ElementReferenceExpression) {
        element = ((ElementReferenceExpression) owner).getReference();
    } else if (owner instanceof FeatureCall) {
        element = ((FeatureCall) owner).getFeature();
    } else {
        return getDelegate().getScope(context, reference);
    }
    IScope scope = IScope.NULLSCOPE;
    InferenceResult result = typeInferrer.infer(owner);
    Type ownerType = result != null ? result.getType() : null;
    if (element instanceof Scope) {
        scope = Scopes.scopeFor(((Scope) element).getDeclarations());
        return new FilteringScope(scope, predicate);
    } else if (ownerType != null) {
        scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
        scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
    }
    if (ownerType instanceof ComplexType) {
        return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
    }
    if (ownerType instanceof EnumerationType) {
        return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
    }
    return scope;
}
Also used : InferenceResult(org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult) EnumerationType(org.yakindu.base.types.EnumerationType) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) ComplexType(org.yakindu.base.types.ComplexType) EnumerationType(org.yakindu.base.types.EnumerationType) Type(org.yakindu.base.types.Type) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Scope(org.yakindu.sct.model.sgraph.Scope) IScope(org.eclipse.xtext.scoping.IScope) SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) Expression(org.yakindu.base.expressions.expressions.Expression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) EObject(org.eclipse.emf.ecore.EObject) IScope(org.eclipse.xtext.scoping.IScope) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) FeatureCall(org.yakindu.base.expressions.expressions.FeatureCall) ComplexType(org.yakindu.base.types.ComplexType) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope)

Example 4 with EnumerationType

use of org.yakindu.base.types.EnumerationType in project statecharts by Yakindu.

the class EnumerationEditingSupport method getCellEditor.

@Override
public CellEditor getCellEditor(Object element) {
    if (element instanceof ExecutionSlot) {
        EnumerationType e = getEnumerationType((ExecutionSlot) element);
        List<String> enumeratorNames = new ArrayList<String>();
        for (Enumerator enumerator : e.getEnumerator()) {
            enumeratorNames.add(enumerator.getName());
        }
        return new ComboBoxCellEditor((Composite) getViewer().getControl(), enumeratorNames.toArray(new String[] {}), SWT.READ_ONLY);
    }
    return null;
}
Also used : ExecutionSlot(org.yakindu.sct.model.sruntime.ExecutionSlot) Enumerator(org.yakindu.base.types.Enumerator) EnumerationType(org.yakindu.base.types.EnumerationType) ArrayList(java.util.ArrayList) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor)

Aggregations

EnumerationType (org.yakindu.base.types.EnumerationType)4 ExecutionSlot (org.yakindu.sct.model.sruntime.ExecutionSlot)3 ArrayList (java.util.ArrayList)1 EObject (org.eclipse.emf.ecore.EObject)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IScope (org.eclipse.xtext.scoping.IScope)1 FilteringScope (org.eclipse.xtext.scoping.impl.FilteringScope)1 ImportScope (org.eclipse.xtext.scoping.impl.ImportScope)1 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 Expression (org.yakindu.base.expressions.expressions.Expression)1 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)1 ComplexType (org.yakindu.base.types.ComplexType)1 Enumerator (org.yakindu.base.types.Enumerator)1 Type (org.yakindu.base.types.Type)1 InferenceResult (org.yakindu.base.types.inferrer.ITypeSystemInferrer.InferenceResult)1 Scope (org.yakindu.sct.model.sgraph.Scope)1 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)1 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)1