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);
}
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()]);
}
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()]);
}
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);
}
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;
}
Aggregations