Skip to main content



      Home
Home » Modeling » EMF » How to get a localized name of EEnumLiteral
How to get a localized name of EEnumLiteral [message #1865775] Sat, 11 May 2024 11:29 Go to next message
Eclipse UserFriend
Hi

Could you please suggest how to get a localized name of an EEnumLiteral from properties file?

If I know an edit-plugin defining the EEnum then I can use the following statement:
XyzEditPlugin.INSTANCE.getString("_UI_EnumName_LITERAL_literal")


But what if I have an EObject and EAttribute (with EEnum type) only. And I don't know which plugin to use to find the string? How to get a localized list of available values for the attribute?
Re: How to get a localized name of EEnumLiteral [message #1865778 is a reply to message #1865775] Sat, 11 May 2024 13:11 Go to previous messageGo to next message
Eclipse UserFriend
There's nothing stopping you from defining your own properties wherever you like.

You mention "the attribute" which suggests that likely you have an EObject with an EAttribute of type EEnum. So you could do the following rather long convoluted this:
    ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    TextModifyTask textModifyTask = SetupFactory.eINSTANCE.createTextModifyTask();  // The object with an attribute of type EEnum.
    AdapterFactoryItemDelegator adapterFactoryItemDelegator = new AdapterFactoryItemDelegator(adapterFactory);
    IItemPropertyDescriptor propertyDescriptor = adapterFactoryItemDelegator.getPropertyDescriptor(textModifyTask,
        SetupPackage.Literals.SETUP_TASK__SCOPE_TYPE);  // The EAttribute
    String text = propertyDescriptor.getLabelProvider(textModifyTask).getText(ScopeType.INSTALLATION); // The enum literal value
Re: How to get a localized name of EEnumLiteral [message #1865781 is a reply to message #1865778] Sat, 11 May 2024 14:34 Go to previous message
Eclipse UserFriend
Thanks a lot! It works!
Previous Topic:UI Issue with using Modeling Nature
Next Topic:EEnum value serialization in xml file
Goto Forum:
  


Current Time: Sat Jul 05 08:57:28 EDT 2025

Powered by FUDForum. Page generated in 0.11223 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top