private void readEnum(String val, VirtualObject object, EStructuralFeature structuralFeature) throws DeserializeException, MetaDataException, DatabaseException { if (val.equals(".T.")) { object.setAttribute(structuralFeature, Boolean.TRUE); } else if (val.equals(".F.")) { object.setAttribute(structuralFeature, Boolean.FALSE); } else if (val.equals(".U.")) { object.eUnset(structuralFeature); } else { if (structuralFeature.getEType() instanceof EEnumImpl) { String realEnumValue = val.substring(1, val.length() - 1); EEnumLiteral enumValue = (((EEnumImpl) structuralFeature.getEType()).getEEnumLiteral(realEnumValue)); if (enumValue == null) { throw new DeserializeException(lineNumber, "Enum type " + structuralFeature.getEType().getName() + " has no literal value '" + realEnumValue + "'"); } object.setAttribute(structuralFeature, enumValue.getLiteral()); } else { throw new DeserializeException(lineNumber, "Value " + val + " indicates enum type but " + structuralFeature.getEType().getName() + " expected"); } } }
public void createPackageContents() { if (isCreated) return; createPackageContentsGen(); EEnumImpl e = new EEnumImpl() { @Override public Object getDefaultValue() { return CalculatedVariable.END; } }; e.setClassifierID(CALCULATED_VARIABLE); ListIterator<EClassifier> iterator = getEClassifiers().listIterator(); while (iterator.hasNext()) { if (iterator.next().getClassifierID() == CALCULATED_VARIABLE) { iterator.set(e); calculatedVariableEEnum = e; break; } } }
protected List<String> getChoiceOfValues(EPlanElement element, EStructuralFeature feature) { if(choiceOfValues == null) { EClassifier eType = feature.getEType(); if(eType instanceof EEnumImpl) { choices = ((EEnumImpl) eType).getELiterals(); } else { IItemPropertySource itemPropertySource = EMFUtils.adapt(element, IItemPropertySource.class); IItemPropertyDescriptor pd = itemPropertySource.getPropertyDescriptor(element, feature); choices = pd.getChoiceOfValues(element); } choiceOfValues = getList(choices); } return choiceOfValues; }
private List<?> getChoiceOfObjects(String parameterName) { if (parameterName != null) { EParameterDef def = ActivityDictionary.getInstance().getAttributeDef(parameterName); if (def != null) { EGenericType eGenericType = def.getEGenericType(); EClassifier classifier = eGenericType.getEClassifier(); if (classifier instanceof EEnumImpl) { EEnumImpl enumImpl = (EEnumImpl) classifier; return enumImpl.getELiterals(); } LogUtil.warn("Row Highlighting only supports Enum types. Not supported for " + parameterName + " (" +classifier+")."); } else { LogUtil.error("Invalid parameter name for Row Highligther: "+ parameterName); } } return Collections.EMPTY_LIST; }
/** * getStringifier(eAttribute.getEAttributeType() is deprecated. * Use getStringifier(eAttribute) instead, when applicable. */ public static IStringifier<?> getStringifier(final EDataType eDataType) { if(eDataType instanceof EEnumImpl) { return new EEnumStringifier(eDataType); } IStringifier stringifier = null; // First check the type name, using hasRegisteredStringifier to avoid unnecessary warnings // from getStringifier boolean hasStringifier = StringifierRegistry.hasRegisteredStringifier(eDataType.getName()); if (hasStringifier) { stringifier = StringifierRegistry.getStringifier(eDataType.getName()); } else { // Next check the instance name Class<?> instanceClass = eDataType.getInstanceClass(); if (instanceClass != null) { stringifier = StringifierRegistry.getStringifier(instanceClass); } // Do not use the DefaultStringifier since we would prefer to delegate to the EFactory instance if (stringifier instanceof DefaultStringifier) { return new EDataTypeStringifier(eDataType); } } return stringifier; }
@Override @SuppressWarnings("unchecked") public CellEditor getCellEditor(Composite parent, ParameterFacet<T> facet) { EStructuralFeature feature = facet.getFeature(); EClassifier type = feature.getEType(); if (isCheckboxType(type)) { return new CheckboxNullCellEditor(parent); } EPlanElement element = facet.getElement(); if (feature.isMany()) { return new MultiselectCellEditor(parent, element, feature); } if (type instanceof EEnumImpl) { return new EEnumComboBoxCellEditor(parent, (EEnumImpl) type); } if (feature instanceof EAttributeParameter) { EAttributeParameter def = (EAttributeParameter) feature; List<EChoice> choices = def.getChoices(); if (DictionaryUtil.containsOnlyValues(choices)) { return new ChoicesCellEditor(parent, def, choices); } } if (feature instanceof EReference) { final EReference reference = (EReference) feature; ComboBoxViewerCellEditor comboBoxViewerCellEditor = new EReferenceCellEditor(parent, element, reference); return comboBoxViewerCellEditor; } IStringifier<Object> stringifier = null; if (feature instanceof EAttribute) { stringifier = ParameterStringifierUtils.getStringifier((EAttribute) feature); } if (stringifier == null) { return new CocoaCompatibleTextCellEditor(parent); } return new StringifierCellEditor(parent, stringifier); }
private static List getList(EEnumImpl impl) { List list = new ArrayList(); EList<EEnumLiteral> literals = impl.getELiterals(); for (EEnumLiteral literal : literals) { list.add(literal.getInstance()); } return list; }
private EEnum getEEnum(String parameterName) { EParameterDef def = ActivityDictionary.getInstance().getAttributeDef(parameterName); if (def != null) { EGenericType eGenericType = def.getEGenericType(); EClassifier classifier = eGenericType.getEClassifier(); if (classifier instanceof EEnumImpl) { return (EEnum) classifier; } } return null; }
public EEnumComboBoxCellEditor(Composite parent, EEnumImpl impl) { super(parent, getList(impl), new LabelProvider()); }