How do I create this button in an eclipse plugin
Inside my eclipse plugin I want to create this button in 开发者_如何学Ca 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());
Just import the plugin org.eclipse.ui (Import -> Plug-ins and Fragments) and search the icon. I found an icon very similar (eclipse 4.2) located at icons/full/dlcl16/progress_rem.gif
精彩评论