Search in sources :

Example 1 with EditorSelectionDialog

use of org.eclipse.ui.dialogs.EditorSelectionDialog in project yamcs-studio by yamcs.

the class OpenWithMenu method createOtherMenuItem.

/**
 * Creates the Other... menu item
 *
 * @param menu
 *            the menu to add the item to
 */
private void createOtherMenuItem(final Menu menu) {
    IFile fileResource = getFileResource();
    if (fileResource == null) {
        return;
    }
    new MenuItem(menu, SWT.SEPARATOR);
    MenuItem menuItem = new MenuItem(menu, SWT.PUSH);
    menuItem.setText("Other...");
    menuItem.addListener(SWT.Selection, evt -> {
        EditorSelectionDialog dialog = new EditorSelectionDialog(menu.getShell());
        dialog.setMessage("Choose the editor for opening " + fileResource.getName());
        if (dialog.open() == Window.OK) {
            IEditorDescriptor editor = dialog.getSelectedEditor();
            if (editor != null) {
                openEditor(editor, editor.isOpenExternal());
            }
        }
    });
}
Also used : IFile(org.eclipse.core.resources.IFile) EditorSelectionDialog(org.eclipse.ui.dialogs.EditorSelectionDialog) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) MenuItem(org.eclipse.swt.widgets.MenuItem)

Aggregations

IFile (org.eclipse.core.resources.IFile)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)1 EditorSelectionDialog (org.eclipse.ui.dialogs.EditorSelectionDialog)1