Search in sources :

Example 11 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project dbeaver by serge-rider.

the class ActionUtils method makeCommandContribution.

public static CommandContributionItem makeCommandContribution(@NotNull IServiceLocator serviceLocator, @NotNull String commandId, int style, @Nullable DBPImage icon) {
    CommandContributionItemParameter parameters = new CommandContributionItemParameter(serviceLocator, null, commandId, style);
    parameters.icon = DBeaverIcons.getImageDescriptor(icon);
    return new CommandContributionItem(parameters);
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 12 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project translationstudio8 by heartsome.

the class BodyMenuConfiguration method createMenu.

/**
	 * 编辑界面右键菜单
	 * @param menu
	 *            ;
	 */
private void createMenu() {
    MenuManager menuMgr = new MenuManager();
    bodyMenu = menuMgr.createContextMenu(table.getShell());
    if (!CommonFunction.checkEdition("L")) {
        menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.database.ui.tm.command.ConcordanceSearch", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.TU_STATE_SEARCHTM), null, null, Messages.getString("menu.BodyMenuConfiguration.searchTM"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
        menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.database.ui.tb.command.TermBaseSearch", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.TU_STATE_SEARCHTB), null, null, Messages.getString("menu.BodyMenuConfiguration.searchTermItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
        menuMgr.add(new Separator());
    }
    // add by yule -webSearch
    menuMgr.add(new Separator());
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.websearch.search", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.WEB_SEARCH), null, null, Messages.getString("menu.BodyMenuConfiguration.webSearch"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new Separator());
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, ActionFactory.CUT.getCommandId(), Collections.EMPTY_MAP, null, null, null, Messages.getString("menu.BodyMenuConfiguration.cut"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, ActionFactory.COPY.getCommandId(), Collections.EMPTY_MAP, null, null, null, Messages.getString("menu.BodyMenuConfiguration.copy"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, ActionFactory.PASTE.getCommandId(), Collections.EMPTY_MAP, null, null, null, Messages.getString("menu.BodyMenuConfiguration.paste"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new Separator());
    // 此处显示出来不做任何事情,是因为用户可以通过右键看到当前状态列中显示的图标是什么含义
    // 在状态列中,是无法知道某一图标的具体含义的
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.untranslated", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/not-translated.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.emptyTranslationItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.draft", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/draft.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.draftItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    Map<String, String> mapParameter = new HashMap<String, String>();
    mapParameter.put("addSegmentToTM", "addToTM");
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.menu.translation.command.completeTranslation", mapParameter, Activator.getImageDescriptor("images/state/translated.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.translatedItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    mapParameter = new HashMap<String, String>();
    mapParameter.put("approveSegment", "approveSelectSegment");
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.ApproveSelectSegment", mapParameter, Activator.getImageDescriptor("images/state/approved.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.approveItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.signedOff", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/sign-off.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.signItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new Separator());
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.menu.translation.lockSegment.command.lockSegment", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/locked.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.isLockItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.needReview", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/questioning.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.problemItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.notSendToTM", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/not-sent-db.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.disAddToTMItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new Separator());
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.AddNote", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.TU_STATE_ADDNOTE), null, null, Messages.getString("menu.BodyMenuConfiguration.addNoteItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.EditNote", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.TU_STATE_EDITNOTE), null, null, Messages.getString("menu.BodyMenuConfiguration.editNoteItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.menu.translateContent.command.deleteCurrentSegmentNotes", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.TU_STATE_DELETENOTE), null, null, Messages.getString("menu.BodyMenuConfiguration.deleteNoteItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    menuMgr.add(new Separator());
    menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.menu.translateContent.command.deleteCurrentSegmentTranslations", Collections.EMPTY_MAP, Activator.getImageDescriptor(ImageConstant.TU_STATE_DELETETRANS), null, null, Messages.getString("menu.BodyMenuConfiguration.deleteTransItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    if (CommonFunction.checkEdition("F") || CommonFunction.checkEdition("U")) {
        menuMgr.add(new Separator());
        menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.handlexlf.commands.setSplitPointByWordNumCommand", Collections.EMPTY_MAP, null, null, null, Messages.getString("menu.BodyMenuConfiguration.setSplitPointByWordNum"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
        menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.handlexlf.commands.nextSplitPointCommand", Collections.EMPTY_MAP, null, null, null, Messages.getString("menu.BodyMenuConfiguration.nextSplitPoint"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
        menuMgr.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "net.heartsome.cat.ts.ui.xliffeditor.nattable.command.splitXLIFFPoint", Collections.EMPTY_MAP, Activator.getImageDescriptor("images/state/cut-point.png"), null, null, Messages.getString("menu.BodyMenuConfiguration.splitPointItem"), null, null, CommandContributionItem.STYLE_PUSH, null, false)));
    }
}
Also used : HashMap(java.util.HashMap) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) MenuManager(org.eclipse.jface.action.MenuManager) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) Separator(org.eclipse.jface.action.Separator)

Example 13 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project dbeaver by dbeaver.

the class ActionUtils method makeCommandContribution.

public static CommandContributionItem makeCommandContribution(IServiceLocator serviceLocator, String commandId, int style, DBPImage icon) {
    CommandContributionItemParameter parameters = new CommandContributionItemParameter(serviceLocator, null, commandId, style);
    parameters.icon = DBeaverIcons.getImageDescriptor(icon);
    return new CommandContributionItem(parameters);
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 14 with CommandContributionItem

use of org.eclipse.ui.menus.CommandContributionItem in project yamcs-studio by yamcs.

the class SwitchProcessorCompoundContributionItem method getContributionItems.

@Override
public IContributionItem[] getContributionItems() {
    List<IContributionItem> items = new ArrayList<>();
    ProcessorInfo currentProcessor = ManagementCatalogue.getInstance().getCurrentProcessorInfo();
    items.add(createProcessorItem(currentProcessor));
    items.add(new Separator());
    String instance = ManagementCatalogue.getCurrentYamcsInstance();
    List<ProcessorInfo> processors = ManagementCatalogue.getInstance().getProcessors(instance);
    Collections.sort(processors, (p1, p2) -> p1.getName().compareTo(p2.getName()));
    processors.forEach(processor -> {
        if (!processor.getName().equals(currentProcessor.getName())) {
            CommandContributionItem item = createProcessorItem(processor);
            items.add(item);
        }
    });
    updateSelection();
    return items.toArray(new IContributionItem[0]);
}
Also used : ProcessorInfo(org.yamcs.protobuf.YamcsManagement.ProcessorInfo) IContributionItem(org.eclipse.jface.action.IContributionItem) ArrayList(java.util.ArrayList) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem) Separator(org.eclipse.jface.action.Separator)

Example 15 with CommandContributionItem

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

the class UserMyRefacContribution method getContributionItems.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected IContributionItem[] getContributionItems() {
    final List<UserRefactoringInfo> refacs = UserRefactoringsManager.getInstance().getMyElementary();
    if (refacs.isEmpty()) {
        final CommandContributionItemParameter param = new CommandContributionItemParameter(PlatformUI.getWorkbench(), null, "org.erlide.wrangler.refactoring.empty", CommandContributionItem.STYLE_PUSH);
        param.label = "<Empty>";
        final CommandContributionItem item = new CommandContributionItem(param);
        return new IContributionItem[] { item };
    }
    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

CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)31 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)25 IContributionItem (org.eclipse.jface.action.IContributionItem)10 HashMap (java.util.HashMap)7 ArrayList (java.util.ArrayList)4 Separator (org.eclipse.jface.action.Separator)3 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)2 MenuManager (org.eclipse.jface.action.MenuManager)2 IMenuService (org.eclipse.ui.menus.IMenuService)2 UserRefactoringInfo (org.erlide.wrangler.refactoring.backend.UserRefactoringInfo)2 DBException (org.jkiss.dbeaver.DBException)2 DatabaseLoadService (org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService)2 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)2 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DecimalFormat (java.text.DecimalFormat)1 java.util (java.util)1 List (java.util.List)1