-->

Adding a custom renderer to different parts

2019-07-29 16:35发布

问题:

I would like some parts to use a different renderer. In some cases I would like to remove the Detach option when right clicking and this is a solution according to a comment on my question here.

I've been following this tutorial as to how this can be done.

I've created two classes. UndetachableStackRenderer and UndetachableStackRendererFactory.

If I add UndetachableStackRendererFactory to the plugin.xml it successfully removes the option to detach from ALL part stacks.

<property
    name="rendererFactoryUri"
    value="bundleclass://com.example.loc/com.example.loc.UndetachableStackRendererFactory">
</property>

I would instead like to change the renderer for one part stack. According to the tutorial I can add CUSTOM_RENDERER_URI to the Persisted State of the part stack.

Key:

CUSTOM_RENDERER_URI

Value:

bundleclass://com.example.loc/com.example.loc.UndetachableStackRenderer

I've tried this and it does nothing. If I enter an incorrect location it doesn't come up with any errors either so it seems as though CUSTOM_RENDERER_URI isn't being seen.

What could be the cause of this?

回答1:

The tutorial seems to be wrong, at least for the current Eclipse release.

The key value is defined in IPresentationEngine.CUSTOM_RENDERER_KEY and has the value Custom Renderer

String CUSTOM_RENDERER_KEY = "Custom Renderer";

It is used in the getRenderer method of org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine