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