Search in sources :

Example 26 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project egit by eclipse.

the class GitActionContributor method createItem.

private CommandContributionItem createItem(String itemAction) {
    IWorkbench workbench = PlatformUI.getWorkbench();
    CommandContributionItemParameter itemParam = new CommandContributionItemParameter(workbench, null, itemAction, STYLE_PUSH);
    IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
    IHandlerService hsr = CommonUtils.getService(activeWorkbenchWindow, IHandlerService.class);
    IEvaluationContext ctx = hsr.getCurrentState();
    ctx.addVariable(ACTIVE_MENU_SELECTION_NAME, getContext().getSelection());
    return new CommandContributionItem(itemParam);
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IHandlerService(org.eclipse.ui.handlers.IHandlerService) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) IEvaluationContext(org.eclipse.core.expressions.IEvaluationContext) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 27 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project egit by eclipse.

the class PushMenu method getContributionItems.

@Override
protected IContributionItem[] getContributionItems() {
    List<IContributionItem> res = new ArrayList<>();
    if (this.handlerService != null) {
        Repository repository = SelectionUtils.getRepository(handlerService.getCurrentState());
        if (repository != null) {
            try {
                String ref = repository.getFullBranch();
                String menuLabel = UIText.PushMenu_PushHEAD;
                if (ref != null && ref.startsWith(Constants.R_HEADS)) {
                    menuLabel = NLS.bind(UIText.PushMenu_PushBranch, Repository.shortenRefName(ref));
                }
                CommandContributionItemParameter params = new CommandContributionItemParameter(this.serviceLocator, getClass().getName(), ActionCommands.PUSH_BRANCH_ACTION, CommandContributionItem.STYLE_PUSH);
                params.label = menuLabel;
                CommandContributionItem item = new CommandContributionItem(params);
                res.add(item);
            } catch (IOException ex) {
                Activator.handleError(ex.getLocalizedMessage(), ex, false);
            }
        }
    }
    return res.toArray(new IContributionItem[res.size()]);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) IContributionItem(org.eclipse.jface.action.IContributionItem) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 28 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project mylyn.docs by eclipse.

the class WikiMarkupGenerationContribution method getContributionItems.

@Override
protected IContributionItem[] getContributionItems() {
    Map<String, IContributionItem> items = new TreeMap<>();
    for (MarkupLanguage markupLanguage : ServiceLocator.getInstance().getAllMarkupLanguages()) {
        try {
            // test to see if markup generation is supported
            markupLanguage.createDocumentBuilder(new StringWriter());
        } catch (UnsupportedOperationException e) {
            // markup langage doesn't provide document builder
            continue;
        }
        String commandId = ConvertMarkupToMarkup.COMMAND_ID;
        // $NON-NLS-1$ //$NON-NLS-2$
        String id = commandId + '.' + markupLanguage.getName().replaceAll("\\W", "_");
        HashMap<String, String> args = new HashMap<>();
        args.put(ConvertMarkupToMarkup.PARAM_MARKUP_LANGUAGE, markupLanguage.getName());
        CommandContributionItemParameter parameters = new CommandContributionItemParameter(serviceLocator, id, commandId, CommandContributionItem.STYLE_PUSH);
        parameters.label = NLS.bind(Messages.WikiMarkupGenerationContribution_generate_markup, markupLanguage.getName());
        parameters.parameters = args;
        items.put(markupLanguage.getName(), new CommandContributionItem(parameters));
    }
    return items.values().toArray(new IContributionItem[items.size()]);
}
Also used : StringWriter(java.io.StringWriter) HashMap(java.util.HashMap) IContributionItem(org.eclipse.jface.action.IContributionItem) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) MarkupLanguage(org.eclipse.mylyn.wikitext.parser.markup.MarkupLanguage) TreeMap(java.util.TreeMap) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 29 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project ecf by eclipse.

the class AbstractRosterMenuContributionItem method createCommandContributionItemForEntry.

/**
 * Create a command contribution item for the given entry with the given commandId.
 *
 * @param commandId the commandId for the new CommandContributionItem.  Must not be <code>null</code>.
 * @param rosterEntry the IRosterEntry for the new CommandContributionItem.  Must not be <code>null</code>.
 * @return CommandContributionItem created.  Must not return <code>null</code>.
 */
protected CommandContributionItem createCommandContributionItemForEntry(String commandId, IRosterEntry rosterEntry) {
    CommandContributionItemParameter p = new CommandContributionItemParameter(serviceLocator, null, commandId, CommandContributionItem.STYLE_PUSH);
    p.icon = getRosterEntryImageDescriptor(rosterEntry);
    p.label = rosterEntry.getName();
    // 3.4 return new CommandContributionItem(serviceLocator, null, commandId, new HashMap(), getRosterEntryImageDescriptor(rosterEntry), null, null, rosterEntry.getName(), null, null, CommandContributionItem.STYLE_PUSH);
    return new CommandContributionItem(p);
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 30 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project erlide_eclipse by erlang.

the class UserRefacContribution method getContributionItems.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected IContributionItem[] getContributionItems() {
    final List<UserRefactoringInfo> refacs = UserRefactoringsManager.getInstance().getElementary();
    final IContributionItem[] items = new IContributionItem[refacs.size()];
    int i = 0;
    for (final UserRefactoringInfo info : refacs) {
        final CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench(), info.getCallback(), "org.erlide.wrangler.refactoring.gen_refac", CommandContributionItem.STYLE_PUSH);
        param.label = info.getLabel();
        param.parameters = new HashMap();
        param.parameters.put("org.erlide.wrangler.refactoring.gen_refac.callback", info.getCallback());
        param.parameters.put("org.erlide.wrangler.refactoring.gen_refac.name", info.getLabel());
        items[i] = new CommandContributionItem(param);
        i++;
    }
    return items;
}
Also used : HashMap(java.util.HashMap) IContributionItem(org.eclipse.jface.action.IContributionItem) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) UserRefactoringInfo(org.erlide.wrangler.refactoring.backend.UserRefactoringInfo)

Aggregations

CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)31 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)30 HashMap (java.util.HashMap)9 IContributionItem (org.eclipse.jface.action.IContributionItem)4 ResultSetPanelDescriptor (org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)4 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)3 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DecimalFormat (java.text.DecimalFormat)2 java.util (java.util)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 org.eclipse.jface.action (org.eclipse.jface.action)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)2