Search in sources :

Example 1 with IPostSelectionProvider

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

the class LinkWithEditorTest method testTreeToText.

@Test
public void testTreeToText() throws Exception {
    IPostSelectionProvider editorSelectionProvider = (IPostSelectionProvider) editor.getSelectionProvider();
    editorSelectionProvider.addPostSelectionChangedListener(selectionSyncer);
    assertSelected(treeViewer);
    activate(editor);
    try {
        selectionSyncer.start();
        treeViewer.setSelection(new StructuredSelection(modelNode));
        selectionSyncer.awaitSignal(EXPECTED_TIMEOUT);
        fail("Selection from inactive part should not be linked");
    } catch (TimeoutException e) {
    }
    activate(outlineView);
    try {
        checkTreeSelectionToText(modelNode, modelAsText, selectionSyncer);
        checkTreeSelectionToText(oneNode, "one", selectionSyncer);
        checkTreeSelectionToText(twoNode, "two", selectionSyncer);
        checkTreeSelectionToText(threeNode, "three", selectionSyncer);
        checkTreeSelectionToText(fourNode, "four", selectionSyncer);
    } finally {
        editorSelectionProvider.removePostSelectionChangedListener(selectionSyncer);
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 2 with IPostSelectionProvider

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

the class XtextEditor method uninstallSelectionChangedListener.

private void uninstallSelectionChangedListener() {
    ISelectionProvider selectionProvider = getSelectionProvider();
    if (selectionProvider != null) {
        if (selectionProvider instanceof IPostSelectionProvider) {
            final IPostSelectionProvider postSelectionProvider = (IPostSelectionProvider) selectionProvider;
            postSelectionProvider.removePostSelectionChangedListener(selectionChangedListener);
        } else {
            selectionProvider.removeSelectionChangedListener(selectionChangedListener);
        }
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 3 with IPostSelectionProvider

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

the class XtextEditor method installSelectionChangedListener.

private void installSelectionChangedListener() {
    selectionChangedListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateStatusLine();
        }
    };
    final ISelectionProvider selectionProvider = getSelectionProvider();
    if (selectionProvider instanceof IPostSelectionProvider) {
        final IPostSelectionProvider postSelectionProvider = (IPostSelectionProvider) selectionProvider;
        postSelectionProvider.addPostSelectionChangedListener(selectionChangedListener);
    } else {
        getSelectionProvider().addSelectionChangedListener(selectionChangedListener);
    }
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 4 with IPostSelectionProvider

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

the class OutlineWithEditorLinker method activate.

public void activate(OutlinePage outlinePage) {
    this.outlinePage = outlinePage;
    treeViewer = outlinePage.getTreeViewer();
    treeListener = new TreeListener();
    treeViewer.addPostSelectionChangedListener(treeListener);
    treeViewer.addDoubleClickListener(treeListener);
    textViewer = outlinePage.getSourceViewer();
    textListener = new TextListener();
    ISelectionProvider textSelectionProvider = textViewer.getSelectionProvider();
    if (textSelectionProvider instanceof IPostSelectionProvider)
        ((IPostSelectionProvider) textSelectionProvider).addPostSelectionChangedListener(textListener);
    else
        textSelectionProvider.addSelectionChangedListener(textListener);
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 5 with IPostSelectionProvider

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

the class OutlineWithEditorLinker method deactivate.

public void deactivate() {
    ISelectionProvider textSelectionProvider = textViewer.getSelectionProvider();
    if (textSelectionProvider instanceof IPostSelectionProvider)
        ((IPostSelectionProvider) textSelectionProvider).removePostSelectionChangedListener(textListener);
    else
        textSelectionProvider.removeSelectionChangedListener(textListener);
    textListener = null;
    textViewer = null;
    treeViewer.removePostSelectionChangedListener(treeListener);
    treeViewer.removeDoubleClickListener(treeListener);
    treeViewer = null;
    treeListener = null;
    outlinePage = null;
}
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)6 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 CoreException (org.eclipse.core.runtime.CoreException)2 ITextSelection (org.eclipse.jface.text.ITextSelection)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 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