【问题标题】:Remove coolbar icon from RCP application从 RCP 应用程序中删除酷栏图标
【发布时间】:2014-02-28 12:37:46
【问题描述】:

使用Eclipse Helios

如何从rcp 应用程序中删除图标。代码在这里...

@SuppressWarnings("限制") 受保护的无效填充菜单栏(IMenuManager menuBar){ @SuppressWarnings("限制") 最终 ActionSetRegistry reg = WorkbenchPlugin.getDefault() .getActionSetRegistry(); @SuppressWarnings("限制") 最终 IActionSetDescriptor[] actionSets = reg.getActionSets(); 最终 String[] removeActionSets = new String[] { "org.eclipse.search.searchActionSet", "org.eclipse.ui.cheatsheets.actionSet", "org.eclipse.ui.actionSet.keyBindings", "org.eclipse.ui.edit.text.actionSet.navigation", "org.eclipse.ui.edit.text.actionSet.annotationNavigation", "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo", "org.eclipse.ui.edit.text.actionSet.openExternalFile", "org.eclipse.ui.externaltools.ExternalToolsSet", "org.eclipse.ui.WorkingSetActionSet", "org.eclipse.update.ui.softwareUpdates", "org.eclipse.ui.actionSet.openFiles", “org.eclipse.mylyn.tasks.ui.navigation”};

for (int i = 0; i < actionSets.length; i++) {
    boolean found = false;
    for (int j = 0; j < removeActionSets.length; j++) {
        if (removeActionSets[j].equals(actionSets[i].getId())) {
            found = true;
            final IExtension ext = actionSets[i]
                    .getConfigurationElement().getDeclaringExtension();
            reg.removeExtension(ext, new Object[] { actionSets[i] });
        }
    }
    if (!found) {
        continue;
    }

}

}

【问题讨论】:

  • 这是一个带有您自己的 ActionBarAdvisor 的 RCP,还是使用 Eclipse IDE 操作栏顾问?
  • 它是 Eclipse IDE 操作栏顾问。默认情况下,它在我的应用程序中。

标签: eclipse-rcp rcp


【解决方案1】:

有时你会得到一些插件贡献的那些动作。

我在 ApplicationActionBarAdvisor 类中使用以下代码删除了那些不需要的操作:

private static final String[] actionSetId = new String[] { "org.eclipse.ui.WorkingSetActionSet", //$NON-NLS-1$
    "org.eclipse.ui.edit.text.actionSet.navigation", //$NON-NLS-1$
    "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo", //$NON-NLS-1$
    "org.eclipse.ui.actionSet.openFiles", //$NON-NLS-1$
    "org.eclipse.ui.edit.text.actionSet.annotationNavigation", //$NON-NLS-1$
    "org.eclipse.ui.NavigateActionSet", //$NON-NLS-1$
    "org.eclipse.search.searchActionSet"}; //$NON-NLS-1$




    private void removeUnWantedActions() {
       ActionSetRegistry asr = WorkbenchPlugin.getDefault().getActionSetRegistry();
       IActionSetDescriptor[] actionSets = asr.getActionSets();

       IExtension ext = null;
       for (IActionSetDescriptor actionSet : actionSets) {
          for (String element : actionSetId) {
              System.out.println(element);

             if (element.equals(actionSet.getId())) {
                ext = actionSet.getConfigurationElement().getDeclaringExtension();
                asr.removeExtension(ext, new Object[] { actionSet });
             }
          }
       }
    }

从 ApplicationActionBarAdvisor 类的构造函数中调用“removeUnWantedActions”。

基本上,您需要找出要删除的操作的 ID。上面的代码删除了以下操作:

你的应该被上面的代码删除。

更多详情见我的博文:http://andydunkel.net/eclipse/java/2011/05/16/remove-unwanted-actions-in-rcp-application.html

安迪

【讨论】:

  • 没试过,但是“new”下拉动作的id是“newWizardDropDown”。尝试将其添加到不需要的操作列表中。
  • 我找到了这个但找不到解决方案help.eclipse.org/indigo/…
  • 这对你帮助不大,这只是如何创建工具栏的手册。问题是,Eclipse 插件可以为工具栏做出贡献。在您的情况下,某些插件有助于工具栏,您必须使用上述方法识别和删除,或隐藏操作。但是你需要正确的 id,你可以使用插件 spy 来做到这一点 (vogella.com/tutorials/EclipseCodeAccess/article.html#pluginspy)。祝你好运!
猜你喜欢
  • 1970-01-01
  • 2016-12-26
  • 2016-08-20
  • 1970-01-01
  • 2011-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多