本文整理汇总了Java中org.eclipse.jface.text.ITextViewerExtension5.modelRange2WidgetRange方法的典型用法代码示例。如果您正苦于以下问题:Java ITextViewerExtension5.modelRange2WidgetRange方法的具体用法?Java ITextViewerExtension5.modelRange2WidgetRange怎么用?Java ITextViewerExtension5.modelRange2WidgetRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.ITextViewerExtension5
的用法示例。
在下文中一共展示了ITextViewerExtension5.modelRange2WidgetRange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isVisible
import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
protected boolean isVisible(ITextViewer viewer, int offset, int length) {
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
IRegion overlap= extension.modelRange2WidgetRange(new Region(offset, length));
return overlap != null;
}
return viewer.overlapsWithVisibleRegion(offset, length);
}
示例2: highlightRegion
import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private void highlightRegion(ISourceViewer viewer, IRegion region)
{
if (region.equals(fActiveRegion)) { return; }
repairRepresentation();
StyledText text = viewer.getTextWidget();
if ((text == null) || text.isDisposed()) { return; }
// highlight region
int offset = 0;
int length = 0;
if (viewer instanceof ITextViewerExtension5)
{
ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
IRegion widgetRange = extension.modelRange2WidgetRange(region);
if (widgetRange == null) { return; }
offset = widgetRange.getOffset();
length = widgetRange.getLength();
} else
{
offset = region.getOffset() - viewer.getVisibleRegion().getOffset();
length = region.getLength();
}
StyleRange oldStyleRange = text.getStyleRangeAtOffset(offset);
Color foregroundColor = fColor;
Color backgroundColor = (oldStyleRange == null) ? text.getBackground() : oldStyleRange.background;
StyleRange styleRange = new StyleRange(offset, length, foregroundColor, backgroundColor);
text.setStyleRange(styleRange);
// underline
text.redrawRange(offset, length, true);
fActiveRegion = region;
}
示例3: paintControl
import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
public void paintControl(PaintEvent event)
{
if (fActiveRegion == null) { return; }
ISourceViewer viewer = getSourceViewer();
if (viewer == null) { return; }
StyledText text = viewer.getTextWidget();
if ((text == null) || text.isDisposed()) { return; }
int offset = 0;
int length = 0;
if (viewer instanceof ITextViewerExtension5)
{
ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
IRegion widgetRange = extension.modelRange2WidgetRange(new Region(offset, length));
if (widgetRange == null) { return; }
offset = widgetRange.getOffset();
length = widgetRange.getLength();
} else
{
IRegion region = viewer.getVisibleRegion();
if (!includes(region, fActiveRegion)) { return; }
offset = fActiveRegion.getOffset() - region.getOffset();
length = fActiveRegion.getLength();
}
// support for bidi
Point minLocation = getMinimumLocation(text, offset, length);
Point maxLocation = getMaximumLocation(text, offset, length);
int x1 = minLocation.x;
int x2 = (minLocation.x + maxLocation.x) - minLocation.x - 1;
int y = (minLocation.y + text.getLineHeight()) - 1;
GC gc = event.gc;
if ((fColor != null) && !fColor.isDisposed())
{
gc.setForeground(fColor);
}
gc.drawLine(x1, y, x2, y);
}
示例4: modelRange2WidgetRange
import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private IRegion modelRange2WidgetRange(IRegion region) {
ISourceViewer viewer= fEditor.getViewer();
if (viewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
return extension.modelRange2WidgetRange(region);
}
IRegion visibleRegion= viewer.getVisibleRegion();
int start= region.getOffset() - visibleRegion.getOffset();
int end= start + region.getLength();
if (end > visibleRegion.getLength())
end= visibleRegion.getLength();
return new Region(start, end - start);
}