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


Java ITextViewerExtension5.modelOffset2WidgetOffset方法代码示例

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


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

示例1: computePopupLocation

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
protected Point computePopupLocation() {
	if (popup == null || popup.isDisposed())
		return null;

	LinkedPosition position = renameLinkedMode.getCurrentLinkedPosition();
	if (position == null)
		return null;
	ISourceViewer viewer = editor.getInternalSourceViewer();
	ITextViewerExtension5 viewer5 = (ITextViewerExtension5) viewer;
	int widgetOffset = viewer5.modelOffset2WidgetOffset(position.offset);

	StyledText textWidget = viewer.getTextWidget();
	Point pos = textWidget.getLocationAtOffset(widgetOffset);
	Point pSize = getExtent();
	pSize.y += HAH + 1;
	pos.x -= HAO;
	pos.y += textWidget.getLineHeight(widgetOffset);
	Point dPos = textWidget.toDisplay(pos);
	Rectangle displayBounds = textWidget.getDisplay().getClientArea();
	Rectangle dPopupRect = Geometry.createRectangle(dPos, pSize);
	Geometry.moveInside(dPopupRect, displayBounds);
	return new Point(dPopupRect.x, dPopupRect.y);
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:RenameRefactoringPopup.java

示例2: getWidgetOffset

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

示例3: isVisible

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Tells whether the given offset is visible in the given text viewer.
 * 
 * @param viewer
 *            the text viewer
 * @param offset
 *            the offset to check
 * @return <code>true</code> if the given offset is visible in the given text viewer
 */
protected boolean isVisible(ITextViewer viewer, int offset) {
	if (viewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
		return extension.modelOffset2WidgetOffset(offset) >= 0;
	}
	IRegion region = viewer.getVisibleRegion();
	int vOffset = region.getOffset();
	return (vOffset <= offset && offset <= vOffset + region.getLength());
}
 
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:MarkRegionTargetWithoutStatusline.java

示例4: repairRepresentation

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private void repairRepresentation(boolean redrawAll)
{
    if (fActiveRegion == null) { return; }
    ISourceViewer viewer = getSourceViewer();
    if (viewer != null)
    {
        resetCursor(viewer);
        int offset = fActiveRegion.getOffset();
        int length = fActiveRegion.getLength();
        // remove style
        if (!redrawAll && viewer instanceof ITextViewerExtension2)
        {
            ((ITextViewerExtension2) viewer).invalidateTextPresentation(offset, length);
        } else
        {
            viewer.invalidateTextPresentation();
        }
        // remove underline
        if (viewer instanceof ITextViewerExtension5)
        {
            ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
            offset = extension.modelOffset2WidgetOffset(offset);
        } else
        {
            offset -= viewer.getVisibleRegion().getOffset();
        }
        StyledText text = viewer.getTextWidget();
        try
        {
            text.redrawRange(offset, length, true);
        }
        catch (IllegalArgumentException x)
        {
        }
    }
    fActiveRegion = null;
}
 
开发者ID:ninneko,项目名称:velocity-edit,代码行数:38,代码来源:VelocityEditor.java

示例5: getWidgetOffset

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Convert a document offset to the corresponding widget offset.
 * 
 * @param viewer the text viewer
 * @param documentOffset the document offset
 * @return widget offset
 * @since 3.6
 */
private int getWidgetOffset(ITextViewer viewer, int documentOffset) {
	if (viewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension= (ITextViewerExtension5)viewer;
		return extension.modelOffset2WidgetOffset(documentOffset);
	}
	IRegion visible= viewer.getVisibleRegion();
	int widgetOffset= documentOffset - visible.getOffset();
	if (widgetOffset > visible.getLength()) {
		return -1;
	}
	return widgetOffset;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:AbstractJavaCompletionProposal.java

示例6: getWidgetOffset

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

示例7: gotoMatchingBracket

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Jumps to the matching bracket.
 */
public void gotoMatchingBracket() {

	ISourceViewer sourceViewer = getSourceViewer();
	IDocument document = sourceViewer.getDocument();
	if (document == null)
		return;

	IRegion selection = getSignedSelection(sourceViewer);

	int selectionLength = Math.abs(selection.getLength());
	if (selectionLength > 1) {
		setStatusLineErrorMessage(JSDTTypeScriptUIMessages.GotoMatchingBracket_error_invalidSelection);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}

	// #26314
	int sourceCaretOffset = selection.getOffset() + selection.getLength();
	if (isSurroundedByBrackets(document, sourceCaretOffset))
		sourceCaretOffset -= selection.getLength();

	IRegion region = fBracketMatcher.match(document, sourceCaretOffset);
	if (region == null) {
		setStatusLineErrorMessage(JSDTTypeScriptUIMessages.GotoMatchingBracket_error_noMatchingBracket);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}

	int offset = region.getOffset();
	int length = region.getLength();

	if (length < 1)
		return;

	int anchor = fBracketMatcher.getAnchor();
	// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
	int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : offset + length;

	boolean visible = false;
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
		visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
	} else {
		IRegion visibleRegion = sourceViewer.getVisibleRegion();
		// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
		visible = (targetOffset >= visibleRegion.getOffset()
				&& targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
	}

	if (!visible) {
		setStatusLineErrorMessage(JSDTTypeScriptUIMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}

	if (selection.getLength() < 0)
		targetOffset -= selection.getLength();

	sourceViewer.setSelectedRange(targetOffset, selection.getLength());
	sourceViewer.revealRange(targetOffset, selection.getLength());
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:65,代码来源:JavaScriptLightWeightEditor.java

示例8: getLineRectangle

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
private Rectangle getLineRectangle(Position position)
{
	if (position == null)
	{
		return null;
	}

	// if the position that is about to be drawn was deleted then we can't
	if (position.isDeleted())
	{
		return null;
	}

	int widgetOffset = 0;
	if (fViewer instanceof ITextViewerExtension5)
	{

		ITextViewerExtension5 extension = (ITextViewerExtension5) fViewer;
		widgetOffset = extension.modelOffset2WidgetOffset(position.getOffset());
		if (widgetOffset == -1)
		{
			return null;
		}
	}
	else
	{

		IRegion visible = fViewer.getVisibleRegion();
		widgetOffset = position.getOffset() - visible.getOffset();
		if (widgetOffset < 0 || visible.getLength() < widgetOffset)
		{
			return null;
		}
	}

	StyledText textWidget = fViewer.getTextWidget();
	// check for https://bugs.eclipse.org/bugs/show_bug.cgi?id=64898
	// this is a guard against the symptoms but not the actual solution
	if (0 <= widgetOffset && widgetOffset <= textWidget.getCharCount())
	{
		Point upperLeft = textWidget.getLocationAtOffset(widgetOffset);
		int width = textWidget.getClientArea().width + textWidget.getHorizontalPixel();
		int height = textWidget.getLineHeight(widgetOffset);
		return new Rectangle(0, upperLeft.y, width, height);
	}

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

示例9: gotoMatchingBracket

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
/**
 * Jumps to the matching bracket.
 */
public void gotoMatchingBracket() {

	ISourceViewer sourceViewer= getSourceViewer();
	IDocument document= sourceViewer.getDocument();
	if (document == null)
		return;

	IRegion selection= getSignedSelection(sourceViewer);
	if (fPreviousSelections == null)
		initializePreviousSelectionList();

	IRegion region= fBracketMatcher.match(document, selection.getOffset(), selection.getLength());
	if (region == null) {
		region= fBracketMatcher.findEnclosingPeerCharacters(document, selection.getOffset(), selection.getLength());
		initializePreviousSelectionList();
		fPreviousSelections.add(selection);
	} else {
		if (fPreviousSelections.size() == 2) {
			if (!selection.equals(fPreviousSelections.get(1))) {
				initializePreviousSelectionList();
			}
		} else if (fPreviousSelections.size() == 3) {
			if (selection.equals(fPreviousSelections.get(2)) && !selection.equals(fPreviousSelections.get(0))) {
				IRegion originalSelection= fPreviousSelections.get(0);
				sourceViewer.setSelectedRange(originalSelection.getOffset(), originalSelection.getLength());
				sourceViewer.revealRange(originalSelection.getOffset(), originalSelection.getLength());
				initializePreviousSelectionList();
				return;
			}
			initializePreviousSelectionList();
		}
	}

	if (region == null) {
		setStatusLineErrorMessage(JavaEditorMessages.GotoMatchingBracket_error_noMatchingBracket);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}

	int offset= region.getOffset();
	int length= region.getLength();

	if (length < 1)
		return;

	int anchor= fBracketMatcher.getAnchor();
	// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
	int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : offset + length - 1;

	boolean visible= false;
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension= (ITextViewerExtension5) sourceViewer;
		visible= (extension.modelOffset2WidgetOffset(targetOffset) > -1);
	} else {
		IRegion visibleRegion= sourceViewer.getVisibleRegion();
		// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
		visible= (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
	}

	if (!visible) {
		setStatusLineErrorMessage(JavaEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}

	int adjustment= getOffsetAdjustment(document, selection.getOffset() + selection.getLength(), selection.getLength());
	targetOffset+= adjustment;
	int direction= (selection.getLength() == 0) ? 0 : ((selection.getLength() > 0) ? 1 : -1);
	if (fPreviousSelections.size() == 1 && direction < 0) {
		targetOffset++;
	}

	if (fPreviousSelections.size() > 0) {
		fPreviousSelections.add(new Region(targetOffset, direction));
	}
	sourceViewer.setSelectedRange(targetOffset, direction);
	sourceViewer.revealRange(targetOffset, direction);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:82,代码来源:JavaEditor.java

示例10: gotoMatchingBracket

import org.eclipse.jface.text.ITextViewerExtension5; //导入方法依赖的package包/类
public void gotoMatchingBracket() {
	ITextViewer sourceViewer = langEditor.getSourceViewer_();
	
	IDocument document= sourceViewer.getDocument();
	if (document == null)
		return;
	
	IRegion selection= EditorUtils.getSignedSelection(sourceViewer);
	if (fPreviousSelections == null)
		initializePreviousSelectionList();
	
	IRegion region= getBracketMatcher().match(document, selection.getOffset(), selection.getLength());
	if (region == null) {
		region= getBracketMatcher().findEnclosingPeerCharacters(document, selection.getOffset(), selection.getLength());
		initializePreviousSelectionList();
		fPreviousSelections.add(selection);
	} else {
		if (fPreviousSelections.size() == 2) {
			if (!selection.equals(fPreviousSelections.get(1))) {
				initializePreviousSelectionList();
			}
		} else if (fPreviousSelections.size() == 3) {
			if (selection.equals(fPreviousSelections.get(2)) && !selection.equals(fPreviousSelections.get(0))) {
				IRegion originalSelection= fPreviousSelections.get(0);
				sourceViewer.setSelectedRange(originalSelection.getOffset(), originalSelection.getLength());
				sourceViewer.revealRange(originalSelection.getOffset(), originalSelection.getLength());
				initializePreviousSelectionList();
				return;
			}
			initializePreviousSelectionList();
		}
	}
	
	if (region == null) {
		langEditor.setStatusLineErrorMessage(LangEditorMessages.GotoMatchingBracket_error_noMatchingBracket);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}
	
	int offset= region.getOffset();
	int length= region.getLength();
	
	if (length < 1)
		return;
	
	int anchor= getBracketMatcher().getAnchor();
	// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
	int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1 : offset + length - 1;
	
	boolean visible= false;
	if (sourceViewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension= (ITextViewerExtension5) sourceViewer;
		visible= (extension.modelOffset2WidgetOffset(targetOffset) > -1);
	} else {
		IRegion visibleRegion= sourceViewer.getVisibleRegion();
		// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
		visible= (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
	}
	
	if (!visible) {
		langEditor.setStatusLineErrorMessage(LangEditorMessages.GotoMatchingBracket_error_bracketOutsideSelectedElement);
		sourceViewer.getTextWidget().getDisplay().beep();
		return;
	}
	
	int adjustment= getBracketMatcher().getOffsetAdjustment(document, selection.getOffset() + selection.getLength(), selection.getLength());
	targetOffset+= adjustment;
	int direction= (selection.getLength() == 0) ? 0 : ((selection.getLength() > 0) ? 1 : -1);
	if (fPreviousSelections.size() == 1 && direction < 0) {
		targetOffset++;
	}
	
	if (fPreviousSelections.size() > 0) {
		fPreviousSelections.add(new Region(targetOffset, direction));
	}
	sourceViewer.setSelectedRange(targetOffset, direction);
	sourceViewer.revealRange(targetOffset, direction);
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:79,代码来源:GotoMatchingBracketManager.java


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