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