use of org.eclipse.ui.actions.OpenWithMenu in project eclipse.platform.text by eclipse.
the class NewTextSearchActionGroup method addOpenWithMenu.
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) {
if (selection == null)
return;
fOpenAction.selectionChanged(selection);
if (fOpenAction.isEnabled()) {
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenAction);
}
if (selection.size() != 1) {
return;
}
Object o = selection.getFirstElement();
if (!(o instanceof IAdaptable))
return;
// Create menu
IMenuManager submenu = new MenuManager(SearchMessages.OpenWithMenu_label);
submenu.add(new OpenWithMenu(fPage, (IAdaptable) o));
// Add the submenu.
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
use of org.eclipse.ui.actions.OpenWithMenu in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method editorContextMenuAboutToShow.
@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();
// XXX: Internal reference will get fixed during 3.7, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=307026
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);
}
use of org.eclipse.ui.actions.OpenWithMenu in project titan.EclipsePlug-ins by eclipse.
the class LogFileActionProvider method addOpenWithMenu.
private void addOpenWithMenu(final IMenuManager aMenu) {
final IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
if (selection == null || selection.size() != 1 || !(selection.getFirstElement() instanceof IFile)) {
return;
}
final IFile file = (IFile) selection.getFirstElement();
IMenuManager submenu = new MenuManager("Open with", ICommonMenuConstants.GROUP_OPEN_WITH);
submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP));
submenu.add(new OpenWithMenu(viewSite.getPage(), file));
submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_ADDITIONS));
if (submenu.getItems().length > 2 && submenu.isEnabled()) {
aMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN_WITH, submenu);
}
}
use of org.eclipse.ui.actions.OpenWithMenu in project webtools.sourceediting by eclipse.
the class ExtendedStorageEditorInputView method createPartControl.
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
public void createPartControl(Composite parent) {
fInputList = new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
fInputList.setContentProvider(new ArrayContentProvider());
fInputList.setLabelProvider(new EditorInputLabelProvider());
fInputList.addDoubleClickListener(new DoubleClickListener());
fInputList.getTable().setHeaderVisible(true);
fInputList.getTable().setLinesVisible(true);
String[] columns = new String[] { "Path", "Type" };
fInputList.setLabelProvider(new EditorInputLabelProvider());
TableLayout tlayout = new TableLayout();
CellEditor[] cellEditors = new CellEditor[5];
for (int i = 0; i < columns.length; i++) {
tlayout.addColumnData(new ColumnWeightData(1));
TableColumn tc = new TableColumn(fInputList.getTable(), SWT.NONE);
tc.setText(columns[i]);
tc.setResizable(true);
tc.setWidth(Display.getCurrent().getBounds().width / 14);
}
fInputList.setCellEditors(cellEditors);
fInputList.setColumnProperties(columns);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
fInputList.getTable().setLayoutData(gd);
// $NON-NLS-1$
MenuManager menuManager = new MenuManager("#popup");
menuManager.setRemoveAllWhenShown(false);
menuManager.add(new InputOpenAction());
menuManager.add(new Separator());
menuManager.add(new InputMoveAction());
menuManager.add(new InputChangeDirtyStateAction());
menuManager.add(new InputDeleteAction());
menuManager.add(new InputReplaceContentsAction());
menuManager.add(new Separator());
menuManager.add(new RemoveInputAction());
Menu menu = menuManager.createContextMenu(fInputList.getControl());
fInputList.getControl().setMenu(menu);
SSETestsPlugin.getDefault().getPluginPreferences().setDefault(getInputsPreferenceName(), "");
String[] paths = StringUtils.unpack(SSETestsPlugin.getDefault().getPluginPreferences().getString(getInputsPreferenceName()));
for (int i = 0; i < paths.length; i++) {
if (paths[i].startsWith("S!")) {
fInputs.add(new FileBasedStorageEditorInput(new File(paths[i].substring(2))));
menuManager.add(new OpenWithMenu(getSite().getPage(), null));
} else if (paths[i].startsWith("F!")) {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(paths[i].substring(2)));
fInputs.add(new FileEditorInput(file));
menuManager.add(new OpenWithMenu(getSite().getPage(), file));
}
}
fInputList.setInput(fInputs);
fInputList.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = ((IStructuredSelection) event.getSelection());
fSelectedElement = sel.getFirstElement();
}
});
}
use of org.eclipse.ui.actions.OpenWithMenu in project erlide_eclipse by erlang.
the class OpenEditorActionGroup method addOpenWithMenu.
private void addOpenWithMenu(final IMenuManager menu) {
final ISelection selection = getContext().getSelection();
if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
return;
}
final IStructuredSelection ss = (IStructuredSelection) selection;
if (ss.size() != 1) {
return;
}
final Object o = ss.getFirstElement();
if (!(o instanceof IAdaptable)) {
return;
}
final IAdaptable element = (IAdaptable) o;
final Object resource = element.getAdapter(IResource.class);
if (!(resource instanceof IFile)) {
return;
}
// Create a menu.
final IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label);
submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource));
// Add the submenu.
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu);
}
Aggregations