use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class DeleteLineAction method getSelection.
/**
* Returns the editor's selection.
*
* @param editor the editor
* @return the editor's selection
*/
private static ITextSelection getSelection(ITextEditor editor) {
ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider == null)
return null;
ISelection selection = selectionProvider.getSelection();
if (!(selection instanceof ITextSelection))
return null;
return (ITextSelection) selection;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class IncrementalFindTarget method install.
/**
* Installs this target. I.e. adds all required listeners.
*/
private void install() {
if (fInstalled)
return;
StyledText text = fTextViewer.getTextWidget();
if (text == null)
return;
text.addMouseListener(this);
text.addFocusListener(this);
fTextViewer.addTextListener(this);
ISelectionProvider selectionProvider = fTextViewer.getSelectionProvider();
if (selectionProvider != null)
selectionProvider.addSelectionChangedListener(this);
if (fTextViewer instanceof ITextViewerExtension)
((ITextViewerExtension) fTextViewer).prependVerifyKeyListener(this);
else
text.addVerifyKeyListener(this);
ICommandService commandService = PlatformUI.getWorkbench().getAdapter(ICommandService.class);
if (commandService != null)
commandService.addExecutionListener(this);
fInstalled = true;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class JoinLinesAction method getSelection.
/**
* Returns the editor's selection.
*
* @param editor the editor
* @return the editor's selection
*/
private static ITextSelection getSelection(ITextEditor editor) {
ISelectionProvider selectionProvider = editor.getSelectionProvider();
if (selectionProvider == null)
return null;
ISelection selection = selectionProvider.getSelection();
if (!(selection instanceof ITextSelection))
return null;
return (ITextSelection) selection;
}
use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class AbstractTemplatesPage method setupSelectionProvider.
/**
* Setup a selection listener to monitor the editor
*/
private void setupSelectionProvider() {
ISelectionProvider selectionProvider = fViewer.getSelectionProvider();
fSelectionChangedListener = new SelectionChangedListener();
if (selectionProvider instanceof IPostSelectionProvider)
((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fSelectionChangedListener);
else
selectionProvider.addSelectionChangedListener(fSelectionChangedListener);
}
use of org.eclipse.jface.viewers.ISelectionProvider in project eclipse.platform.text by eclipse.
the class QuickDiffRestoreAction method getSelection.
/**
* Returns the selection of the editor this action belongs to.
*
* @return the editor's selection, or <code>null</code>
*/
protected ITextSelection getSelection() {
if (getTextEditor() == null)
return null;
ISelectionProvider sp = getTextEditor().getSelectionProvider();
if (sp == null)
return null;
ISelection s = sp.getSelection();
if (s instanceof ITextSelection)
return (ITextSelection) s;
return null;
}
Aggregations