Package org.eclipse.jface.text

Examples of org.eclipse.jface.text.TextPresentation


        // The HTML2TextReader does not render <p> like a browser.
        // Instead of inserting an empty line, it just adds a single line break.
        // Furthermore, the indentation of <dl><dd> elements is too small (e.g
        // with a long @see line)
        final TextPresentation presentation = new TextPresentation();
        final HTML2TextReader reader = new HTML2TextReader(new StringReader(
                fInput.getHtml()), presentation);
        String text;
        try {
            try {
                text = reader.getString();
            } catch (final IOException e) {
                text = ""; //$NON-NLS-1$
            }
        } finally {
            try {
                reader.close();
            } catch (final IOException e) {
            }
        }

        fTextLayout.setText(text);
        fTextLayout.setWidth(sizeConstraints == null ? SWT.DEFAULT : sizeConstraints.x
                - trim.width);
        @SuppressWarnings("rawtypes")
        final Iterator iter = presentation.getAllStyleRangeIterator();
        while (iter.hasNext()) {
            final StyleRange sr = (StyleRange) iter.next();
            if (sr.fontStyle == SWT.BOLD) {
                fTextLayout.setStyle(fBoldStyle, sr.start, sr.start + sr.length - 1);
            }
View Full Code Here


    return result;
  }

  private void applyDiffPresentation(SourceViewer oldViewer, SourceViewer newViewer,
      UpdatableScript.TextualDiff textualDiff) {
    TextPresentation oldPresentation = new TextPresentation();
    TextPresentation newPresentation = new TextPresentation();

    List<Long> chunkNumbers = textualDiff.getChunks();
    int posOld = 0;
    int posNew = 0;
    for (int i = 0; i < chunkNumbers.size(); i += 3) {
      int startOld = chunkNumbers.get(i + 0).intValue();
      int endOld = chunkNumbers.get(i + 1).intValue();
      int endNew = chunkNumbers.get(i + 2).intValue();
      int startNew = startOld - posOld + posNew;

      if (startOld == endOld) {
        // Add
        newPresentation.addStyleRange(new StyleRange(startNew, endNew - startNew,
            null, colors.get(ColorName.ADDED_BACKGROUND)));
      } else if (startNew == endNew) {
        // Remove
        oldPresentation.addStyleRange(new StyleRange(startOld, endOld - startOld,
            null, colors.get(ColorName.ADDED_BACKGROUND)));
      } else {
        // Replace
        newPresentation.addStyleRange(new StyleRange(startNew, endNew - startNew,
            null, colors.get(ColorName.CHANGED_BACKGROUND)));
        oldPresentation.addStyleRange(new StyleRange(startOld, endOld - startOld,
            null, colors.get(ColorName.CHANGED_BACKGROUND)));
      }
View Full Code Here

        IFile activeFile = hFile.getRealFile();
        HaxeProject project = Activator.getProjectManager().getCurrentHaxeProject();
        CodeFile currFile = project.getFile(activeFile);
        String currPack = currFile.getPackage();
       
        TextPresentation presentation = new TextPresentation();
       
        for (NodeLink info : usagesList.get(currPack))
        {
            HaxeTree node = info.getNode();
            int offset = node.getMostLeftPosition();
            int end = node.getMostRightPosition();

            Display display = Display.getDefault();
            StyleRange styleRange = new StyleRange(           
                    offset, end - offset + 1,
                    display.getSystemColor(SWT.COLOR_WHITE),
                    display.getSystemColor(SWT.COLOR_BLUE),
                    SWT.NORMAL);

            // Negative (possibly 0) length style ranges will cause an
            // IllegalArgumentException in changeTextPresentation(..)
            if (styleRange.length > 0 )
            {
                presentation.addStyleRange(styleRange);
            }
        }
        if (!presentation.isEmpty() && view.isEditable())
        {
            view.changeTextPresentation(presentation, true);
        }
    }
View Full Code Here

  protected TextPresentation createPresentation(IRegion damage, IDocument document) {
    try {
      int validLength = Math.min(damage.getLength(), document.getLength() - damage.getOffset());
     
      if (fRepairers == null || fRepairers.isEmpty()) {
        TextPresentation presentation= new TextPresentation(damage, 1);
        presentation.setDefaultStyleRange(new StyleRange(damage.getOffset(), validLength, null, null));
        return presentation;
      }

      TextPresentation presentation= new TextPresentation(damage, 1000);

      ITypedRegion[] partitions= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), validLength, false);
      for (int i= 0; i < partitions.length; i++) {
        ITypedRegion r= partitions[i];
        IPresentationRepairer repairer= getRepairer(r.getType());
View Full Code Here

   * @param damage the damage to be repaired
   * @param document the document whose presentation must be repaired
   */
  void processDamage(IRegion damage, IDocument document) {
    if (damage != null && damage.getLength() > 0) {
      TextPresentation p = createPresentation(damage, document);
      if (p != null) {
        /**
         * 229749 - Read-Only highlighting support missing
         * 272981 - Read-only highlighting moved to semantic highlighting
         */
 
View Full Code Here

          if (current != null)
            newPositions.add(current);
        }
        fRemovedPositions = newPositions;
       
        TextPresentation presentation = null;
        if (!fJobPresenter.isCanceled())
          presentation = fJobPresenter.createPresentation(fAddedPositions, fRemovedPositions);
        if (!fJobPresenter.isCanceled())
          updatePresentation(presentation, fAddedPositions, fRemovedPositions);
      }
View Full Code Here

        if (!_jobPresenter.isCanceled()) {
            _reconcilePositions(subtrees);
        }

        TextPresentation textPresentation = null;

        if (!_jobPresenter.isCanceled()) {
            textPresentation = _jobPresenter.createPresentation(
                    _addedPositions, _removedPositions);
        }
View Full Code Here

   *         <code>null</code> if the partitioning could not be computed
   */
  protected TextPresentation createPresentation(IRegion damage, IDocument document) {
    try {
      if (fRepairers == null || fRepairers.isEmpty()) {
        TextPresentation presentation= new TextPresentation(damage, 100);
        presentation.setDefaultStyleRange(new StyleRange(damage.getOffset(), damage.getLength(), null, null));
        return presentation;
      }

      TextPresentation presentation= new TextPresentation(damage, 1000);

      ITypedRegion[] partitioning= TextUtilities.computePartitioning(document, getDocumentPartitioning(), damage.getOffset(), damage.getLength(), false);
      for (int i= 0; i < partitioning.length; i++) {
        ITypedRegion r= partitioning[i];
        IPresentationRepairer repairer= getRepairer(r.getType());
View Full Code Here

   * @param damage the damage to be repaired
   * @param document the document whose presentation must be repaired
   */
  private void processDamage(IRegion damage, IDocument document) {
    if (damage != null && damage.getLength() > 0) {
      TextPresentation p= createPresentation(damage, document);
      if (p != null)
        applyTextRegionCollection(p);
    }
  }
View Full Code Here

    fContentAssistSubjectControlAdapter.installValidator(frame);

    if (frame.fPresenter != null) {
      if (fTextPresentation == null)
        fTextPresentation= new TextPresentation();
      fContentAssistSubjectControlAdapter.installContextInformationPresenter(frame);
      frame.fPresenter.updatePresentation(frame.fOffset, fTextPresentation);
    }

    createContextInfoPopup();
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.TextPresentation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.