Example usage for org.eclipse.jface.action ContributionItem fill

List of usage examples for org.eclipse.jface.action ContributionItem fill

Introduction

In this page you can find the example usage for org.eclipse.jface.action ContributionItem fill.

Prototype

@Override
public void fill(CoolBar parent, int index) 

Source Link

Document

The default implementation of this IContributionItem method does nothing.

Usage

From source file:net.tourbook.ui.tourChart.action.ActionSetMarkerLabelPositionMenu.java

License:Open Source License

private void fillMenu(final Menu menu) {

    final int currentLabelPosition = _tourMarker.getLabelPosition();

    for (final ContributionItem contribItem : _allActions) {

        if (contribItem instanceof ActionContributionItem) {

            final ActionContributionItem actionItem = (ActionContributionItem) contribItem;
            final IAction action = actionItem.getAction();

            if (action instanceof ActionSetMarkerPosition) {

                final ActionSetMarkerPosition posAction = (ActionSetMarkerPosition) action;

                final boolean isCurrentPosition = posAction.labelPosId == currentLabelPosition;

                posAction.setChecked(isCurrentPosition);
                posAction.setEnabled(!isCurrentPosition);
            }//from   ww w  .  j a  v a  2  s.  c  om
        }

        contribItem.fill(_menu, -1);
    }
}

From source file:org.eclipse.tcf.te.tcf.ui.views.scriptpad.actions.PeersSubMenuAction.java

License:Open Source License

private Menu getSubMenu(Menu menu) {
    menu.addMenuListener(new MenuAdapter() {
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.MenuAdapter#menuShown(org.eclipse.swt.events.MenuEvent)
         *///w w  w  .ja  v  a2  s.c o  m
        @Override
        public void menuShown(MenuEvent e) {
            ContributionItem item;
            // dispose all "old" menu items before fill up the menu with new ones
            Menu m = (Menu) e.widget;
            MenuItem[] items = m.getItems();
            for (MenuItem item2 : items) {
                item2.dispose();
            }

            // Get the selected peer model
            IPeerNode selected = null;
            if (view instanceof ScriptPad)
                selected = ((ScriptPad) view).getPeerModel();

            boolean selectFirst = selected == null;

            IPeerNode[] peerNodes = ModelManager.getPeerModel().getPeerNodes();
            if (peerNodes != null && peerNodes.length > 0) {
                for (IPeerNode peerNode : peerNodes) {
                    if (isValueAdd(peerNode))
                        continue;
                    Action action = new PeerAction(view, peerNode);
                    if (selectFirst) {
                        action.setChecked(true);
                        selectFirst = false;
                        if (view instanceof ScriptPad)
                            ((ScriptPad) view).setPeerModel(peerNode);
                    } else if (selected != null && selected.equals(peerNode)) {
                        action.setChecked(true);
                        if (view instanceof ScriptPad)
                            ((ScriptPad) view).setPeerModel(peerNode);
                    }
                    item = new ActionContributionItem(action);
                    item.fill(m, -1);
                }
            }
        }
    });

    return menu;
}