@Override
protected void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
IAction preferencesAction= getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES);
menu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, new Separator(ITextEditorActionConstants.GROUP_SETTINGS));
menu.appendToGroup(ITextEditorActionConstants.GROUP_SETTINGS, preferencesAction);
menu.appendToGroup(ITextEditorActionConstants.GROUP_SAVE, new Separator(ITextEditorActionConstants.GROUP_OPEN));
IEditorInput editorInput= getEditorInput();
if ((editorInput.getAdapter(IResource.class)) instanceof IFile) {
MenuManager openWithSubMenu= new MenuManager(TextEditorMessages.AbstractDecoratedTextEditor_openWith_menu);
final IWorkbenchPage page= getEditorSite().getPage();
openWithSubMenu.add(new OpenWithMenu(page, editorInput) {
@Override
protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
super.openEditor(editorDescriptor, openUsingDescriptor);
ISelection selection= getSelectionProvider().getSelection();
if (selection instanceof ITextSelection) {
revealInEditor(page.getActiveEditor(), ((ITextSelection)selection).getOffset(), ((ITextSelection)selection).getLength());
}
}
});
menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, openWithSubMenu);
}
MenuManager showInSubMenu= new MenuManager(getShowInMenuLabel());
showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(getEditorSite().getWorkbenchWindow()));
menu.appendToGroup(ITextEditorActionConstants.GROUP_OPEN, showInSubMenu);
}