Ejemplo n.º 1
0
  protected void adaptTextPresentation(
      final TextPresentation presentation, final int offset, final int insertLength) {

    int yoursStart = offset;
    int yoursEnd = offset + insertLength - 1;
    yoursEnd = Math.max(yoursStart, yoursEnd);

    @SuppressWarnings("rawtypes")
    Iterator e = presentation.getAllStyleRangeIterator();
    while (e.hasNext()) {

      StyleRange range = (StyleRange) e.next();

      int myStart = range.start;
      int myEnd = range.start + range.length - 1;
      myEnd = Math.max(myStart, myEnd);

      if (myEnd < yoursStart) {
        continue;
      }

      if (myStart < yoursStart) {
        range.length += insertLength;
      } else {
        range.start += insertLength;
      }
    }
  }
Ejemplo n.º 2
0
  /**
   * Extended to remove any style ranges that overlap with an embedded editor.
   *
   * <p>We don't want to change style ranges over the region where there is a contained editor,
   * because thet will remove the GlyphMetrics that we created earlier
   */
  public void applyTextPresentation(TextPresentation textPresentation) {
    // need to check if any of the ranges of the textPresentation overlaps
    // with an embedded editor region.

    // for now, we can assume that there won't be many store positions, so we can
    // just go through them sequentially.
    // if this turns out to be expensive, we can be more intelligent later
    Collection<Position> values = editorPositionMap.values();
    for (Iterator<StyleRange> rangeIter = textPresentation.getAllStyleRangeIterator();
        rangeIter.hasNext(); ) {
      StyleRange range = rangeIter.next();
      Position overlapPosition = null;
      for (final Position editorPosition : values) {
        if (editorPosition.overlapsWith(range.start, range.length)) {
          overlapPosition = editorPosition;
          break;
        }
      }

      if (overlapPosition != null) {
        textPresentation.replaceStyleRanges(
            createStyleRange(getEditor(overlapPosition), overlapPosition));
      }
    }
  }
Ejemplo n.º 3
0
 public static StyleRange[] getStyles(final TextPresentation presentation) {
   final StyleRange[] ranges = new StyleRange[presentation.getDenumerableRanges()];
   final Iterator<?> e = presentation.getAllStyleRangeIterator();
   for (int i = 0; e.hasNext(); i++) {
     ranges[i] = (StyleRange) e.next();
   }
   return ranges;
 }