EMF.edit gestString multiple editors & cross references [message #1854020] |
Thu, 28 July 2022 09:46 |
Eric Jeunieaux Messages: 3 Registered: December 2017 |
Junior Member |
|
|
Hi,
I'm working on a project that includes several Ecore models that reference each other.
These models are grouped into 3 families; there is one EMF.edit plugin per family.
Dependencies are as follows:
- ModelFamily_1 has no dependency
- ModelFamily_2 depends on ModelsFamily_1
- ModelFamily_3 depends on ModelsFamily_1 and ModelFamily_2
There is one edit plugin for each family (and one editor plugin).
- ModelFamily_1_EditPlugin
- ModelFamily_2_EditPlugin
- ModelFamily_3_EditPlugin
Plugins are generated from the GenModel (no modification to the default generator).
In their constructors, each plugin instantiates a ResourceLocator[] array with a reference to itself and a reference for each of its dependencies.
For the ModelFamily_3_EditPlugin the generated code gives :
ResourceLocator[] = { ModelFamily_3_EditPlugin.INSTANCE, ModelFamily_1_EditPlugin.INSTANCE, ModelFamily_2_EditPlugin.INSTANCE }
(The following happens using an Eclipse runtime; I have not tested with deployed plugins)
In the treeview default editor, when selecting a ModelFamily_3 element extending a ModelFamily_1 element, the name localization of a feature inherited from the Model1Family element is as:
- 1 - try to localize the key using ModelFamily_3_EditPlugin.INSTANCE as resource locator
- 2 - as the localization is in the plugin.properties from the ModelFamily_1_EditPlugin the step 1 thows a new MissingResourceException
-3 - string localization is then delegated to the delegetResourceLocator using the function delegatedGetString(key, translate)
In memory, the delegated resource locators is [null, ModelFamily_1_EditPlugin@2e3f9d29, ModelFamily_2_EditPlugin@1525f2da]]
The system returns a java.lang.NullPointerException on the next instruction because "delegateResourceLocators[0]" is null
ResourceLocator[] delegateResourceLocators = getDelegateResourceLocators();
for (int i = 0; i < delegateResourceLocators.length; ++i) {
try {
return delegateResourceLocators[i].getString(key, translate);
}
catch (MissingResourceException exception) {
// Ignore this since we will throw an exception when all else fails.
}
}
When I remove ModelFamily_3_EditPlugin.INSTANCE from the resource locator array of the ModelFamily_3_EditPlugin, the problem disappears
ResourceLocator[] = { ModelFamily_1_EditPlugin.INSTANCE, ModelFamily_2_EditPlugin.INSTANCE }
There is certainly a reason but why add a reference to the plugin in the delegation as it is already used as primary resource locator ?
public ResourceLocator getPluginResourceLocator() {
return plugin;
}
And according to the answer, how to avoid this null pointer exception ?
Thanks
|
|
|
Re: EMF.edit gestString multiple editors & cross references [message #1854021 is a reply to message #1854020] |
Thu, 28 July 2022 10:09 |
Ed Merks Messages: 32985 Registered: July 2009 |
Senior Member |
|
|
I don't expect that result. What's generated is determined by this: public List<String> getEditResourceDelegateImportedPluginClassNames()
{
List<String> result = new UniqueEList<String>();
for (GenPackage genPackage : getUsedGenPackages())
{
GenModel genModel = genPackage.getGenModel();
if (genModel.hasEditSupport())
{
result.add(genModel.getImportedName(genModel.getQualifiedEditPluginClassName()));
}
}
return result;
} So it would appear that your GenPackage is also among its own used GenPackages.
Is each of these in a separate GenModel? Is each GenModel in a separate project? There's no circularity between the pacakages?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.01564 seconds