Package org.eclipse.jface.text.source

Examples of org.eclipse.jface.text.source.IAnnotationModel


        if (!(viewer instanceof ISourceViewer)) {
            return;
        }

        IAnnotationModel model = ((ISourceViewer) viewer).getAnnotationModel();

        for (Iterator<Annotation> it = model.getAnnotationIterator(); it
            .hasNext();) {
            Annotation annotation = it.next();
            if (annotation instanceof ViewportAnnotation) {
                if (((ViewportAnnotation) annotation).getSource()
                    .equals(source))
                    model.removeAnnotation(annotation);
            }
        }

        IDocument document = viewer.getDocument();
        try {
            int lines = document.getNumberOfLines();
            top = Math.max(0, Math.min(lines - 1, top));
            bottom = Math.max(0, Math.min(lines - 1, bottom));

            int start = document.getLineOffset(top);
            if (start == -1)
                throw new BadLocationException("Start line -1");
            int end = document.getLineOffset(bottom);
            if (end == -1 || end < start)
                throw new BadLocationException("End line -1 or less than start");
            SarosAnnotation annotation = new ViewportAnnotation(source);
            Position position = new Position(start, end - start);
            model.addAnnotation(annotation, position);
        } catch (BadLocationException e) {
            log.warn("Internal Error:", e);
        }
    }
View Full Code Here


  /**
   * Remove ALL temporary annotations that this strategy can handle.
   */
  protected TemporaryAnnotation[] getAllAnnotationsToRemove() {
    List removals = new ArrayList();
    IAnnotationModel annotationModel = getAnnotationModel();
    if (annotationModel != null) {
      Iterator i = annotationModel.getAnnotationIterator();
      while (i.hasNext()) {
        Object obj = i.next();
        if (!(obj instanceof ITemporaryAnnotation))
          continue;

View Full Code Here

    }
    return (TemporaryAnnotation[]) removals.toArray(new TemporaryAnnotation[removals.size()]);
  }

  protected IAnnotationModel getAnnotationModel() {
    IAnnotationModel model = null;
    if (fSourceViewer != null) {
      model = fSourceViewer.getAnnotationModel();
    }
    return model;
  }
View Full Code Here

  }

  protected TemporaryAnnotation[] getAnnotationsToRemove(DirtyRegion dr, List stepsRun) {

    List remove = new ArrayList();
    IAnnotationModel annotationModel = getAnnotationModel();
    // can be null when closing the editor
    if (getAnnotationModel() != null) {

      // clear validator annotations
      getMarkerAnnotations().clear();

      Iterator i = annotationModel.getAnnotationIterator();
      while (i.hasNext()) {

        Object obj = i.next();

        // check if it's a validator marker annotation
View Full Code Here

    // it's reconfigured later
  }

  private void removeAnnotations(TemporaryAnnotation[] annotationsToRemove) {

    IAnnotationModel annotationModel = getAnnotationModel();
    // can be null when closing the editor
    if (annotationModel != null) {
      for (int i = 0; i < annotationsToRemove.length; i++) {
        if (isCanceled()) {
          if (DEBUG)
            System.out.println("[trace reconciler] >** REMOVAL WAS CANCELLED **"); //$NON-NLS-1$
          return;
        }
        StructuredMarkerAnnotation sma = getCorrespondingMarkerAnnotation(annotationsToRemove[i]);
        if (sma != null) {
          // gray out the marker annotation
          sma.setGrayed(true);
        }
        // remove the temp one
        annotationModel.removeAnnotation(annotationsToRemove[i]);

      }
    }

    if (DEBUG) {
View Full Code Here

   * IExtendedStorageEditorInput notifications and assigning breakpoint
   * markers.
   */
  class StorageInputDocumentProvider extends StorageDocumentProvider implements IElementStateListener {
    protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
      IAnnotationModel model = null;
      IStorageEditorInput storageInput = (IStorageEditorInput) element;
      String ext = BreakpointRulerAction.getFileExtension(storageInput);
      IContentType[] types = getEditorInputContentTypes(storageInput);
      IResource res = null;
      for (int i = 0; res == null && i < types.length; i++) {
View Full Code Here

              value = "TOTAL"; //$NON-NLS-1$
            }
          }
        }
        else if (TEMPORARY_ANNOTATION_KEYS[3].equals(id)) {
          IAnnotationModel annotationModel = fTextEditor.getDocumentProvider().getAnnotationModel(fTextEditor.getEditorInput());
          Position p = annotationModel.getPosition(fAnnotation);
          if (p != null) {
            value = String.valueOf(p.getOffset());
          }
        }
        else if (TEMPORARY_ANNOTATION_KEYS[4].equals(id)) {
          IAnnotationModel annotationModel = fTextEditor.getDocumentProvider().getAnnotationModel(fTextEditor.getEditorInput());
          Position p = annotationModel.getPosition(fAnnotation);
          if (p != null) {
            value = String.valueOf(p.getLength());
          }
        }
        else if (TEMPORARY_ANNOTATION_KEYS[5].equals(id)) {
View Full Code Here

      return null;
    return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
  }

  public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
    IAnnotationModel model = ((SourceViewer) viewer).getAnnotationModel();
    if (model != null) {
      List messages = new ArrayList();
      Iterator e = model.getAnnotationIterator();
      while (e.hasNext()) {
        Annotation a = (Annotation) e.next();
        if (!isAnnotationValid(a))
          continue;

        Position p = model.getPosition(a);
        // check if this is an annotation in the region we are
        // concerned with
        if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
          String msg = a.getText();
          if ((msg != null) && msg.trim().length() > 0) {
View Full Code Here

   *
   * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer,
   *      int)
   */
  public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
    IAnnotationModel model = ((SourceViewer) textViewer).getAnnotationModel();
    Region hoverRegion = null;

    if (model != null) {
      Iterator e = model.getAnnotationIterator();
      while (e.hasNext()) {
        Annotation a = (Annotation) e.next();
        if (!isAnnotationValid(a))
          continue;
        Position p = model.getPosition(a);
        if (p != null && p.includes(offset)) {
          // find the smallest region containing offset
          if ((hoverRegion == null) || (hoverRegion.getLength() > p.getLength())) {
            hoverRegion = new Region(p.getOffset(), p.getLength());
          }
View Full Code Here

  /*
   * @see org.eclipse.core.filebuffers.IAnnotationModelFactory#createAnnotationModel(org.eclipse.core.runtime.IPath)
   */
  public IAnnotationModel createAnnotationModel(IPath location) {
    IAnnotationModel model = null;
    IFile file = FileBuffers.getWorkspaceFileAtLocation(location);
    if (file != null) {
      model = new StructuredResourceMarkerAnnotationModel(file);
    }
    else {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.text.source.IAnnotationModel

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.