[EMFForms] Render and RenderTester in different Bundles [message #1555051] |
Fri, 09 January 2015 15:29 |
Phil Wim Messages: 89 Registered: October 2013 |
Member |
|
|
Hi,
I tried to setup render and rendertester in different bundles, to archive project specific rendertesters.
In my case it's not working because the render needs the corresponding rendertester in the same bundle, same for rendertester.
I took a look to SWTRenderFactoryImpl.readBundle and saw that this is the actual behavior.
loadClass(configurationElement.getContributor().getName()...
Therefore I patched the renders.exsd to add a optional bundle name as string. Maybe there's a nicer way to archive that instead of a string. But this did the trick. Here's the modified readRender
private void readRenderer() {
final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(RENDER_EXTENSION);
for (final IExtension extension : extensionPoint.getExtensions()) {
for (final IConfigurationElement configurationElement : extension.getConfigurationElements()) {
try {
// PATCH START
String bundleName = configurationElement.getContributor().getName();
if (configurationElement.getAttribute("bundle") != null
&& !configurationElement.getAttribute("bundle").isEmpty()
&& Platform.getBundle(configurationElement.getAttribute("bundle")) != null) {
bundleName = configurationElement.getAttribute("bundle");
}
//ORIG:final Class<AbstractSWTRenderer<VElement>> renderer = loadClass(configurationElement.getContributor().getName(), configurationElement.getAttribute("renderer")); //$NON-NLS-1$
final Class<AbstractSWTRenderer<VElement>> renderer = loadClass(bundleName, configurationElement.getAttribute("renderer")); //$NON-NLS-1$
// PATCH END
final Set<ECPRendererTester> tester = new LinkedHashSet<ECPRendererTester>();
for (final IConfigurationElement testerExtension : configurationElement.getChildren()) {
if (TEST_DYNAMIC.equals(testerExtension.getName())) {
tester.add((ECPRendererTester) testerExtension.createExecutableExtension(RENDERER_TESTER));
} else if (TEST_STATIC.equals(testerExtension.getName())) {
final int priority = Integer.parseInt(testerExtension.getAttribute(TESTER_PRIORITY));
final String vElement = testerExtension.getAttribute(TESTER_VELEMENT);
final Class<? extends VElement> supportedEObject = loadClass(testerExtension.getContributor().getName(), vElement);
tester.add(new ECPStaticRendererTester(priority, supportedEObject));
}
}
rendererDescriptors.add(new ECPRendererDescription(renderer, tester));
} catch (final CoreException ex) {
ex.printStackTrace();
} catch (final ClassNotFoundException e) {
e.printStackTrace();
} catch (final InvalidRegistryObjectException e) {
e.printStackTrace();
}
}
}
}
Or is there a different way to archive that? When exactly do i use additionalRenders extension point?
Cheers
Philippe
[Updated on: Fri, 09 January 2015 15:29] Report message to a moderator
|
|
|
Re: [EMFForms] [message #1556494 is a reply to message #1555051] |
Sat, 10 January 2015 10:58 |
Jonas Helming Messages: 699 Registered: July 2009 |
Senior Member |
|
|
Hi,
I see your issue. I acually wonder, why "createExecutableExtension" is
not used here. This would IMHO solve the problem.
Could you kindly report a BR for this and add me to CC?
Best regards
Jonas
Am 09.01.2015 um 16:29 schrieb Phil Wim:
> Hi,
>
> I tried to setup render and rendertester in different bundles, to
> archive project specific rendertesters.
> In my case it's not working because the render needs the corresponding
> rendertester in the same bundle, same for rendertester.
> I took a look to SWTRenderFactoryImpl.readBundle and saw that this is
> the actual behavior.
> loadClass(configurationElement.getContributor().getName()...
> Therefore I patched the renders.exsd to add a optional bundle name as
> string. Maybe there's a nicer way to archive that instead of a string.
> But this did the trick. Here's the modified readRender
> private void readRenderer() {
> final IExtensionPoint extensionPoint =
> Platform.getExtensionRegistry().getExtensionPoint(RENDER_EXTENSION);
> for (final IExtension extension : extensionPoint.getExtensions()) {
>
> for (final IConfigurationElement configurationElement :
> extension.getConfigurationElements()) {
> try {
> // PATCH START
> String bundleName =
> configurationElement.getContributor().getName();
> if (configurationElement.getAttribute("bundle") != null
> &&
> !configurationElement.getAttribute("bundle").isEmpty()
> &&
> Platform.getBundle(configurationElement.getAttribute("bundle")) != null) {
> bundleName =
> configurationElement.getAttribute("bundle");
> }
> //ORIG:final Class<AbstractSWTRenderer<VElement>>
> renderer = loadClass(configurationElement.getContributor().getName(),
> configurationElement.getAttribute("renderer")); //$NON-NLS-1$
> final Class<AbstractSWTRenderer<VElement>> renderer
> = loadClass(bundleName, configurationElement.getAttribute("renderer"));
> //$NON-NLS-1$
> // PATCH END
>
> final Set<ECPRendererTester> tester = new
> LinkedHashSet<ECPRendererTester>();
> for (final IConfigurationElement testerExtension :
> configurationElement.getChildren()) {
> if
> (TEST_DYNAMIC.equals(testerExtension.getName())) {
> tester.add((ECPRendererTester)
> testerExtension.createExecutableExtension(RENDERER_TESTER));
> } else if
> (TEST_STATIC.equals(testerExtension.getName())) {
>
> final int priority =
> Integer.parseInt(testerExtension.getAttribute(TESTER_PRIORITY));
>
> final String vElement =
> testerExtension.getAttribute(TESTER_VELEMENT);
> final Class<? extends VElement>
> supportedEObject = loadClass(testerExtension.getContributor().getName(),
> vElement);
>
> tester.add(new
> ECPStaticRendererTester(priority, supportedEObject));
> }
> }
>
> rendererDescriptors.add(new
> ECPRendererDescription(renderer, tester));
> } catch (final CoreException ex) {
> ex.printStackTrace();
> } catch (final ClassNotFoundException e) {
> e.printStackTrace();
> } catch (final InvalidRegistryObjectException e) {
> e.printStackTrace();
> }
> }
> }
> }
>
> Or is there a different way to archive that? When exactly do i use
> additionalRenders extension point?
>
> Cheers
> Philippe
--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03656 seconds