use of org.eclipse.jface.text.ITextViewer in project KaiZen-OpenAPI-Editor by RepreZen.
the class Mocks method mockTextViewer.
public static ITextViewer mockTextViewer(SwaggerDocument document) {
ITextViewer viewer = mock(ITextViewer.class);
when(viewer.getDocument()).thenReturn(document);
return viewer;
}
use of org.eclipse.jface.text.ITextViewer in project KaiZen-OpenAPI-Editor by RepreZen.
the class Mocks method mockTextViewer.
public static ITextViewer mockTextViewer(OpenApi3Document document, int offset) {
ITextViewer viewer = mock(ITextViewer.class);
ISelectionProvider selectionProvider = mockSelectionProvider();
ITextSelection selection = mockSelection();
when(viewer.getDocument()).thenReturn(document);
when(viewer.getSelectedRange()).thenReturn(new Point(0, 0));
when(viewer.getSelectionProvider()).thenReturn(selectionProvider);
when(selectionProvider.getSelection()).thenReturn(selection);
when(selection.getOffset()).thenReturn(offset);
return viewer;
}
use of org.eclipse.jface.text.ITextViewer in project KaiZen-OpenAPI-Editor by RepreZen.
the class Mocks method mockTextViewer.
public static ITextViewer mockTextViewer(SwaggerDocument document, int offset) {
ITextViewer viewer = mock(ITextViewer.class);
ISelectionProvider selectionProvider = mockSelectionProvider();
ITextSelection selection = mockSelection();
when(viewer.getDocument()).thenReturn(document);
when(viewer.getSelectedRange()).thenReturn(new Point(0, 0));
when(viewer.getSelectionProvider()).thenReturn(selectionProvider);
when(selectionProvider.getSelection()).thenReturn(selection);
when(selection.getOffset()).thenReturn(offset);
return viewer;
}
use of org.eclipse.jface.text.ITextViewer in project eclipse.platform.text by eclipse.
the class ShowWhitespaceCharactersAction method installPainter.
/**
* Installs the painter on the editor.
*/
private void installPainter() {
Assert.isTrue(fWhitespaceCharPainter == null);
ITextViewer viewer = getTextViewer();
if (viewer instanceof ITextViewerExtension2) {
if (fStore != null) {
fWhitespaceCharPainter = new WhitespaceCharacterPainter(viewer, fShowLeadingSpaces, fShowEnclosedSpaces, fShowTrailingSpaces, fShowLeadingIdeographicSpaces, fShowEnclosedIdeographicSpaces, fShowTrailingIdeographicSpace, fShowLeadingTabs, fShowEnclosedTabs, fShowTrailingTabs, fShowCarriageReturn, fShowLineFeed, fAlpha);
} else {
fWhitespaceCharPainter = new WhitespaceCharacterPainter(viewer);
}
((ITextViewerExtension2) viewer).addPainter(fWhitespaceCharPainter);
}
}
use of org.eclipse.jface.text.ITextViewer in project eclipse.platform.text by eclipse.
the class TextViewerDeleteLineTarget method clipToVisibleRegion.
/**
* Clips the given start and end offset to the visible viewer region.
*
* @param startOffset the start offset
* @param endOffset the end offset
* @return the clipped region
* @since 3.3.2
*/
private IRegion clipToVisibleRegion(int startOffset, int endOffset) {
ITextViewer viewer = fClipboard.getViewer();
IRegion visibleRegion;
if (viewer instanceof ITextViewerExtension5)
visibleRegion = ((ITextViewerExtension5) viewer).getModelCoverage();
else
visibleRegion = viewer.getVisibleRegion();
int visibleStart = visibleRegion.getOffset();
int visibleLength = visibleRegion.getLength();
startOffset = Math.max(startOffset, visibleStart);
endOffset = Math.min(endOffset, visibleStart + visibleLength);
return new Region(startOffset, endOffset - startOffset);
}
Aggregations