use of org.eclipse.ui.menus.CommandContributionItem in project core by jcryptool.
the class KeystoreView method addContributionItem.
private void addContributionItem(IContributionManager manager, final String commandId, final ImageDescriptor icon, final String tooltip) {
CommandContributionItemParameter param = new CommandContributionItemParameter(serviceLocator, null, commandId, SWT.PUSH);
if (icon != null)
param.icon = icon;
if (tooltip != null && !tooltip.equals(""))
param.tooltip = tooltip;
CommandContributionItem item = new CommandContributionItem(param);
manager.add(item);
}
use of org.eclipse.ui.menus.CommandContributionItem 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.CommandContributionItem 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.CommandContributionItem 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.CommandContributionItem 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);
}
Aggregations