Example usage for org.eclipse.jface.action Action getMenuCreator

List of usage examples for org.eclipse.jface.action Action getMenuCreator

Introduction

In this page you can find the example usage for org.eclipse.jface.action Action getMenuCreator.

Prototype

@Override
    public IMenuCreator getMenuCreator() 

Source Link

Usage

From source file:org.rssowl.ui.internal.OwlUI.java

License:Open Source License

/**
 * @param action the dropdown action.//from  ww w.j  a  v  a 2s .  com
 * @param manager the toolbar containing the action.
 */
public static void positionDropDownMenu(Action action, ToolBarManager manager) {
    Menu menu = action.getMenuCreator().getMenu(manager.getControl());
    if (menu != null) {

        /* Adjust Location */
        IContributionItem contributionItem = manager.find(action.getId());
        if (contributionItem != null && contributionItem instanceof ActionContributionItem) {
            Widget widget = ((ActionContributionItem) contributionItem).getWidget();
            if (widget != null && widget instanceof ToolItem) {
                ToolItem item = (ToolItem) widget;
                Rectangle rect = item.getBounds();
                Point pt = new Point(rect.x, rect.y + rect.height);
                pt = manager.getControl().toDisplay(pt);
                if (Application.IS_MAC)
                    pt.y += 5;
                menu.setLocation(pt.x, pt.y);
            }
        }

        /* Set Visible */
        menu.setVisible(true);
    }
}