質問

Commons Navigatorフレームワークからほぼすべてのポップアップメニューを削除することに部分的に成功しました。 plugin.xml ファイル。
行くことを拒否する2つのメニューがあります。

  • group.edit
  • group.reorganize.

じぶんの plugin.xml 構成は次のようになります:

<extension
          point="org.eclipse.ui.navigator.viewer">
       <viewer
             viewerId="org.eclipse.ui.example.navigator.view">
             <popupMenu allowsPlatformContributions="false">
                <insertionPoint
                    name="group.edit" />

                <insertionPoint
                    name="group.reorganize" />
             </popupMenu>
       </viewer>
       <viewerContentBinding
             viewerId="org.eclipse.ui.thermo.navigator.view">
          <includes>
             <contentExtension
                   pattern="org.eclipse.ui.navigator.resourceContent"/>
          </includes>
       </viewerContentBinding> 
</extension>

設定 allowsPlatformContribution falseに、コンテキストメニューに追加の寄付を停止します を除外する 為に group.editgroup.reorganize...これは私にとってバグのように見え始めています。

明らかな解決策は、私の挿入点を削除することです <popUpMenu> しかし、それらがなければ、アプリケーションは例外をスローします:

Throwable: java.lang.IllegalArgumentException: Group not found: group.edit

java.lang.IllegalArgumentException: Group not found: group.edit
at org.eclipse.jface.action.ContributionManager.addToGroup(ContributionManager.java:131)
at org.eclipse.jface.action.ContributionManager.appendToGroup(ContributionManager.java:138)
at org.eclipse.ui.internal.navigator.resources.actions.EditActionGroup.fillContextMenu(EditActionGroup.java:74)
at org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider.fillContextMenu(EditActionProvider.java:50)
at org.eclipse.ui.navigator.NavigatorActionService.addCommonActionProviderMenu(NavigatorActionService.java:205)
at org.eclipse.ui.navigator.NavigatorActionService.fillContextMenu(NavigatorActionService.java:172)
at org.eclipse.ui.internal.navigator.CommonNavigatorManager.fillContextMenu(CommonNavigatorManager.java:258)
at org.eclipse.ui.internal.navigator.CommonNavigatorManager$4.menuAboutToShow(CommonNavigatorManager.java:273)
at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:335)
at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:463)
at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:459)
at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:485)

再編成グループに同じ例外がスローされます。

役に立ちましたか?

解決

「group.edit」アクション(コピー/ペースト)を削除することに成功しましたが、一般的なナビゲーター拡張ポイントを使用して、そのようにしました。

   <extension
         point="org.eclipse.ui.navigator.viewer">
      <viewerActionBinding
            viewerId="org.eclipse.ui.navigator.ProjectExplorer">
         <includes>
            <actionExtension
                  pattern="my.app.client.actions.MyAppEditActionExtension">
            </actionExtension>
         </includes>
      </viewerActionBinding>    
   </extension>
   <extension
         point="org.eclipse.ui.navigator.navigatorContent">
      <actionProvider
            class="my.app.client.workshop.MyPasteActionProvider"
            id="my.app.client.actions.MyAppEditActionExtension"
            overrides="org.eclipse.ui.navigator.resources.actions.EditActions"
            priority="highest">
         <enablement>
         <!-- A hack to allways be enabled -->
         <not>
            <systemTest
                  property="MyApp"
                  value="WONT-EVER-BE-SET">
            </systemTest>
         </not>
         </enablement>
     </actionProvider>
   </extension>

また、プラグインの依存関係に「org.eclipse.ui.navigator.resources」を追加することで、次のように「mypasteactionprovider」を実装しました。

import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.ui.internal.navigator.resources.actions.EditActionProvider;

/**
 * Create the Edit actions (Cut/Copy/Paste) 
 * and register then globally in the workbench using EditActionProvider.
 * <p/>
 * Then, removes the Copy/Paste contributions in the pop-up menu.
 */
public class MyPasteActionProvider extends EditActionProvider {
   public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu);
   // remove Copy/Paste contributions
   IContributionItem copyItemRemoved = menu.remove("org.eclipse.ui.CopyAction");
   IContributionItem pasteItemRemoved = menu.remove("org.eclipse.ui.PasteAction");
   }
}

まあ、それは「落胆したアクセス」ですが、私は自分自身を落胆させていました;-) JM.D

他のヒント

通常、あなたはを使用する必要があります コマンドフレームワーク Eclipse(3.3以上)の最近のバージョンでは、共通のナビゲーターにポップアップメニューを提供するメカニズムに取って代わります。

これ スレッドが提案します メニュー項目を最初に表示する原因となっているものを削除するには:

彼らはおそらくアクションセットになっているので、攻撃的な貢献を引き起こしているアクションセットを特定できる場合、あなたはあなたの中でこのようなことをすることができます WorkbenchAdvisor:

    ActionSetRegistry reg = WorkbenchPlugin.getDefault()
            .getActionSetRegistry();


    IActionSetDescriptor[] actionSets = reg.getActionSets();
    String[] removeActionSets = new String[] {
        "org.eclipse.ui.cheatsheets.actionSet",
        "org.eclipse.ui.edit.text.actionSet.annotationNavigation",
       "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo",
          "org.eclipse.ui.WorkingSetActionSet",
        "org.eclipse.update.ui.softwareUpdates", };


    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;
        }


        if (!found)
            continue;
        IExtension ext = actionSets[i].getConfigurationElement()
                .getDeclaringExtension();
        reg.removeExtension(ext, new Object[] { actionSets[i] });
    }

私が見つけた最も近いバグはです 145233:入力を指定するためのより明確な方法を作成します(RCPアプリ用), 、 とともに 同様のハック.
バグ 143430(commonnavigatorでは、初期inputが適応可能である必要があります) より一般的なものであり、その後、CNFがEclipse3.5(Galileo)で改善されたことを示します。
3.5とカスタムCNFクラスのこの問題もありますか?


記事で述べたように」Eclipse CNF:ナビゲーターコンテンツ拡張機能「、CNFはEclipse3.5で進化しました。この記事には、真のカスタムコンテキストメニューエントリがあるツリーがあるようです。

alt text

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top