Ned Twigg
Ned Twigg

Reputation: 2224

Disabling the Maximize/Minimize trim space in Eclipse RCP 4

In Eclipse 3 and Eclipse 4, an EditorSashContainer looks like this when it has one EditorStack:

EditorSashContainer with one EditorStack

in Eclipse 4, it adds extra trim (which I've colored red) when there are multiple EditorStacks, which it didn't do in Eclipse 3:

EditorSashContainer with multiple EditorStacks

I understand that now that we're in E4, there's no such thing as Editor, EditorStack, and EditorSashContainer , just Part, PartStack, and PartSashContainer. But there is something different between this "root" PartSashContainer and "regular" PartSashContainer, because only this "root" one has the maximize/minimize buttons and the extra trim:

PartSashContainers with and without trim

My question is this:

My custom RCP application only has one "root" PartSashContainer, and it's unsettling for this extra trim to come and go. I have mucked with application.css, and even gone as far as forking org.eclipse.e4.ui.workbench.addons.swt, but I'm stuck.

Upvotes: 1

Views: 1111

Answers (1)

Ned Twigg
Ned Twigg

Reputation: 2224

Welp, it ain't pretty, but I found a way. Thanks to greg-449 for the crucial MArea hint.

You can set the rendererFactoryUri by adding a snippet like this to your product extension:

<property
    name="rendererFactoryUri"
    value="bundleclass://com.myplugin/package.to.MyWorkbenchRendererFactory">
</property>

If you don't set it, Eclipse uses this by default.

If you set the renderer for MArea to be the regular MPartSashContainer's renderer, it just works.

Here's my code:

import org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.advanced.MArea;
import org.eclipse.e4.ui.workbench.renderers.swt.SashRenderer;
import org.eclipse.e4.ui.workbench.renderers.swt.WorkbenchRendererFactory;

public class MyWorkbenchRendererFactory extends WorkbenchRendererFactory {
    private SashRenderer areaRenderer;

    @Override
    public AbstractPartRenderer getRenderer(MUIElement uiElement, Object parent) {
        if (uiElement instanceof MArea) {
            if (areaRenderer == null) {
                areaRenderer = new SashRenderer();
                initRenderer(areaRenderer);
            }
            return areaRenderer;
        } else {
            return super.getRenderer(uiElement, parent);
        }
    }
}

Of course, now the "Minimize/Maximize" buttons will be rendered strangely, but I disable them anyway, so fixing that part is your problem ;-).

Upvotes: 1

Related Questions