本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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();
}
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}