Java Code Examples for org.eclipse.jface.text.TextSelection#emptySelection()

The following examples show how to use org.eclipse.jface.text.TextSelection#emptySelection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public ITextViewer getSourceViewer(final String currentModelToParse, final IXtextDocument xtextDocument) {
	ITextViewer result = new MockableTextViewer() {
		@Override
		public IDocument getDocument() {
			return xtextDocument;
		}
		
		@Override
		public ISelectionProvider getSelectionProvider() {
			return new MockableSelectionProvider() {
				@Override
				public ISelection getSelection() {
					return TextSelection.emptySelection();
				}
			};
		}
		
		@Override
		public StyledText getTextWidget() {
			return null;
		}
	};
	return result;
}
 
Example 2
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public ITextViewer getSourceViewer(final String currentModelToParse, final IXtextDocument xtextDocument) {
	ITextViewer result = new MockableTextViewer() {
		@Override
		public IDocument getDocument() {
			return xtextDocument;
		}
		
		@Override
		public ISelectionProvider getSelectionProvider() {
			return new MockableSelectionProvider() {
				@Override
				public ISelection getSelection() {
					return TextSelection.emptySelection();
				}
			};
		}
		
		@Override
		public StyledText getTextWidget() {
			return null;
		}
	};
	return result;
}
 
Example 3
Source File: IndentAction.java    From typescript.java with MIT License 5 votes vote down vote up
/**
 * Returns the selection on the editor or an invalid selection if none can
 * be obtained. Returns never <code>null</code>.
 * 
 * @return the current selection, never <code>null</code>
 */
private ITextSelection getSelection() {
	ISelectionProvider provider = getSelectionProvider();
	if (provider != null) {

		ISelection selection = provider.getSelection();
		if (selection instanceof ITextSelection)
			return (ITextSelection) selection;
	}

	// null object
	return TextSelection.emptySelection();
}
 
Example 4
Source File: ExpandSnippetVerifyKeyListener.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
protected ITextSelection getSelection()
{
	if (textEditor == null || textEditor.getSelectionProvider() == null)
	{
		return TextSelection.emptySelection();
	}
	return (ITextSelection) textEditor.getSelectionProvider().getSelection();
}
 
Example 5
Source File: IndentAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the selection on the editor or an invalid selection if none can be obtained. Returns
 * never <code>null</code>.
 *
 * @return the current selection, never <code>null</code>
 */
private ITextSelection getSelection() {
	ISelectionProvider provider= getSelectionProvider();
	if (provider != null) {

		ISelection selection= provider.getSelection();
		if (selection instanceof ITextSelection)
			return (ITextSelection) selection;
	}

	// null object
	return TextSelection.emptySelection();
}