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


Java ITextViewerExtension5类代码示例

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


ITextViewerExtension5类属于org.eclipse.jface.text包,在下文中一共展示了ITextViewerExtension5类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: widgetRegion2ModelRegion

import org.eclipse.jface.text.ITextViewerExtension5; //导入依赖的package包/类
/**
 * Translates the given text event into the corresponding range of the viewer's
 * document.
 * 
 * @param e
 *            the text event
 * @return the widget region corresponding the region of the given event or
 *         <code>null</code> if none
 * @since 2.1
 */
private IRegion widgetRegion2ModelRegion(TextEvent e) {

	String text = e.getText();
	int length = text == null ? 0 : text.length();

	if (viewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
		return extension.widgetRange2ModelRange(new Region(e.getOffset(), length));
	}

	IRegion visible = viewer.getVisibleRegion();
	IRegion region = new Region(e.getOffset() + visible.getOffset(), length);
	return region;
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:25,代码来源:TMPresentationReconciler.java

示例8: select

import org.eclipse.jface.text.ITextViewerExtension5; //导入依赖的package包/类
private void select() {
	ITextViewer viewer = fCurrentTarget.getViewer();
	if (viewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension5 = (ITextViewerExtension5) viewer;
		extension5.exposeModelRange(new Region(fFramePosition.offset, fFramePosition.length));
	} else if (!viewer.overlapsWithVisibleRegion(fFramePosition.offset, fFramePosition.length)) {
		viewer.resetVisibleRegion();
	}
	viewer.revealRange(fFramePosition.offset, fFramePosition.length);
	viewer.setSelectedRange(fFramePosition.offset, fFramePosition.length);
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:12,代码来源:TweakedLinkedModeUI.java

示例9: 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

示例10: containedByVisibleRegion

import org.eclipse.jface.text.ITextViewerExtension5; //导入依赖的package包/类
/**
 * Checks if <code>selection</code> is contained by the visible region of <code>viewer</code>.
 * As a special case, a selection is considered contained even if it extends over the visible
 * region, but the extension stays on a partially contained line and contains only white space.
 *
 * @param selection the selection to be checked
 * @param viewer the viewer displaying a visible region of <code>selection</code>'s document.
 * @return <code>true</code>, if <code>selection</code> is contained, <code>false</code> otherwise.
 */
private boolean containedByVisibleRegion(ITextSelection selection, ITextViewer viewer) {
	int min= selection.getOffset();
	int max= min + selection.getLength();
	IDocument document= viewer.getDocument();

	IRegion visible;
	if (viewer instanceof ITextViewerExtension5)
		visible= ((ITextViewerExtension5) viewer).getModelCoverage();
	else
		visible= viewer.getVisibleRegion();

	int visOffset= visible.getOffset();
	try {
		if (visOffset > min) {
			if (document.getLineOfOffset(visOffset) != selection.getStartLine())
				return false;
			if (!isWhitespace(document.get(min, visOffset - min))) {
				return false;
			}
		}
		int visEnd= visOffset + visible.getLength();
		if (visEnd < max) {
			if (document.getLineOfOffset(visEnd) != selection.getEndLine())
				return false;
			if (!isWhitespace(document.get(visEnd, max - visEnd))) {
				return false;
			}
		}
		return true;
	} catch (BadLocationException e) {
	}
	return false;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:43,代码来源:TextViewerMoveLinesAction.java

示例11: 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

示例12: adjustHighlightRange

import org.eclipse.jface.text.ITextViewerExtension5; //导入依赖的package包/类
/**
 * Adjusts the highlight range so that at least the specified range
 * is highlighted.
 * <p>
 * Subclasses may re-implement this method.</p>
 * @param viewer 
 *
 * @param offset the offset of the range which at least should be highlighted
 * @param length the length of the range which at least should be highlighted
 */
protected void adjustHighlightRange(ITextViewer viewer, int offset, int length) {
	if (viewer == null)
		return;

	if (viewer instanceof ITextViewerExtension5) {
		ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
		extension.exposeModelRange(new Region(offset, length));
	} else if (!isVisible(viewer, offset, length)) {
		viewer.resetVisibleRegion();
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:TextViewerJoinLinesAction.java

示例13: 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

示例14: 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

示例15: 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


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