Search in sources :

Example 11 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 12 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)

Example 13 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 14 with IPostSelectionProvider

use of org.eclipse.jface.viewers.IPostSelectionProvider in project eclipse.platform.text by eclipse.

the class AbstractTemplatesPage method dispose.

@Override
public void dispose() {
    ISelectionProvider selectionProvider = fViewer.getSelectionProvider();
    if (selectionProvider instanceof IPostSelectionProvider)
        ((IPostSelectionProvider) selectionProvider).removePostSelectionChangedListener(fSelectionChangedListener);
    else
        selectionProvider.removeSelectionChangedListener(fSelectionChangedListener);
    fTextEditor.setAction(ITextEditorActionConstants.PASTE, fEditorOldPasteAction);
    if (fContextMenu != null && !fContextMenu.isDisposed())
        fContextMenu.dispose();
    if (fTemplateChangeListener != null)
        getTemplatePreferenceStore().removePropertyChangeListener(fTemplateChangeListener);
    super.dispose();
}
Also used : IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider)

Example 15 with IPostSelectionProvider

use of org.eclipse.jface.viewers.IPostSelectionProvider in project eclipse.platform.text by eclipse.

the class LinkedModeUI method connect.

private void connect() {
    Assert.isNotNull(fCurrentTarget);
    ITextViewer viewer = fCurrentTarget.getViewer();
    Assert.isNotNull(viewer);
    fCurrentTarget.fWidget = viewer.getTextWidget();
    if (fCurrentTarget.fWidget == null)
        leave(ILinkedModeListener.EXIT_ALL);
    if (fCurrentTarget.fKeyListener == null) {
        fCurrentTarget.fKeyListener = new KeyListener();
        ((ITextViewerExtension) viewer).prependVerifyKeyListener(fCurrentTarget.fKeyListener);
    } else
        fCurrentTarget.fKeyListener.setEnabled(true);
    registerAutoEditVetoer(viewer);
    ((IPostSelectionProvider) viewer).addPostSelectionChangedListener(fSelectionListener);
    createAnnotationModel();
    showSelection();
    fCurrentTarget.fShell = fCurrentTarget.fWidget.getShell();
    if (fCurrentTarget.fShell == null)
        leave(ILinkedModeListener.EXIT_ALL);
    fCurrentTarget.fShell.addShellListener(fCloser);
    fAssistant.install(viewer);
    viewer.addTextInputListener(fCloser);
    viewer.getDocument().addDocumentListener(fDocumentListener);
}
Also used : ITextViewerExtension(org.eclipse.jface.text.ITextViewerExtension) IPostSelectionProvider(org.eclipse.jface.viewers.IPostSelectionProvider) VerifyKeyListener(org.eclipse.swt.custom.VerifyKeyListener) ITextViewer(org.eclipse.jface.text.ITextViewer)

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