Skip to main content



      Home
Home » Modeling » EMF » Dynamic enum literal/caption for editor(How to load the caption for enum values from other files than the prlugin.properties)
Dynamic enum literal/caption for editor [message #1864903] Fri, 19 April 2024 11:06 Go to next message
Eclipse UserFriend
Hi,

I have an EMF model for which I generate the example editor.

That model contains an enum that represents an abstract type. I want the user to be able to provide the literals for the values of the enum. This is intended for the UI only, internals shall remain untouched.

If I modify the respective entries in the plugin.properties file of the editor I get the expected behavior. However, I want to load the strings from another file.

Overwriting getLabelProvider of the respective ItemPropertyDescriptor seems to do the trick but then I have to do this modification for every property where I use the enum. Is there another way?

[Updated on: Fri, 19 April 2024 11:26] by Moderator

Re: Dynamic enum literal/caption for editor [message #1864932 is a reply to message #1864903] Sat, 20 April 2024 05:19 Go to previous messageGo to next message
Eclipse UserFriend
You could add an override for xyz.XyzEditPlugin.Implementation.getString(String, boolean) and intercept the keys for which you want special translations rather than the translations from the plugin.properties.
Re: Dynamic enum literal/caption for editor [message #1864965 is a reply to message #1864932] Mon, 22 April 2024 06:07 Go to previous message
Eclipse UserFriend
Hi Ed!

Thanks for the hint! This works fine:
package xyz.provider;

[...]

public final class xyzEditPlugin extends EMFPlugin {
	
	[...]

	public static class Implementation extends EclipsePlugin {
	
		[...]

		@Override
		public String getString(String key, boolean translate) {

			return super.getString(key, translate);
		}
	}
}


However, I have to identify the project from which this is called as the file containing the labels is project specific.

As far as I understand this is not possible at this location. I played with
org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot()
but it seems it cannot do what I want since the plugin is a shared resource.

I also checked the call stack and tried a few things but to me it seems like
org.eclipse.emf.edit.ui.provider.PropertyDescriptor.getLabelProvider()
is the last context aware of the corresponding EObject and thus the model. Instead of overwriting getLabelProvider for each ItemPropertyDescriptor, could I do it "centralized" without the need to modify the ItemProvider for each class?

Regards
Thomas

[Updated on: Tue, 23 April 2024 05:03] by Moderator

Previous Topic:Library Upgrade Issues
Next Topic:CDO attributes and references
Goto Forum:
  


Current Time: Sat Aug 30 16:20:16 EDT 2025

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

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

Back to the top