Search in sources :

Example 41 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project eclipse.platform.text by eclipse.

the class ContentAssistAction method run.

/**
 * Runs the content assist operation on the editor's text operation target.
 */
@Override
public void run() {
    if (fOperationTarget != null) {
        ITextEditor editor = getTextEditor();
        if (editor != null && validateEditorInputState()) {
            Display display = null;
            IWorkbenchPartSite site = editor.getSite();
            Shell shell = site.getShell();
            if (shell != null && !shell.isDisposed())
                display = shell.getDisplay();
            BusyIndicator.showWhile(display, new Runnable() {

                @Override
                public void run() {
                    fOperationTarget.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
                }
            });
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Shell(org.eclipse.swt.widgets.Shell) Display(org.eclipse.swt.widgets.Display)

Example 42 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project eclipse.platform.text by eclipse.

the class ShiftAction method run.

/**
 * The <code>TextOperationAction</code> implementation of this
 * <code>IAction</code> method runs the operation with the current
 * operation code.
 */
@Override
public void run() {
    if (fOperationCode == -1 || fOperationTarget == null)
        return;
    ITextEditor editor = getTextEditor();
    if (editor == null)
        return;
    if (!validateEditorInputState())
        return;
    Display display = null;
    IWorkbenchPartSite site = editor.getSite();
    Shell shell = site.getShell();
    if (shell != null && !shell.isDisposed())
        display = shell.getDisplay();
    BusyIndicator.showWhile(display, new Runnable() {

        @Override
        public void run() {
            fOperationTarget.doOperation(fOperationCode);
        }
    });
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Shell(org.eclipse.swt.widgets.Shell) Display(org.eclipse.swt.widgets.Display)

Example 43 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project eclipse.platform.text by eclipse.

the class TextOperationAction method run.

/**
 * The <code>TextOperationAction</code> implementation of this
 * <code>IAction</code> method runs the operation with the current
 * operation code.
 */
@Override
public void run() {
    if (fOperationCode == -1 || fOperationTarget == null)
        return;
    ITextEditor editor = getTextEditor();
    if (editor == null)
        return;
    if (!fRunsOnReadOnly && !validateEditorInputState())
        return;
    Display display = null;
    IWorkbenchPartSite site = editor.getSite();
    Shell shell = site.getShell();
    if (shell != null && !shell.isDisposed())
        display = shell.getDisplay();
    BusyIndicator.showWhile(display, new Runnable() {

        @Override
        public void run() {
            fOperationTarget.doOperation(fOperationCode);
        }
    });
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Shell(org.eclipse.swt.widgets.Shell) Display(org.eclipse.swt.widgets.Display)

Example 44 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project eclipse.platform.text by eclipse.

the class RulerColumnDescriptor method matchesEditor.

/**
 * Returns <code>true</code> if this contribution matches the passed editor, <code>false</code> if not.
 *
 * @param editor the editor to check
 * @return <code>true</code> if this contribution targets the passed editor
 */
public boolean matchesEditor(ITextEditor editor) {
    Assert.isLegal(editor != null);
    RulerColumnTarget target = getTarget();
    IWorkbenchPartSite site = editor.getSite();
    if (site != null && target.matchesEditorId(site.getId()))
        return true;
    if (target.matchesClass(editor.getClass()))
        return true;
    IContentType contentType = getContentType(editor);
    return contentType != null && target.matchesContentType(contentType);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) RulerColumnTarget(org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget) IContentType(org.eclipse.core.runtime.content.IContentType)

Example 45 with IWorkbenchPartSite

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

the class BrowserView method registerContextMenu.

protected void registerContextMenu(String menuName) {
    Control control = this.viewer.getControl();
    MenuManager manager = new MenuManager(menuName);
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    Menu menu = manager.createContextMenu(control);
    viewer.getControl().setMenu(menu);
    IWorkbenchPartSite partSite = getSite();
    partSite.registerContextMenu(manager, viewer);
    partSite.setSelectionProvider(viewer);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Control(org.eclipse.swt.widgets.Control) MenuManager(org.eclipse.jface.action.MenuManager) Menu(org.eclipse.swt.widgets.Menu) Separator(org.eclipse.jface.action.Separator)

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