Java Code Examples for org.eclipse.emf.ecore.EEnumLiteral.getLiteral()

The following are Jave code examples for showing how to use getLiteral() of the org.eclipse.emf.ecore.EEnumLiteral class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DarwinSPL   File: DwprofileCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal> handleEnumAttribute(de.darwinspl.preferences.resource.dwprofile.mopp.DwprofileExpectedTerminal expectedTerminal, de.darwinspl.preferences.resource.dwprofile.mopp.DwprofileExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal> result = new LinkedHashSet<de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		de.darwinspl.preferences.resource.dwprofile.IDwprofileTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		de.darwinspl.preferences.resource.dwprofile.IDwprofileTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new de.darwinspl.preferences.resource.dwprofile.ui.DwprofileCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 2
Project: DarwinSPL   File: HyexpressionCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal> handleEnumAttribute(eu.hyvar.feature.expression.resource.hyexpression.mopp.HyexpressionExpectedTerminal expectedTerminal, eu.hyvar.feature.expression.resource.hyexpression.mopp.HyexpressionExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal> result = new LinkedHashSet<eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		eu.hyvar.feature.expression.resource.hyexpression.IHyexpressionTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new eu.hyvar.feature.expression.resource.hyexpression.ui.HyexpressionCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 3
Project: DarwinSPL   File: HyvalidityformulaCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal> handleEnumAttribute(eu.hyvar.context.contextValidity.resource.hyvalidityformula.mopp.HyvalidityformulaExpectedTerminal expectedTerminal, eu.hyvar.context.contextValidity.resource.hyvalidityformula.mopp.HyvalidityformulaExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal> result = new LinkedHashSet<eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		eu.hyvar.context.contextValidity.resource.hyvalidityformula.IHyvalidityformulaTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new eu.hyvar.context.contextValidity.resource.hyvalidityformula.ui.HyvalidityformulaCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 4
Project: DarwinSPL   File: HydatavalueCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal> handleEnumAttribute(eu.hyvar.dataValues.resource.hydatavalue.mopp.HydatavalueExpectedTerminal expectedTerminal, eu.hyvar.dataValues.resource.hydatavalue.mopp.HydatavalueExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal> result = new LinkedHashSet<eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		eu.hyvar.dataValues.resource.hydatavalue.IHydatavalueTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new eu.hyvar.dataValues.resource.hydatavalue.ui.HydatavalueCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 5
Project: DarwinSPL   File: HymappingCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal> handleEnumAttribute(eu.hyvar.feature.mapping.resource.hymapping.mopp.HymappingExpectedTerminal expectedTerminal, eu.hyvar.feature.mapping.resource.hymapping.mopp.HymappingExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal> result = new LinkedHashSet<eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		eu.hyvar.feature.mapping.resource.hymapping.IHymappingTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		eu.hyvar.feature.mapping.resource.hymapping.IHymappingTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new eu.hyvar.feature.mapping.resource.hymapping.ui.HymappingCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 6
Project: DarwinSPL   File: HyconstraintsCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal> handleEnumAttribute(eu.hyvar.feature.constraint.resource.hyconstraints.mopp.HyconstraintsExpectedTerminal expectedTerminal, eu.hyvar.feature.constraint.resource.hyconstraints.mopp.HyconstraintsExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal> result = new LinkedHashSet<eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		eu.hyvar.feature.constraint.resource.hyconstraints.IHyconstraintsTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new eu.hyvar.feature.constraint.resource.hyconstraints.ui.HyconstraintsCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 7
Project: DarwinSPL   File: HymanifestCodeCompletionHelper.java   Source Code and License Vote up 5 votes
protected Collection<eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal> handleEnumAttribute(eu.hyvar.mspl.manifest.resource.hymanifest.mopp.HymanifestExpectedTerminal expectedTerminal, eu.hyvar.mspl.manifest.resource.hymanifest.mopp.HymanifestExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) {
	Collection<EEnumLiteral> enumLiterals = enumType.getELiterals();
	Collection<eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal> result = new LinkedHashSet<eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal>();
	for (EEnumLiteral literal : enumLiterals) {
		String unResolvedLiteral = literal.getLiteral();
		// use token resolver to get de-resolved value of the literal
		eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestTokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory();
		eu.hyvar.mspl.manifest.resource.hymanifest.IHymanifestTokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName());
		String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container);
		boolean matchesPrefix = matches(resolvedLiteral, prefix);
		result.add(new eu.hyvar.mspl.manifest.resource.hymanifest.ui.HymanifestCompletionProposal(expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container));
	}
	return result;
}
 
Example 8
Project: OpenSPIFe   File: ProfileUtil.java   Source Code and License Vote up 5 votes
public static String getDisplayString(Profile profile, Object currentValue) {
	if (currentValue != null) {
		if (currentValue instanceof Number) {
			Unit units = profile.getUnits();
			if ((units == null) || (units == Unit.ONE) || units == BINARY_CHOICE) {
				return NUMBER_FORMAT.format(currentValue);
			}
			currentValue = AmountUtils.valueOf((Number)currentValue, units);
		}
		if (currentValue instanceof String) {
			return currentValue.toString();
		}
		if (currentValue instanceof Boolean) {
			return currentValue.toString();
		}
		if (currentValue instanceof EEnumLiteral) {
			EEnumLiteral eEnumLiteral = (EEnumLiteral) currentValue;
			return eEnumLiteral.getLiteral();
		}
		if (currentValue instanceof Amount) {
			return EnsembleAmountFormat.INSTANCE.formatAmount((Amount) currentValue);
		}
		if (currentValue instanceof PowerValue) {
			return getDisplayString(profile, ((PowerValue)currentValue).getStateValue());
		}
		@SuppressWarnings("unchecked")
		IStringifier stringifier = StringifierRegistry.getStringifier(currentValue.getClass());
		return stringifier.getDisplayString(currentValue);
	}
	return "N/A";
}
 
Example 9
Project: OpenSPIFe   File: ADParameterUtils.java   Source Code and License Vote up 5 votes
/**
 * If the parameter is an EEnum, it is set to the first available literal which equalsIgnoreCase matches newValue
 * 
 * @param element
 * @param parameterName
 * @param newValue
 * @return The value the parameter was set to, in its proper case.
 * @throws UndefinedParameterException
 */
public static String setParameterStringCaseInsensitive(EPlanElement element, String parameterName, String newValue) throws UndefinedParameterException {
	EObject data = element.getData();
	EStructuralFeature feature = getParameterFeature(data, parameterName);
	EClassifier type = feature.getEType();
	if (type instanceof EEnum) {
		EEnum enumType = (EEnum) type;
		EEnumLiteral literalValue = getCaseInsensitiveValue(enumType, newValue);
		data.eSet(feature, literalValue);
		return literalValue == null ? null : literalValue.getLiteral();
	} else {
		setParameterString(element, parameterName, newValue);
		return newValue;
	}
}
 
Example 10
Project: OpenSPIFe   File: ADParameterUtils.java   Source Code and License Vote up 5 votes
public static String addParameterStringToListCaseInsensitive(EPlanElement element, String parameterName, String newValue) throws UndefinedParameterException {
	EObject data = element.getData();
	EStructuralFeature feature = getParameterFeature(data, parameterName);
	EClassifier type = feature.getEType();
	if (type instanceof EEnum) {
		EEnum enumType = (EEnum) type;
		EEnumLiteral literal = getCaseInsensitiveValue(enumType, newValue);
		addParameterObjectToList(element, parameterName, literal);
		return literal == null ? null : literal.getLiteral();
	} else {
		addParameterStringToList(element, parameterName, newValue);
		return newValue;
	}
}
 
Example 11
Project: OpenSPIFe   File: ADParameterUtils.java   Source Code and License Vote up 5 votes
private static Map<String, EEnumLiteral> cacheLiterals(EEnum enumType) {
	Map<String, EEnumLiteral> map = new HashMap<String, EEnumLiteral>();
	EList<EEnumLiteral> literals = enumType.getELiterals();
	for (EEnumLiteral literal : literals) {
		String literalString = literal.getLiteral();
		map.put(literalString.toUpperCase(), literal);
	}
	literalValues.put(enumType, map);
	return map;
}
 
Example 12
Project: waqtsalat-eclipse-plugin   File: MainPrefsPage.java   Source Code and License Vote up 5 votes
private String[][] getJuristicMethods() {
    EList<EEnumLiteral> eLiterals = WaqtSalatPackage.Literals.JURISTIC_METHOD.getELiterals();
    final String[][] result = new String[eLiterals.size()][2];
    int i = 0;
    for (Iterator<EEnumLiteral> iterator = eLiterals.iterator(); iterator.hasNext();) {
        EEnumLiteral eEnumLiteral = (EEnumLiteral) iterator.next();
        result[i][0] = eEnumLiteral.getLiteral();
        result[i][1] = eEnumLiteral.getLiteral();
        i++;
    }
    return result;
}