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