从RCP应用程序中删除酷吧图标

时间:2014-02-26 08:09:06

标签: eclipse-rcp rcp

使用Eclipse Helios

enter image description here

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

@SuppressWarnings( “限制”) protected void fillMenuBar(IMenuManager menuBar){     @SuppressWarnings( “限制”)     final ActionSetRegistry reg = WorkbenchPlugin.getDefault()             .getActionSetRegistry();     @SuppressWarnings( “限制”)          final IActionSetDescriptor [] actionSets = reg.getActionSets();           final 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;
    }

}

}

1 个答案:

答案 0 :(得分:0)

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

我在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。上面的代码删除了以下操作:

enter image description here

您应该通过上面的代码删除。

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

安迪

相关问题