Dynamic enum literal/caption for editor [message #1864903] |
Fri, 19 April 2024 11:06  |
Eclipse User |
|
|
|
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 #1864965 is a reply to message #1864932] |
Mon, 22 April 2024 06:07  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04628 seconds