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

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

Introduction

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

Prototype

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

Source Link

Document

The ActionContributionItem implementation of this , IContributionItem method creates an SWT ToolItem for the action using the action's style.

Usage

From source file:com.amazonaws.eclipse.ec2.utils.MenuAction.java

License:Apache License

/**
 * Use to add different MenuItems to the menu
 * /*from   ww w. ja va  2  s. c  o  m*/
 * @param action
 *            The Action to be added
 */
protected void addActionToMenu(IAction action) {
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(menu, -1);
}

From source file:com.android.ide.eclipse.adt.internal.lint.RunLintAction.java

License:Open Source License

private void addAction(IAction action) {
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(mMenu, -1);
}

From source file:com.aptana.ruby.internal.rake.actions.RakeTasksContributionItem.java

License:Open Source License

@Override
public void fill(Menu menu, int index) {
    IProject project = getProject();// ww  w .j a  v  a  2 s  . co m
    if (project == null) {
        return;
    }
    Map<String, String> tasks = getRakeHelper().getTasks(project, new NullProgressMonitor());

    fNamespaces = new HashMap<String, MenuManager>();
    // Please note that tehre's a lot of code mixed up in here to ensure that the menus, items and sub-menus all
    // appear alphabetically
    List<String> values = new ArrayList<String>(tasks.keySet());
    Collections.sort(values);
    for (String task : values) {
        String[] paths = task.split(RAKE_NAMESPACE_DELIMETER);
        if (paths.length == 1) {
            IAction action = new RunRakeAction(project, task, tasks.get(task));
            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(menu, -1);
        } else {
            MenuManager manager = getOrCreate(paths);
            manager.add(new RunRakeAction(project, task, tasks.get(task)));
        }
    }
    values = new ArrayList<String>(fNamespaces.keySet());
    Collections.sort(values);
    Collections.reverse(values);
    for (String path : values) {
        MenuManager manager = fNamespaces.get(path);
        String[] parts = path.split(RAKE_NAMESPACE_DELIMETER);
        if (parts.length == 1) {
            int index2 = getInsertIndex(menu, manager);
            manager.fill(menu, index2);
        } else {
            MenuManager parent = getParent(parts);
            if (parent != null) {
                int index2 = getInsertIndex(parent, manager);
                parent.insert(index2, manager);
            } else {
                int index2 = getInsertIndex(menu, manager);
                manager.fill(menu, index2);
            }
        }
    }
}

From source file:com.architexa.org.eclipse.gef.ui.palette.LayoutAction.java

License:Open Source License

/**
 * Helper method that wraps the given action in an ActionContributionItem and then adds it
 * to the given menu./*from   w  ww  . j  ava2s . c om*/
 * 
 * @param   parent   The menu to which the given action is to be added
 * @param   action   The action that is to be added to the given menu
 */
protected void addActionToMenu(Menu parent, IAction action) {
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(parent, -1);
}

From source file:com.elphel.vdt.ui.views.ContextsAction.java

License:Open Source License

public Menu getMenu(Control parent) {
    if (menu != null) {
        menu.dispose();/*www . ja v a  2 s .c  om*/
    }

    menu = new Menu(parent);
    for (Iterator<Context> i = contexts.iterator(); i.hasNext();) {
        Context context = (Context) i.next();
        if (context.isVisible()) {
            Action action = createContextAction(context);
            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(menu, -1);
        }
    }
    return menu;
}

From source file:com.google.dart.tools.search.internal.ui.OpenSearchDialogPageAction.java

License:Open Source License

private void addToMenu(Menu localMenu, IAction action, int accelerator) {
    StringBuffer label = new StringBuffer();
    if (accelerator >= 0 && accelerator < 10) {
        //add the numerical accelerator
        label.append('&');
        label.append(accelerator);/*  www.  j a v a2  s .  com*/
        label.append(' ');
    }
    label.append(action.getText());
    action.setText(label.toString());
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(localMenu, -1);
}

From source file:com.google.dart.tools.search2.internal.ui.SearchHistoryDropDownAction.java

License:Open Source License

protected void addActionToMenu(Menu parent, Action action) {
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(parent, -1);
}

From source file:com.ibm.xsp.extlib.designer.bluemix.action.ToolbarAction.java

License:Open Source License

protected void addToMenu(Menu menu, IAction action) {
    ActionContributionItem item = new ActionContributionItem(action);
    item.fill(menu, -1);
}

From source file:com.liferay.ide.project.ui.action.NewPluginProjectDropDownAction.java

License:Open Source License

public Menu getMenu(Control parent) {
    if (fMenu == null) {
        fMenu = new Menu(parent);

        NewWizardAction[] actions = getNewProjectActions();

        // Separator separator = null;
        ////from   www. j  av  a 2s .co m
        // for (NewWizardAction action : actions) {
        // action.setShell(fWizardShell);
        //
        // ActionContributionItem item = new ActionContributionItem(action);
        // item.fill(fMenu, -1);
        //
        // if (separator == null) {
        // separator = new Separator();
        // separator.fill(fMenu, -1);
        // }
        // }

        // only do the first project action (not the 5 separate ones)

        for (NewWizardAction action : actions) {
            action.setShell(fWizardShell);
            ActionContributionItem projectItem = new ActionContributionItem(action);
            projectItem.fill(fMenu, -1);
        }

        NewWizardAction importAction = new ImportLiferayProjectsWizardAction();
        importAction.setShell(fWizardShell);
        ActionContributionItem item = new ActionContributionItem(importAction);
        item.fill(fMenu, -1);

        NewWizardAction[] projectExtraActions = getExtraProjectActions();

        for (NewWizardAction extraAction : projectExtraActions) {
            extraAction.setShell(fWizardShell);

            ActionContributionItem extraItem = new ActionContributionItem(extraAction);
            extraItem.fill(fMenu, -1);
        }

        new Separator().fill(fMenu, -1);

        // add non project items
        NewWizardAction[] nonProjectActions = getActionFromDescriptors(getNonProjectTypeAttribute());

        for (NewWizardAction action : nonProjectActions) {
            action.setShell(fWizardShell);

            ActionContributionItem noProjectitem = new ActionContributionItem(action);
            noProjectitem.fill(fMenu, -1);
        }

        new Separator().fill(fMenu, -1);

        NewWizardAction[] noProjectExtraActions = getActionFromDescriptors(getNonProjectExtraTypeAttribute());

        for (NewWizardAction action : noProjectExtraActions) {
            action.setShell(fWizardShell);

            ActionContributionItem noProjectExtraitem = new ActionContributionItem(action);
            noProjectExtraitem.fill(fMenu, -1);
        }

        new Separator().fill(fMenu, -1);

        Action[] sdkActions = getServerActions(parent.getShell());

        for (Action action : sdkActions) {
            ActionContributionItem sdkItem = new ActionContributionItem(action);
            sdkItem.fill(fMenu, -1);
        }
    }

    return fMenu;
}

From source file:com.liferay.ide.project.ui.action.NewPortletDropDownAction.java

License:Open Source License

public Menu getMenu(Control parent) {
    if (fMenu == null) {
        fMenu = new Menu(parent);

        NewWizardAction[] actions = getActionFromDescriptors(getTypeAttribute());

        for (NewWizardAction action : actions) {
            action.setShell(fWizardShell);

            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(fMenu, -1);
        }//  w  w w. j a va  2  s.c o  m

        new Separator().fill(fMenu, -1);

        NewWizardAction[] extraActions = getActionFromDescriptors(getExtraTypeAttribute());

        for (NewWizardAction action : extraActions) {
            action.setShell(fWizardShell);

            ActionContributionItem item = new ActionContributionItem(action);
            item.fill(fMenu, -1);
        }
    }

    return fMenu;
}