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);
}
}
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);
}
}
}
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);
}
}
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);
}
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;
}
Aggregations