Tabnine Logo
TextViewer.modelRange2WidgetRange
Code IndexAdd Tabnine to your IDE (free)

How to use
modelRange2WidgetRange
method
in
org.eclipse.jface.text.TextViewer

Best Java code snippets using org.eclipse.jface.text.TextViewer.modelRange2WidgetRange (Showing top 20 results out of 315)

origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Returns whether the marked region of this viewer is empty.
 *
 * @return <code>true</code> if the marked region of this viewer is empty, otherwise <code>false</code>
 * @since 2.0
 */
private boolean isMarkedRegionEmpty() {
  return
    fTextWidget == null ||
    fMarkPosition == null ||
    fMarkPosition.isDeleted() ||
    modelRange2WidgetRange(fMarkPosition) == null;
}
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Returns whether the marked region of this viewer is empty.
 *
 * @return <code>true</code> if the marked region of this viewer is empty, otherwise <code>false</code>
 * @since 2.0
 */
private boolean isMarkedRegionEmpty() {
  return
    fTextWidget == null ||
    fMarkPosition == null ||
    fMarkPosition.isDeleted() ||
    modelRange2WidgetRange(fMarkPosition) == null;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Same as {@link #modelRange2WidgetRange(IRegion)} just for a {@link org.eclipse.jface.text.Position}.
 *
 * @param modelPosition the position describing a range in the viewer's document
 * @return a region describing a range in the viewer's widget
 * @since 2.1
 */
protected IRegion modelRange2WidgetRange(Position modelPosition) {
  return modelRange2WidgetRange(new Region(modelPosition.getOffset(), modelPosition.getLength()));
}
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Same as {@link #modelRange2WidgetRange(IRegion)} just for a {@link org.eclipse.jface.text.Position}.
 *
 * @param modelPosition the position describing a range in the viewer's document
 * @return a region describing a range in the viewer's widget
 * @since 2.1
 */
protected IRegion modelRange2WidgetRange(Position modelPosition) {
  return modelRange2WidgetRange(new Region(modelPosition.getOffset(), modelPosition.getLength()));
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

IRegion region= modelRange2WidgetRange(presentation.getCoverage());
if (region == null)
  return;
origin: org.eclipse.platform/org.eclipse.jface.text

IRegion region= modelRange2WidgetRange(presentation.getCoverage());
if (region == null)
  return;
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Translates a style range given relative to the viewer's document into style
 * ranges relative to the viewer's widget or <code>null</code>.
 *
 * @param range the style range in the coordinates of the viewer's document
 * @return the style range in the coordinates of the viewer's widget or <code>null</code>
 * @since 2.1
 */
protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
  IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
  if (region != null) {
    StyleRange result= (StyleRange) range.clone();
    result.start= region.getOffset();
    result.length= region.getLength();
    return result;
  }
  return null;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Translates a style range given relative to the viewer's document into style
 * ranges relative to the viewer's widget or <code>null</code>.
 *
 * @param range the style range in the coordinates of the viewer's document
 * @return the style range in the coordinates of the viewer's widget or <code>null</code>
 * @since 2.1
 */
protected StyleRange modelStyleRange2WidgetStyleRange(StyleRange range) {
  IRegion region= modelRange2WidgetRange(new Region(range.start, range.length));
  if (region != null) {
    StyleRange result= (StyleRange) range.clone();
    result.start= region.getOffset();
    result.length= region.getLength();
    return result;
  }
  return null;
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui

  return null;
IRegion region= ((TextViewer)fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length));
if (region == null)
  return null;
origin: org.eclipse/org.eclipse.jdt.ui

  return null;
IRegion region= ((TextViewer)fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length));
if (region == null)
  return null;
origin: org.eclipse.jdt/org.eclipse.jdt.ui

  return null;
IRegion region= ((TextViewer)fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length));
if (region == null)
  return null;
origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor

private IRegion modelRange2WidgetRange(IRegion region) {
  if (fEditorViewer instanceof ITextViewerExtension5) {
    ITextViewerExtension5 extension = (ITextViewerExtension5) fEditorViewer;
    return extension.modelRange2WidgetRange(region);
  }
  if (fEditorViewer instanceof TextViewer) {
    return ((TextViewer) fEditorViewer).modelRange2WidgetRange(region);
  }
  IRegion visibleRegion = fEditorViewer.getVisibleRegion();
  int start = region.getOffset() - visibleRegion.getOffset();
  int end = start + region.getLength();
  if (end > visibleRegion.getLength())
    end = visibleRegion.getLength();
  return new Region(start, end - start);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Invalidates the given range of the text presentation.
 *
 * @param offset the offset of the range to be invalidated
 * @param length the length of the range to be invalidated
 * @since 2.1
 */
@Override
public final void invalidateTextPresentation(int offset, int length) {
  if (fVisibleDocument != null) {
    IRegion widgetRange= modelRange2WidgetRange(new Region(offset, length));
    if (widgetRange != null) {
      fWidgetCommand.event= null;
      fWidgetCommand.start= widgetRange.getOffset();
      fWidgetCommand.length= widgetRange.getLength();
      try {
        fWidgetCommand.text= fVisibleDocument.get(widgetRange.getOffset(), widgetRange.getLength());
        updateTextListeners(fWidgetCommand);
      } catch (BadLocationException x) {
        // can not happen because of previous checking
      }
    }
  }
}
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Invalidates the given range of the text presentation.
 *
 * @param offset the offset of the range to be invalidated
 * @param length the length of the range to be invalidated
 * @since 2.1
 */
@Override
public final void invalidateTextPresentation(int offset, int length) {
  if (fVisibleDocument != null) {
    IRegion widgetRange= modelRange2WidgetRange(new Region(offset, length));
    if (widgetRange != null) {
      fWidgetCommand.event= null;
      fWidgetCommand.start= widgetRange.getOffset();
      fWidgetCommand.length= widgetRange.getLength();
      try {
        fWidgetCommand.text= fVisibleDocument.get(widgetRange.getOffset(), widgetRange.getLength());
        updateTextListeners(fWidgetCommand);
      } catch (BadLocationException x) {
        // can not happen because of previous checking
      }
    }
  }
}
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Paints the highlighting of this range.
 */
private void paint() {
  IRegion widgetRegion= modelRange2WidgetRange(fPosition);
  int offset= widgetRegion.getOffset();
  int length= widgetRegion.getLength();
  int count= fTextWidget.getCharCount();
  if (offset + length >= count) {
    length= count - offset; // clip
    Point upperLeft= fTextWidget.getLocationAtOffset(offset);
    Point lowerRight= fTextWidget.getLocationAtOffset(offset + length);
    int width= fTextWidget.getClientArea().width;
    int height= fTextWidget.getLineHeight(offset + length) + lowerRight.y - upperLeft.y;
    fTextWidget.redraw(upperLeft.x, upperLeft.y, width, height, false);
  }
  fTextWidget.redrawRange(offset, length, true);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Paints the highlighting of this range.
 */
private void paint() {
  IRegion widgetRegion= modelRange2WidgetRange(fPosition);
  int offset= widgetRegion.getOffset();
  int length= widgetRegion.getLength();
  int count= fTextWidget.getCharCount();
  if (offset + length >= count) {
    length= count - offset; // clip
    Point upperLeft= fTextWidget.getLocationAtOffset(offset);
    Point lowerRight= fTextWidget.getLocationAtOffset(offset + length);
    int width= fTextWidget.getClientArea().width;
    int height= fTextWidget.getLineHeight(offset + length) + lowerRight.y - upperLeft.y;
    fTextWidget.redraw(upperLeft.x, upperLeft.y, width, height, false);
  }
  fTextWidget.redrawRange(offset, length, true);
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Copies/cuts the marked region.
 *
 * @param delete <code>true</code> if the region should be deleted rather than copied.
 * @since 2.0
 */
protected void copyMarkedRegion(boolean delete) {
  if (fTextWidget == null)
    return;
  if (fMarkPosition == null || fMarkPosition.isDeleted() || modelRange2WidgetRange(fMarkPosition) == null)
    return;
  int widgetMarkOffset= modelOffset2WidgetOffset(fMarkPosition.offset);
  Point selection= fTextWidget.getSelection();
  if (selection.x <= widgetMarkOffset)
    fTextWidget.setSelection(selection.x, widgetMarkOffset);
  else
    fTextWidget.setSelection(widgetMarkOffset, selection.x);
  if (delete) {
    wrapCompoundChange(new Runnable() {
      @Override
      public void run() {
        fTextWidget.cut();
      }
    });
  } else {
    fTextWidget.copy();
    fTextWidget.setSelection(selection.x); // restore old cursor position
  }
}
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Copies/cuts the marked region.
 *
 * @param delete <code>true</code> if the region should be deleted rather than copied.
 * @since 2.0
 */
protected void copyMarkedRegion(boolean delete) {
  if (fTextWidget == null)
    return;
  if (fMarkPosition == null || fMarkPosition.isDeleted() || modelRange2WidgetRange(fMarkPosition) == null)
    return;
  int widgetMarkOffset= modelOffset2WidgetOffset(fMarkPosition.offset);
  Point selection= fTextWidget.getSelection();
  if (selection.x <= widgetMarkOffset)
    fTextWidget.setSelection(selection.x, widgetMarkOffset);
  else
    fTextWidget.setSelection(widgetMarkOffset, selection.x);
  if (delete) {
    wrapCompoundChange(() -> fTextWidget.cut());
  } else {
    fTextWidget.copy();
    fTextWidget.setSelection(selection.x); // restore old cursor position
  }
}
origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text

/**
 * Similar to {@link #modelRange2WidgetRange(IRegion)}, but more forgiving:
 * if <code>modelRange</code> describes a region entirely hidden in the
 * image, then this method returns the zero-length region at the offset of
 * the folded region.
 *
 * @param modelRange the model range
 * @return the corresponding widget range, or <code>null</code>
 * @since 3.1
 */
protected IRegion modelRange2ClosestWidgetRange(IRegion modelRange) {
  if (!(fInformationMapping instanceof IDocumentInformationMappingExtension2))
    return modelRange2WidgetRange(modelRange);
  try {
    if (modelRange.getLength() < 0) {
      Region reversed= new Region(modelRange.getOffset() + modelRange.getLength(), -modelRange.getLength());
      IRegion result= ((IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(reversed);
      if (result != null)
        return new Region(result.getOffset() + result.getLength(), -result.getLength());
    }
    return ((IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(modelRange);
  } catch (BadLocationException x) {
  }
  return null;
}
origin: org.eclipse.platform/org.eclipse.jface.text

/**
 * Similar to {@link #modelRange2WidgetRange(IRegion)}, but more forgiving:
 * if <code>modelRange</code> describes a region entirely hidden in the
 * image, then this method returns the zero-length region at the offset of
 * the folded region.
 *
 * @param modelRange the model range
 * @return the corresponding widget range, or <code>null</code>
 * @since 3.1
 */
protected IRegion modelRange2ClosestWidgetRange(IRegion modelRange) {
  if (!(fInformationMapping instanceof IDocumentInformationMappingExtension2))
    return modelRange2WidgetRange(modelRange);
  try {
    if (modelRange.getLength() < 0) {
      Region reversed= new Region(modelRange.getOffset() + modelRange.getLength(), -modelRange.getLength());
      IRegion result= ((IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(reversed);
      if (result != null)
        return new Region(result.getOffset() + result.getLength(), -result.getLength());
    }
    return ((IDocumentInformationMappingExtension2) fInformationMapping).toClosestImageRegion(modelRange);
  } catch (BadLocationException x) {
  }
  return null;
}
org.eclipse.jface.textTextViewermodelRange2WidgetRange

Javadoc

Implements the contract of ITextViewerExtension5#modelRange2WidgetRange(IRegion).

Popular methods of TextViewer

  • getTextWidget
  • getControl
  • doOperation
  • setDocument
  • getRewriteTarget
  • getSelection
  • modelLine2WidgetLine
    Implements the contract of ITextViewerExtension5#modelLine2WidgetLine(int).
  • getDocument
  • setSelectedRange
  • setSelection
  • <init>
    Create a new text viewer with the given SWT style bits. The viewer is ready to use but does not have
  • canDoOperation
  • <init>,
  • canDoOperation,
  • getVisibleRegion,
  • handleDispose,
  • invalidateTextPresentation,
  • setTopIndex,
  • _getVisibleRegionOffset,
  • activatePlugins,
  • addPresentation

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • getExternalFilesDir (Context)
  • getContentResolver (Context)
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now