protected Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> handleEnumAttribute( org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedTerminal expectedTerminal, org.emftext.language.xpath3.resource.xpath3.mopp.Xpath3ExpectedStructuralFeature expectedFeature, EEnum enumType, String prefix, EObject container) { Collection<EEnumLiteral> enumLiterals = enumType.getELiterals(); Collection<org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal> result = new LinkedHashSet< org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal>(); for (EEnumLiteral literal : enumLiterals) { String unResolvedLiteral = literal.getLiteral(); // use token resolver to get de-resolved value of the literal org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolverFactory tokenResolverFactory = metaInformation.getTokenResolverFactory(); org.emftext.language.xpath3.resource.xpath3.IXpath3TokenResolver tokenResolver = tokenResolverFactory.createTokenResolver(expectedFeature.getTokenName()); String resolvedLiteral = tokenResolver.deResolve(unResolvedLiteral, expectedFeature.getFeature(), container); boolean matchesPrefix = matches(resolvedLiteral, prefix); result.add( new org.emftext.language.xpath3.resource.xpath3.ui.Xpath3CompletionProposal( expectedTerminal, resolvedLiteral, prefix, matchesPrefix, expectedFeature.getFeature(), container)); } return result; }
/** * Converts a primitive type value. For EEnum: this implementation only converts an Enum to an * EEnum value. * * @param value the value to convert * @param eDataType its EDataType * @return the converted value */ protected Object convertEAttributeValue(final Object value, final EDataType eDataType) { if (value instanceof Enum<?>) { final EDataType enumDataType = getDataTypeOrBaseType(eDataType); Check.isInstanceOf(enumDataType, EEnum.class); final EEnum eeNum = (EEnum) enumDataType; for (final EEnumLiteral enumLiteral : eeNum.getELiterals()) { // the code generation template uppercases enum if (enumLiteral.getName().toUpperCase(Locale.ENGLISH).equals(((Enum<?>) value).name())) { return enumLiteral.getInstance(); } } } if (value instanceof Date && eDataType == XMLTypePackage.eINSTANCE.getDate()) { final Date date = (Date) value; final XMLCalendar xmlCalendar = new XMLCalendar(date, XMLCalendar.DATE); final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); xmlCalendar.clear(); xmlCalendar.setYear(calendar.get(Calendar.YEAR)); xmlCalendar.setMonth(1 + calendar.get(Calendar.MONTH)); xmlCalendar.setDay(calendar.get(Calendar.DATE)); // note xmlcalendar expects minutes, calendar gives millis xmlCalendar.setTimezone(calendar.get(Calendar.ZONE_OFFSET) / 60000); return xmlCalendar; } if (value instanceof Date && eDataType == XMLTypePackage.eINSTANCE.getDateTime()) { final Date date = (Date) value; return new XMLCalendar(date, XMLCalendar.DATETIME); } return value; }
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; }
private IScope calculateEnumLiteralScope(EEnum enumeration) { EList<EEnumLiteral> literals = enumeration.getELiterals(); return Scopes.scopeFor( literals, new Function<EEnumLiteral, QualifiedName>() { public QualifiedName apply(EEnumLiteral literal) { QualifiedName qualifiedName = qualifiedNameConverter.toQualifiedName(literal.getLiteral()); return qualifiedName; } }, IScope.NULLSCOPE); }
@Override public List<String> resolveValues(TemplateVariable variable, XtextTemplateContext castedContext) { String enumerationName = (String) variable.getVariableType().getParams().iterator().next(); EEnum enumeration = (EEnum) getEClassifierForGrammar(enumerationName, getGrammar(castedContext)); if (enumeration == null) { return Collections.emptyList(); } return Lists.transform( enumeration.getELiterals(), new Function<EEnumLiteral, String>() { public String apply(EEnumLiteral enumLiteral) { return enumLiteral.getLiteral(); } }); }
/** * {@inheritDoc} * * @see * org.obeonetwork.dsl.uml2.properties.uml.parts.CreationEventPropertiesEditionPart#initVisibility(EEnum * eenum, Enumerator current) */ public void initVisibility(EEnum eenum, Enumerator current) { visibility.setInput(eenum.getELiterals()); visibility.modelUpdating(new StructuredSelection(current)); }
/** * Initializes the annotations for <b>http://www.topcased.org/uuid</b>. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ protected void createUuidAnnotations() { String source = "http://www.topcased.org/uuid"; addAnnotation(this, source, new String[] {"uuid", "11350778856090"}); addAnnotation(containerEClass, source, new String[] {"uuid", "11350778856251"}); addAnnotation(getContainer_Name(), source, new String[] {"uuid", "11350778856252"}); addAnnotation(getContainer_PackageName(), source, new String[] {"uuid", "11350778856253"}); addAnnotation(getContainer_Incomplete(), source, new String[] {"uuid", "11350778856254"}); addAnnotation(getContainer_Deployments(), source, new String[] {"uuid", "11350778856255"}); addAnnotation(getContainer_DeploymentGroups(), source, new String[] {"uuid", "11350778856256"}); addAnnotation(getContainer_AllDeployments(), source, new String[] {"uuid", "11350778856407"}); addAnnotation(deploymentEClass, source, new String[] {"uuid", "11350778856408"}); addAnnotation(getDeployment_Component(), source, new String[] {"uuid", "11350778856409"}); addAnnotation(getDeployment_Id(), source, new String[] {"uuid", "113507788564010"}); addAnnotation(getDeployment_Type(), source, new String[] {"uuid", "113507788564011"}); addAnnotation(getDeployment_Singleton(), source, new String[] {"uuid", "113507788564012"}); addAnnotation(getDeployment_Lazy(), source, new String[] {"uuid", "113507788564013"}); addAnnotation(getDeployment_Prototype(), source, new String[] {"uuid", "113507788564014"}); addAnnotation(getDeployment_Initialized(), source, new String[] {"uuid", "113507788565615"}); addAnnotation(getDeployment_Container(), source, new String[] {"uuid", "113507788565616"}); addAnnotation( getDeployment_DeploymentGroup(), source, new String[] {"uuid", "113507788565617"}); addAnnotation(getDeployment_Dependencies(), source, new String[] {"uuid", "113507788565618"}); addAnnotation(getDeployment_Creators(), source, new String[] {"uuid", "113507788565619"}); addAnnotation(getDeployment_Listeners(), source, new String[] {"uuid", "113507788565620"}); addAnnotation(getDeployment_Referers(), source, new String[] {"uuid", "113507788565621"}); addAnnotation(getDeployment_Root(), source, new String[] {"uuid", "113507788565622"}); addAnnotation(getDeployment_Depends(), source, new String[] {"uuid", "113568774160969"}); addAnnotation(deploymentGroupEClass, source, new String[] {"uuid", "113507788567123"}); addAnnotation(getDeploymentGroup_Container(), source, new String[] {"uuid", "113507788567124"}); addAnnotation(getDeploymentGroup_SubGroups(), source, new String[] {"uuid", "113507788567125"}); addAnnotation( getDeploymentGroup_SuperGroup(), source, new String[] {"uuid", "113507788567126"}); addAnnotation( getDeploymentGroup_Deployments(), source, new String[] {"uuid", "113507788567127"}); addAnnotation(getDeploymentGroup_Name(), source, new String[] {"uuid", "113507788567128"}); addAnnotation(parameterEClass, source, new String[] {"uuid", "113507788567129"}); addAnnotation( (EOperation) parameterEClass.getEOperations().get(0), source, new String[] {"uuid", "113507788567130"}); addAnnotation(dependencyEClass, source, new String[] {"uuid", "113507788568731"}); addAnnotation(getDependency_Feature(), source, new String[] {"uuid", "113507788568732"}); addAnnotation(getDependency_Deployment(), source, new String[] {"uuid", "113507788568733"}); addAnnotation(referenceEClass, source, new String[] {"uuid", "113507788568734"}); addAnnotation(getReference_Target(), source, new String[] {"uuid", "113507788568735"}); addAnnotation(getReference_Listen(), source, new String[] {"uuid", "113507788568736"}); addAnnotation(integerParameterEClass, source, new String[] {"uuid", "113507788568737"}); addAnnotation(getIntegerParameter_Value(), source, new String[] {"uuid", "113507788568738"}); addAnnotation(longParameterEClass, source, new String[] {"uuid", "113507788570339"}); addAnnotation(getLongParameter_Value(), source, new String[] {"uuid", "113507788570340"}); addAnnotation(floatParameterEClass, source, new String[] {"uuid", "113507788570341"}); addAnnotation(getFloatParameter_Value(), source, new String[] {"uuid", "113507788570342"}); addAnnotation(doubleParameterEClass, source, new String[] {"uuid", "113507788570343"}); addAnnotation(getDoubleParameter_Value(), source, new String[] {"uuid", "113507788570344"}); addAnnotation(booleanParameterEClass, source, new String[] {"uuid", "113507788570345"}); addAnnotation(getBooleanParameter_Value(), source, new String[] {"uuid", "113507788571846"}); addAnnotation(stringParameterEClass, source, new String[] {"uuid", "113507788571847"}); addAnnotation(getStringParameter_Value(), source, new String[] {"uuid", "113507788571848"}); addAnnotation(charParameterEClass, source, new String[] {"uuid", "113507788571849"}); addAnnotation(getCharParameter_Value(), source, new String[] {"uuid", "113507788571850"}); addAnnotation(creatorEClass, source, new String[] {"uuid", "113507788571851"}); addAnnotation(getCreator_Operation(), source, new String[] {"uuid", "113507788571852"}); addAnnotation(getCreator_Deployment(), source, new String[] {"uuid", "113507788573453"}); addAnnotation(getCreator_Product(), source, new String[] {"uuid", "113507788573454"}); addAnnotation(listenerEClass, source, new String[] {"uuid", "113507788573455"}); addAnnotation(getListener_Deployment(), source, new String[] {"uuid", "113507788573456"}); addAnnotation(getListener_Notifier(), source, new String[] {"uuid", "113507788573457"}); addAnnotation(deploymentTypeEEnum, source, new String[] {"uuid", "113507788573458"}); addAnnotation( (EEnumLiteral) deploymentTypeEEnum.getELiterals().get(0), source, new String[] {"uuid", "113507788573459"}); addAnnotation( (EEnumLiteral) deploymentTypeEEnum.getELiterals().get(1), source, new String[] {"uuid", "113507788573460"}); addAnnotation( (EEnumLiteral) deploymentTypeEEnum.getELiterals().get(2), source, new String[] {"uuid", "113507788573461"}); }