Custom tool tips on a GEF palette

Here is a solution to have custom tool tips on a GEF palette.
The solution is not perfect because it relies on non-API code. But it works.

You must use a different EditPartFactory.

PaletteViewer paletteViewer = new PaletteViewer();
paletteViewer.setEditPartFactory( new PaletteEditPartFactory() {

	protected EditPart createEntryEditPart(EditPart parentEditPart, Object model) {
		return new EipToolEntryEditPart((PaletteEntry) model);

This EditPartFactory returns a new kind of edit part for tool entries.

public class EipToolEntryEditPart extends ToolEntryEditPart {

 	public EipToolEntryEditPart( PaletteEntry paletteEntry ) {
		super( paletteEntry );

	protected IFigure createToolTip() {
 		IFigure result = null;
		if( getModel() instanceof CombinedTemplateCreationEntry ) {
 			Object tpl = ((CombinedTemplateCreationEntry) getModel()).getTemplate();
			if( tpl instanceof EIPtype )
				result = new EipPaletteTooltipFigure((EIPtype) tpl);
				result = super.createToolTip();
			result = super.createToolTip();

 		return result;

And here is an example of figure I used.

public class EipPaletteTooltipFigure extends Figure {

 	public EipPaletteTooltipFigure( EIPtype eipType ) {

 		setLayoutManager( new ToolbarLayout());
		setBackgroundColor( ColorConstants.white );
		setOpaque( true );
		setBorder( new CompoundBorder(
					new LineBorder(, 2 ),
					new MarginBorder( 12 )));

 		FontData fontData = new FontData( "Arial", 12, SWT.BOLD );
		Font font = new Font( Display.getDefault(), fontData );

 		Label l = new Label( eipType.getPrettyName());
		l.setFont( font );
		l.setLabelAlignment( PositionConstants.LEFT );
		l.setBorder( new MarginBorder( 0, 4, 12, 4 ));
		add( l );

 		l = new Label( eipType.getExplaination());
		l.setBorder( new MarginBorder( 4, 4, 6, 4 ));
		add( l );


Here is an overview of this tool tip.

A custom tool tip for a GEF palette

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s