Search in sources :

Example 71 with IWorkbenchPartSite

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

the class EditorCompoundContributionItem method getSelection.

protected ITextSelection getSelection() {
    final IEditorPart ep = getEditorPart();
    if (ep == null)
        return null;
    final IWorkbenchPartSite ws = ep.getEditorSite();
    if (ws == null)
        return null;
    final ISelectionProvider sp = ws.getSelectionProvider();
    if (sp == null)
        return null;
    final ISelection sel = sp.getSelection();
    if (sel == null || !(sel instanceof ITextSelection))
        return null;
    return (ITextSelection) sel;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelection(org.eclipse.jface.viewers.ISelection) IEditorPart(org.eclipse.ui.IEditorPart) ITextSelection(org.eclipse.jface.text.ITextSelection)

Example 72 with IWorkbenchPartSite

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

the class XtextStyledTextCellEditor method initContextMenu.

protected void initContextMenu(Control control) {
    MenuManager menuManager = createMenuManager();
    Menu contextMenu = menuManager.createContextMenu(control);
    control.setMenu(contextMenu);
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite();
    site.registerContextMenu(CONTEXTMENUID, menuManager, site.getSelectionProvider());
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) MenuManager(org.eclipse.jface.action.MenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 73 with IWorkbenchPartSite

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

the class AbstractEditorPropertySection method initContextMenu.

protected void initContextMenu(Control control) {
    MenuManager menuManager = new FilteringMenuManager();
    Menu contextMenu = menuManager.createContextMenu(control);
    control.setMenu(contextMenu);
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPartSite site = window.getActivePage().getActiveEditor().getSite();
    site.registerContextMenu(CONTEXTMENUID, menuManager, site.getSelectionProvider());
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) 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