1

私の現在のRCPプロジェクトでは、MultipageEditorPart. さまざまなページがあり、単純な SWT コンポジットが含まれています。コンポジットには、いくつかの Text 要素と Combo 要素が含まれています。ユーザーがエディター ページを右クリックすると、コンテキスト メニューが開きます。このメニューには、コンポジットを含む新しいエディター ページを作成するためのコマンドがあります。

コマンドは既に機能していますが、エディターのコンテキスト メニューを実装する方法についてはまったくわかりません。誰かがこれを手伝ってくれますか?

4

1 に答える 1

2

This should be based on Action contributions: see Contributing Actions to the Eclipse Workbench

As an RCP-based example, You could check out "Designing a Workflow Editor Eclipse XML", where a contextual menu is added to an EditorPart, included in a MultipageEditorPart.

protected void createContextMenuFor(StructuredViewer viewer) { 
   MenuManager contextMenu = new MenuManager("#PopUp"); 
   contextMenu.add(new Separator("additions")); 
   contextMenu.setRemoveAllWhenShown(true); 
   contextMenu.addMenuListener(this); 
   Menu menu= contextMenu.createContextMenu(viewer.getControl()); 
   viewer.getControl().setMenu(menu); 
   getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); 

   } 

alt text

See also Step 18 for extending that context menu (section "Delete - Contextual Menu, requiring using GEF).

于 2010-02-11T12:41:33.110 に答える