Search in sources :

Example 16 with IPostSelectionProvider

use of org.eclipse.jface.viewers.IPostSelectionProvider in project webtools.sourceediting by eclipse.

the class GoToMatchingTagAction method setEditor.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor)
	 */
public void setEditor(ITextEditor editor) {
    ITextEditor textEditor = getTextEditor();
    if (textEditor != null) {
        removeAnnotation(true);
        ISelectionProvider selectionProvider = textEditor.getSelectionProvider();
        if (selectionProvider instanceof IPostSelectionProvider) {
            ((IPostSelectionProvider) selectionProvider).removePostSelectionChangedListener(fUpdateListener);
        }
    }
    super.setEditor(editor);
    if (editor != null) {
        ISelectionProvider selectionProvider = editor.getSelectionProvider();
        if (selectionProvider instanceof IPostSelectionProvider) {
            ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fUpdateListener);
        }
        updateFor(selectionProvider.getSelection());
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 17 with IPostSelectionProvider

use of org.eclipse.jface.viewers.IPostSelectionProvider in project xtext-eclipse by eclipse.

the class RailroadSelectionLinker method setXtextEditor.

public void setXtextEditor(XtextEditor xtextEditor) {
    if (currentEditor != null) {
        removeTextSelectionListener(currentEditor);
    }
    if (XTEXT_LANGUAGE_NAME.equals(xtextEditor.getLanguageName())) {
        currentEditor = xtextEditor;
        ISelectionProvider selectionProvider = xtextEditor.getSelectionProvider();
        if (selectionProvider instanceof IPostSelectionProvider)
            ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(textSelectionChangeListener);
        else
            selectionProvider.addSelectionChangedListener(textSelectionChangeListener);
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Aggregations

IPostSelectionProvider (org.eclipse.jface.viewers.IPostSelectionProvider)17 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)13 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)5 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)3 CoreException (org.eclipse.core.runtime.CoreException)2 ITextViewer (org.eclipse.jface.text.ITextViewer)2 ISelection (org.eclipse.jface.viewers.ISelection)2 Iterator (java.util.Iterator)1 TimeoutException (java.util.concurrent.TimeoutException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 DocShare (org.eclipse.ecf.docshare2.DocShare)1 ResourcesShare (org.eclipse.ecf.internal.sync.resources.core.ResourcesShare)1 ITextInputListener (org.eclipse.jface.text.ITextInputListener)1 ITextSelection (org.eclipse.jface.text.ITextSelection)1 ITextViewerExtension (org.eclipse.jface.text.ITextViewerExtension)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1