当前位置: 首页>>代码示例>>Java>>正文


Java ITextViewerExtension5.modelRange2WidgetRange方法代码示例

本文整理汇总了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);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:9,代码来源:TextViewerJoinLinesAction.java

示例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;
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:31,代码来源:VelocityEditor.java

示例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);
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:37,代码来源:VelocityEditor.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:16,代码来源:JDTQuickMenuCreator.java


注:本文中的org.eclipse.jface.text.ITextViewerExtension5.modelRange2WidgetRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。