How do I disable/remove the Palette of an Eclipse Graphiti editor?

935 Views Asked by At

Trying to remove the palette of a Eclipse Graphiti editor.

org.eclipse.graphiti.ui.editor.DiagramBehavior has a createPaletteBehaviour() to override but if I return null, the editor crashes.

I also tried this in the diagram behavior, but I actually don't want it collapsed but removed:

@Override
protected DefaultPaletteBehavior createPaletteBehaviour() {
    return new DefaultPaletteBehavior(this) {
        @Override
        public FlyoutPreferences getPalettePreferences() {
            FlyoutPreferences palettePreferences = super.getPalettePreferences();
            palettePreferences.setPaletteState(FlyoutPaletteComposite.STATE_COLLAPSED);
            return palettePreferences;
        }
    };
}

I would also prefer to use some API instead of manipulating the preferences.

2

There are 2 best solutions below

1
On BEST ANSWER

I just got a reply in the eclipse forum: https://www.eclipse.org/forums/index.php/m/1698886/

"you can override isShowFlyoutPalette() in your tool behavior provider and return false there to hide the palette."

This is what I was looking for.

0
On

This is the hack I came up with, there is a org.eclipse.gef.ui.palette.FlyoutPaletteComposite.STATE_HIDDEN with the value "8", since the constant is private (and probably should not be used) I have to set it directly.

@Override
protected DefaultPaletteBehavior createPaletteBehaviour() {
    return new DefaultPaletteBehavior(this) {
        @Override
        public FlyoutPreferences getPalettePreferences() {
            FlyoutPreferences palettePreferences = super.getPalettePreferences();
            palettePreferences.setPaletteState(8);
            return palettePreferences;
        }
    };
}

But as mentioned I would prefer API instead of this preferences hack.