Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add context menu entry to TextEditor

I want to add a custom menu item to the context menu of the default text editor in eclipse.

I can add a menu entry to all context menus with

<menuContribution locationURI="popup:org.eclipse.ui.popup.any?after=additions">
    <command commandId="HelloPlugin2.commands.sampleCommand" label="My Test" style="push" />
</menuContribution>

but I want it to be shown only in the current editors context menu, so i tried

 <menuContribution locationURI="popup:#TextEditorContext?after=additions">
    <command commandId="HelloPlugin2.commands.sampleCommand" label="My Test" style="push" />
</menuContribution>

but unfortunately the item is not visible...

Can anybode help me out? Thank you!

like image 514
Klaus Schulz Avatar asked May 07 '26 11:05

Klaus Schulz


1 Answers

The base text editor context menu id is #TextEditorContext but other editors based on the text editor normally override this using the setEditorContextMenuId method.

Looking at the setEditorContextMenuId calls the Java text editor context menu id appears to be #CompilationUnitEditorContext (and #ClassFileEditorContext if a .class file is being edited).

like image 163
greg-449 Avatar answered May 11 '26 16:05

greg-449