1

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.

flavio.donze
  • 6,077
  • 9
  • 41
  • 69

2 Answers2

1

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.

flavio.donze
  • 6,077
  • 9
  • 41
  • 69
  • 2
    FYI: As far as I know, Graphiti internally also uses the hack described in your previous [answer](http://stackoverflow.com/a/30908505/), as GEF does not provide an API method to hide the FlyoutPalette. (This is just meant as background info) – tjalling Jul 29 '15 at 09:18
0

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.

flavio.donze
  • 6,077
  • 9
  • 41
  • 69