Search in sources :

Example 26 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project jbosstools-openshift by jbosstools.

the class UIUtils method getCurrentSelection.

/**
 * Use this method instead of HandlerUtil.getCurrentSelection(event)
 * when action is called on Properties View.
 *
 * @param event
 * @return
 */
public static ISelection getCurrentSelection(ExecutionEvent event) {
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    IWorkbenchPartSite site = (part != null) ? part.getSite() : null;
    IWorkbenchWindow window = (site != null) ? site.getWorkbenchWindow() : null;
    ISelectionService service = (window != null) ? window.getSelectionService() : null;
    return service != null ? service.getSelection() : null;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelectionService(org.eclipse.ui.ISelectionService)

Example 27 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project xtext-eclipse by eclipse.

the class HighlightingReconciler method getDisplay.

private Display getDisplay() {
    XtextEditor editor = this.editor;
    if (editor == null) {
        if (sourceViewer != null)
            return sourceViewer.getControl().getDisplay();
        return null;
    }
    IWorkbenchPartSite site = editor.getSite();
    if (site == null)
        return null;
    Shell shell = site.getShell();
    if (shell == null || shell.isDisposed())
        return null;
    Display display = shell.getDisplay();
    if (display == null || display.isDisposed())
        return null;
    return display;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Shell(org.eclipse.swt.widgets.Shell) XtextEditor(org.eclipse.xtext.ui.editor.XtextEditor) Display(org.eclipse.swt.widgets.Display)

Example 28 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project xtext-eclipse by eclipse.

the class ImportsAwareClipboardAction method getShell.

private Shell getShell() {
    ITextEditor editor = getTextEditor();
    if (editor != null) {
        IWorkbenchPartSite site = editor.getSite();
        Shell shell = site.getShell();
        if (shell != null && !shell.isDisposed()) {
            return shell;
        }
    }
    return null;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Shell(org.eclipse.swt.widgets.Shell) ITextEditor(org.eclipse.ui.texteditor.ITextEditor)

Example 29 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project egit by eclipse.

the class GitHistoryPage method getPartSite.

private IWorkbenchPartSite getPartSite() {
    final IWorkbenchPart part = getHistoryPageSite().getPart();
    IWorkbenchPartSite site = null;
    if (part != null)
        site = part.getSite();
    return site;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart)

Example 30 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project statecharts by Yakindu.

the class StatechartDefinitionSection method initContextMenu.

protected void initContextMenu(Control control) {
    MenuManager menuManager = new FilteringMenuManager();
    Menu contextMenu = menuManager.createContextMenu(control);
    control.setMenu(contextMenu);
    IWorkbenchPartSite site = editorPart.getSite();
    if (site != null)
        site.registerContextMenu("org.yakindu.base.xtext.utils.jface.viewers.StyledTextXtextAdapterContextMenu", menuManager, site.getSelectionProvider());
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) FilteringMenuManager(org.yakindu.base.xtext.utils.jface.viewers.FilteringMenuManager) MenuManager(org.eclipse.jface.action.MenuManager) FilteringMenuManager(org.yakindu.base.xtext.utils.jface.viewers.FilteringMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)73 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ISelection (org.eclipse.jface.viewers.ISelection)12 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)10 MenuManager (org.eclipse.jface.action.MenuManager)9 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Composite (org.eclipse.swt.widgets.Composite)9 Display (org.eclipse.swt.widgets.Display)9 Shell (org.eclipse.swt.widgets.Shell)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 Menu (org.eclipse.swt.widgets.Menu)7 IEditorSite (org.eclipse.ui.IEditorSite)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 SWT (org.eclipse.swt.SWT)6 PartInitException (org.eclipse.ui.PartInitException)6 List (java.util.List)5 IToolBarManager (org.eclipse.jface.action.IToolBarManager)4 Separator (org.eclipse.jface.action.Separator)4