Package org.eclipse.jface.text.source

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


    List<Annotation> result = new ArrayList<Annotation>();
    Iterator<Annotation> it = model.getAnnotationIterator();
   
   
    while(it.hasNext()){
      Annotation ann = it.next();
     
      Position pos = model.getPosition(ann);
     
      try {
        if(document.getLineOfOffset(pos.offset) == lineNumber)
View Full Code Here


                    // if(errorPart instanceof LdifUnknownPart) {
                    // errorOffset = container.getOffset();
                    // errorLength = container.getLength();
                    // errorText = new StringBuffer(container.toString());
                    // }
                    Annotation annotation = new Annotation( ERROR_ANNOTATION_TYPE, true, errorText.toString() );
                    Position position = new Position( errorOffset, errorLength );
                    positionList.add( position );
                    viewer.getAnnotationModel().addAnnotation( annotation, position );
                }
View Full Code Here

                    int start = invalidFilters[i].getStartToken().getOffset();
                    int stop = invalidFilters[i].getStopToken() != null ? invalidFilters[i].getStopToken().getOffset()
                        + invalidFilters[i].getStopToken().getLength() : start
                        + invalidFilters[i].getStartToken().getLength();

                    Annotation annotation = new Annotation( "DEFAULT", true, invalidFilters[i].toString() );
                    Position position = new Position( start, stop - start );
                    positionList.add( position );
                    this.sourceViewer.getAnnotationModel().addAnnotation( annotation, position );
                }
            }

            for ( int i = 0; i < tokens.length; i++ )
            {
                if ( tokens[i].getType() == LdapFilterToken.ERROR )
                {

                    boolean overlaps = false;
                    for ( int k = 0; k < positionList.size(); k++ )
                    {
                        Position pos = ( Position ) positionList.get( k );
                        if ( pos.overlapsWith( tokens[i].getOffset(), tokens[i].getLength() ) )
                        {
                            overlaps = true;
                            break;
                        }
                    }
                    if ( !overlaps )
                    {
                        Annotation annotation = new Annotation( "DEFAULT", true, tokens[i].getValue() );
                        Position position = new Position( tokens[i].getOffset(), tokens[i].getLength() );
                        this.sourceViewer.getAnnotationModel().addAnnotation( annotation, position );
                    }
                }
            }
View Full Code Here

      highlight(0, 0); // TODO: only if removed annotation was selected

      IAnnotationModelExtension annotationModel = (IAnnotationModelExtension) getDocumentProvider().getAnnotationModel(getEditorInput());
     
      Annotation removeAnnotations[] = new Annotation[deletedAnnotations.size()];
      int removeAnnotationsIndex = 0;
      for (AnnotationFS annotation : deletedAnnotations) {
        removeAnnotations[removeAnnotationsIndex++] = new EclipseAnnotationPeer(annotation);
      }
     
View Full Code Here

    }

    List oldAnnotations = new ArrayList(2);
    Iterator annotationIterator = annotationModel.getAnnotationIterator();
    while (annotationIterator.hasNext()) {
      Annotation annotation = (Annotation) annotationIterator.next();
      if (ANNOTATION_TYPE.equals(annotation.getType())) {
        annotation.markDeleted(true);
        if (DEBUG) {
          System.out.println("removing " + annotation); //$NON-NLS-1$
        }
        oldAnnotations.add(annotation);
      }
    }

    Map newAnnotations = new HashMap();
    if (!selection.isEmpty() && selection instanceof IStructuredSelection && selection instanceof ITextSelection) {
      Object o = ((IStructuredSelection) selection).getFirstElement();
      if (o instanceof IDOMNode) {
        int offset = ((ITextSelection) selection).getOffset();
        IStructuredDocumentRegion matchRegion = null;
        if (((Node) o).getNodeType() == Node.ATTRIBUTE_NODE) {
          o = ((Attr) o).getOwnerElement();
        }

        Position pStart = null;
        Position pEnd = null;
        String tag = ""; //$NON-NLS-1$
        if (o instanceof IDOMNode) {
          IDOMNode node = (IDOMNode) o;
          IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
          if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) {
            if (startStructuredDocumentRegion.getNumberOfRegions() > 1) {
              ITextRegion nameRegion = startStructuredDocumentRegion.getRegions().get(1);
              pStart = new Position(startStructuredDocumentRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
              tag = startStructuredDocumentRegion.getText(nameRegion);
            }
            matchRegion = ((IDOMNode) o).getEndStructuredDocumentRegion();
            if (matchRegion != null && matchRegion.getNumberOfRegions() > 1) {
              ITextRegion nameRegion = matchRegion.getRegions().get(1);
              pEnd = new Position(matchRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
            }
          }
          else {
            IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion();
            if (endStructuredDocumentRegion != null && endStructuredDocumentRegion.containsOffset(offset)) {
              if (endStructuredDocumentRegion.getNumberOfRegions() > 1) {
                ITextRegion nameRegion = endStructuredDocumentRegion.getRegions().get(1);
                pEnd = new Position(endStructuredDocumentRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
                tag = endStructuredDocumentRegion.getText(nameRegion);
              }
              matchRegion = ((IDOMNode) o).getStartStructuredDocumentRegion();
              if (matchRegion != null && matchRegion.getNumberOfRegions() > 1) {
                ITextRegion nameRegion = matchRegion.getRegions().get(1);
                pStart = new Position(matchRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
              }
            }
          }
        }
        if (pStart != null && pEnd != null) {
          Annotation annotation = new Annotation(ANNOTATION_TYPE, false, NLS.bind(XMLUIMessages.gotoMatchingTag_start, tag));
          newAnnotations.put(annotation, pStart);
          if (DEBUG) {
            System.out.println("adding " + annotation); //$NON-NLS-1$
          }
          annotation = new Annotation(ANNOTATION_TYPE, false, NLS.bind(XMLUIMessages.gotoMatchingTag_end, tag));
          newAnnotations.put(annotation, pEnd);
          if (DEBUG) {
            System.out.println("adding " + annotation); //$NON-NLS-1$
          }
        }
View Full Code Here

   */
  private void setFocusPosition(Position position) throws BadLocationException {
    if (fMarkFocus && getPosition(fFocusAnnotation) != position) {
      removeAnnotation(fFocusAnnotation, false);
      if (position != null) {
        fFocusAnnotation= new Annotation(FOCUS_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
        addAnnotation(fFocusAnnotation, position, false);
      } else
        fFocusAnnotation= null;
    }
  }
View Full Code Here

   */
  private void setExitPosition(Position position) throws BadLocationException {
    if (fMarkExitTarget && getPosition(fExitAnnotation) != position) {
      removeAnnotation(fExitAnnotation, false);
      if (position != null) {
        fExitAnnotation= new Annotation(EXIT_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
        addAnnotation(fExitAnnotation, position, false);
      } else
        fExitAnnotation= null;
    }
  }
View Full Code Here

      for (Iterator iter= positions.iterator(); iter.hasNext();) {
        Position p= (Position) iter.next();
        if (fGroupAnnotations.containsKey(p)) {
          toRemove.remove(fGroupAnnotations.get(p));
        } else {
          Annotation a= new Annotation(SLAVE_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
          toAdd.put(a, p);
          fGroupAnnotations.put(p, a);
        }
      }
    }
View Full Code Here

      for (Iterator iter= positions.iterator(); iter.hasNext();) {
        Position p= (Position) iter.next();
        if (fTargetAnnotations.containsKey(p)) {
          toRemove.remove(fTargetAnnotations.get(p));
        } else {
          Annotation a= new Annotation(TARGET_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
          toAdd.put(a, p);
          fTargetAnnotations.put(p, a);
        }
      }
    }
View Full Code Here

      bags= new ArrayList();
    }

    Iterator e= fAnnotationModel.getAnnotationIterator();
    while (e.hasNext()) {
      Annotation annotation= (Annotation) e.next();
      if (annotation instanceof AnnotationBag) {
        if (bags == null)
          fAnnotationModel.removeAnnotation(annotation);
        else
          bags.add(annotation);
View Full Code Here

TOP

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

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.