开发者

How do I create this button in an eclipse plugin

Inside my eclipse plugin I want to create this button in 开发者_如何学Ca composite:

How do I create this button in an eclipse plugin

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜