Inside my eclipse plugin I want to create this button in a composite:
Where do I get the icon? How do I create that button?
Here's the solution I found by digging a little deeper...
Create an IAction:
private class RemoveCurrentGraphAction extends Action {
@Override
public void run() {
updateWith(new ModuleGraph());
}
public RemoveCurrentGraphAction() {
setToolTipText("Reset to empty graph");
}
@Override
public int getStyle() {
return IAction.AS_PUSH_BUTTON;
}
@Override
public ImageDescriptor getImageDescriptor() {
return PlatformUI.getWorkbench().getSharedImages()
.getImageDescriptor(org.eclipse.ui.ISharedImages.IMG_ELCL_REMOVE);
}
}
Then when creating the view, add the action to the toolbar:
IActionBars bars = getViewSite().getActionBars();
bars.getToolBarManager().add(new RemoveCurrentGraphAction());