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