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


Java ITextViewerExtension5.widgetOffset2ModelOffset方法代码示例

本文整理汇总了Java中org.eclipse.jface.text.ITextViewerExtension5.widgetOffset2ModelOffset方法的典型用法代码示例。如果您正苦于以下问题:Java ITextViewerExtension5.widgetOffset2ModelOffset方法的具体用法?Java ITextViewerExtension5.widgetOffset2ModelOffset怎么用?Java ITextViewerExtension5.widgetOffset2ModelOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.text.ITextViewerExtension5的用法示例。


在下文中一共展示了ITextViewerExtension5.widgetOffset2ModelOffset方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeHighlightRange

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Computes and returns the source reference that includes the caret and serves as provider for the
 * outline pageModel selection and the editor range indication.
 *
 * @return the computed source reference
 */
public ISourceReference computeHighlightRange() {
	ISourceViewer sourceViewer = getSourceViewer();
	if (sourceViewer == null) return null;

	StyledText styledText = sourceViewer.getTextWidget();
	if (styledText == null) return null;

	int caret = 0;
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
		caret = extension.widgetOffset2ModelOffset(styledText.getSelection().x);
	} else {
		int offset = sourceViewer.getVisibleRegion().getOffset();
		caret = offset + styledText.getSelection().x;
	}

	PagePart part = getPagePartAt(caret, false);
	return (ISourceReference) part;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:26,代码来源:FluentMkEditor.java

示例2: getCurrentTextOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private int getCurrentTextOffset(ISourceViewer viewer)
{
    try
    {
        StyledText text = viewer.getTextWidget();
        if ((text == null) || text.isDisposed()) { return -1; }
        Display display = text.getDisplay();
        Point absolutePosition = display.getCursorLocation();
        Point relativePosition = text.toControl(absolutePosition);
        int widgetOffset = text.getOffsetAtLocation(relativePosition);
        if (viewer instanceof ITextViewerExtension5)
        {
            ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
            return extension.widgetOffset2ModelOffset(widgetOffset);
        } else
        {
            return widgetOffset + viewer.getVisibleRegion().getOffset();
        }
    }
    catch (IllegalArgumentException e)
    {
        return -1;
    }
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:25,代码来源:VelocityEditor.java

示例3: createDialogArea

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Control createDialogArea(Composite parent)
{
	Composite composite = new Composite(parent, SWT.NONE);
	GridLayoutFactory.fillDefaults().applyTo(composite);

	fPage.createControl(composite);

	// Try to select the current item we're on in editor in the outline
	ISourceViewer viewer = fEditor.getISourceViewer();
	int offset = viewer.getTextWidget().getCaretOffset();
	if (viewer instanceof ITextViewerExtension5)
	{
		ITextViewerExtension5 v5 = (ITextViewerExtension5) viewer;
		offset = v5.widgetOffset2ModelOffset(offset);
	}
	if (offset != -1)
	{
		fPage.revealPosition(offset);
	}
	GridDataFactory.fillDefaults().hint(320, 240).applyTo(composite);

	return composite;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:28,代码来源:QuickOutlinePopupDialog.java

示例4: getCaretOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
public int getCaretOffset()
{
	ISourceViewer sourceViewer = getSourceViewer();
	if (sourceViewer == null)
	{
		return -1;
	}
	StyledText styledText = sourceViewer.getTextWidget();
	if (styledText == null)
	{
		return -1;
	}

	if (sourceViewer instanceof ITextViewerExtension5)
	{
		ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
		return extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
	}
	int offset = sourceViewer.getVisibleRegion().getOffset();
	return offset + styledText.getCaretOffset();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:22,代码来源:AbstractThemeableEditor.java

示例5: getCursorOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
@Override
public int getCursorOffset() {
	ISourceViewer sourceViewer = getSourceViewer();
	StyledText styledText = sourceViewer.getTextWidget();
	if (styledText == null) {
		return 0;
	}
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
		return extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
	} else {
		int offset = sourceViewer.getVisibleRegion().getOffset();
		return offset + styledText.getCaretOffset();
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:16,代码来源:TypeScriptEditor.java

示例6: getDocumentOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Convert a widget offset to the corresponding document offset.
 * 
 * @param widgetOffset
 * @return document offset
 */
private int getDocumentOffset(int widgetOffset)
{
	if (fTextViewer instanceof ITextViewerExtension5)
	{
		ITextViewerExtension5 extension = (ITextViewerExtension5) fTextViewer;
		return extension.widgetOffset2ModelOffset(widgetOffset);
	}
	IRegion visible = fTextViewer.getVisibleRegion();
	if (widgetOffset > visible.getLength())
	{
		return -1;
	}
	return widgetOffset + visible.getOffset();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:21,代码来源:WhitespaceCharacterPainter.java

示例7: getCaretOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private static int getCaretOffset(ITextViewer textViewer)
{
	StyledText textWidget = textViewer.getTextWidget();
	int caretOffset = textWidget.getCaretOffset();
	if (textViewer instanceof ITextViewerExtension5)
	{
		ITextViewerExtension5 extension = (ITextViewerExtension5) textViewer;
		return extension.widgetOffset2ModelOffset(caretOffset);
	}
	return caretOffset;
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:12,代码来源:CommandExecutionUtils.java

示例8: getModelCaret

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Returns the location of the caret as offset in the source viewer's input document.
 * 
 * @return the caret location
 */
private int getModelCaret()
{
	int widgetCaret = fViewer.getTextWidget().getCaretOffset();
	if (fViewer instanceof ITextViewerExtension5)
	{
		ITextViewerExtension5 extension = (ITextViewerExtension5) fViewer;
		return extension.widgetOffset2ModelOffset(widgetCaret);
	}
	IRegion visible = fViewer.getVisibleRegion();
	return widgetCaret + visible.getOffset();
}
 
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:17,代码来源:LineBackgroundPainter.java

示例9: createStyleRange

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Creates a style range for the text viewer.
 * 
 * @param viewer the text viewer
 * @return the new style range for the text viewer or <code>null</code>
 * @since 3.6
 */
private StyleRange createStyleRange(ITextViewer viewer) {
	StyledText text= viewer.getTextWidget();
	if (text == null || text.isDisposed())
		return null;

	int widgetCaret= text.getCaretOffset();

	int modelCaret= 0;
	if (viewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
		modelCaret= extension.widgetOffset2ModelOffset(widgetCaret);
	} else {
		IRegion visibleRegion= viewer.getVisibleRegion();
		modelCaret= widgetCaret + visibleRegion.getOffset();
	}

	if (modelCaret >= getReplacementOffset() + getReplacementLength())
		return null;

	int length= getReplacementOffset() + getReplacementLength() - modelCaret;

	Color foreground= getForegroundColor();
	Color background= getBackgroundColor();

	return new StyleRange(modelCaret, length, foreground, background);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:34,代码来源:AbstractJavaCompletionProposal.java

示例10: createStyleRange

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private StyleRange createStyleRange(ITextViewer viewer, int initialOffset, int len) {
    StyledText text = viewer.getTextWidget();
    if (text == null || text.isDisposed()) {
        return null;
    }

    int widgetCaret = text.getCaretOffset();

    int modelCaret = 0;
    if (viewer instanceof ITextViewerExtension5) {
        ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
        modelCaret = extension.widgetOffset2ModelOffset(widgetCaret);
    } else {
        IRegion visibleRegion = viewer.getVisibleRegion();
        modelCaret = widgetCaret + visibleRegion.getOffset();
    }

    if (modelCaret >= initialOffset + len) {
        return null;
    }

    int length = initialOffset + len - modelCaret;

    Color foreground = getForegroundColor();
    Color background = getBackgroundColor();

    return new StyleRange(modelCaret, length, foreground, background);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:29,代码来源:PyCompletionPresentationUpdater.java

示例11: getDocumentOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Convert a widget offset to the corresponding document offset.
 * 
 * @param widgetOffset
 *            the widget offset
 * @return document offset
 */
private int getDocumentOffset(int widgetOffset) {
	if (fTextViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) fTextViewer;
		return extension.widgetOffset2ModelOffset(widgetOffset);
	}
	IRegion visible = fTextViewer.getVisibleRegion();
	if (widgetOffset > visible.getLength()) {
		return -1;
	}
	return widgetOffset + visible.getOffset();
}
 
开发者ID:sschaef,项目名称:IndentGuide,代码行数:19,代码来源:IndentGuidePainter.java

示例12: computeHighlightRangeSourceReference

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Computes and returns the source reference that includes the caret and
 * serves as provider for the outline page selection and the editor range
 * indication.
 *
 * @return the computed source reference
 * @since 3.0
 */
protected ISourceReference computeHighlightRangeSourceReference() {
	ISourceViewer sourceViewer= getSourceViewer();
	if (sourceViewer == null)
		return null;

	StyledText styledText= sourceViewer.getTextWidget();
	if (styledText == null)
		return null;

	int caret= 0;
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension= (ITextViewerExtension5)sourceViewer;
		caret= extension.widgetOffset2ModelOffset(styledText.getCaretOffset());
	} else {
		int offset= sourceViewer.getVisibleRegion().getOffset();
		caret= offset + styledText.getCaretOffset();
	}

	IJavaElement element= getElementAt(caret, false);

	if ( !(element instanceof ISourceReference))
		return null;

	if (element.getElementType() == IJavaElement.IMPORT_DECLARATION) {

		IImportDeclaration declaration= (IImportDeclaration) element;
		IImportContainer container= (IImportContainer) declaration.getParent();
		ISourceRange srcRange= null;

		try {
			srcRange= container.getSourceRange();
		} catch (JavaModelException e) {
		}

		if (srcRange != null && srcRange.getOffset() == caret)
			return container;
	}

	return (ISourceReference) element;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:49,代码来源:JavaEditor.java


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