GritcoAndreea
GritcoAndreea

Reputation: 85

Custom button for toolbar Eclipse RCP Application

I am currently working on a web browser application using Eclipse e4. I want to put on the toolbar a toggle button for saving my favorites url's.

I want it to be like in Google Chrome , a star which gets the yellow color when it's pressed(the link was added to favorites).

How can I do this?

Should I use for this the Application.e4xmi ?

Upvotes: 0

Views: 334

Answers (1)

greg-449
greg-449

Reputation: 111142

You can use the Application.e4xmi if this is a tool bar for a Window or a Part. You would use a 'Handled Tool Item' in the tool bar.

The Application.e4xmi does not provide a way to set separate icons for the selected and normal states of a tool item so you will have to do this in the handler class. Something like:

@Execute
public void execute(MToolItem mitem)
{
  if (mitem.isSelected())
    mitem.setIconURI("platform:/plugin/your.plugin.id/icons/selectedimage.png");
  else
    mitem.setIconURI("platform:/plugin/your.plugin.id/icons/unselectedimage.png");

  // TODO other code
}

Upvotes: 2

Related Questions