Package org.eclipse.jface.text.source

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


                    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() ); //$NON-NLS-1$
                    Position position = new Position( start, stop - start );
                    positionList.add( position );
                    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 = 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() ); //$NON-NLS-1$
                        Position position = new Position( tokens[i].getOffset(), tokens[i].getLength() );
                        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

  /*
   * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent)
   */
  public void annotationDefaultSelected(VerticalRulerEvent event) {
    Annotation a= event.getSelectedAnnotation();
    IAnnotationModel model= getAnnotationModel();
    Position position= model.getPosition(a);
    if (position == null)
      return;

View Full Code Here

    annotModel.addAnnotationModelListener(this);
    resource = r;
   
    for (Iterator i = annotModel.getAnnotationIterator(); i.hasNext(); )
      {
      Annotation current = (Annotation)i.next();
      if (!annotationSupported(current)) continue;
      if (current.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
        annotations.put(current,buildXCDEAnnotation(annotModel.getPosition(current).offset,
                              annotModel.getPosition(current).length,
                              buildBookmarkDetails((MarkerAnnotation)current)));
      else if (current.getType().equals("org.eclipse.ui.workbench.texteditor.task"))
        annotations.put(current,buildXCDEAnnotation(annotModel.getPosition(current).offset,
                              annotModel.getPosition(current).length,
                              buildTaskDetails((MarkerAnnotation)current)));
      }
    }
View Full Code Here

   */
  private Annotation findAnnotation(String type, int offset, int length, String text)
    {
    for (Iterator i = annotModel.getAnnotationIterator(); i.hasNext(); )
      {
      Annotation current = (Annotation)i.next();
      if (!annotationSupported(current)) continue;
      try
        {
        if (current.getType().equals(type) &&
          annotModel.getPosition(current).offset == offset &&
          annotModel.getPosition(current).length == length &&
          ((MarkerAnnotation)current).getMarker().getAttribute(IMarker.MESSAGE).equals(text))
          {
          return current;
View Full Code Here

      found.add(i.next());
   
    //process all the annotations currently attached to the model
    for (Iterator i = annotModel.getAnnotationIterator(); i.hasNext(); )
      {
      Annotation current = (Annotation)i.next();

      //if we have a type we are not interested in, we will skip it
      if (!annotationSupported(current))
        continue;
     
      if (!annotations.containsKey(current))
        {
        //new annotaiton
        MarkerAnnotation toAdd = (MarkerAnnotation)current;
        if (toAdd.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
          {
          XCDEBookmarkDetails details = buildBookmarkDetails(toAdd);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          annotations.put(current,a);
          makeChange(new XCDEDocumentAnnotationStimulusAdd(parentRegister.getUsername(),a));
          }
        else if (toAdd.getType().equals("org.eclipse.ui.workbench.texteditor.task"))
          {
          XCDETaskDetails details = buildTaskDetails(toAdd);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          annotations.put(current,a);
          makeChange(new XCDEDocumentAnnotationStimulusAdd(parentRegister.getUsername(),a));
         
        }
      else
        {
        //changed
        MarkerAnnotation toChange = (MarkerAnnotation)current;
        if (toChange.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
          {
          XCDEBookmarkDetails details = buildBookmarkDetails(toChange);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          if (!((XCDEDocumentAnnotation)annotations.get(current)).details.equals(details))
            {
            makeChange(new XCDEDocumentAnnotationStimulusChange(parentRegister.getUsername(),
                  (XCDEDocumentAnnotation)annotations.get(current),a));
            }
          annotations.put(current,a);
          }
        else if (toChange.getType().equals("org.eclipse.ui.workbench.texteditor.task"))
          {
          XCDETaskDetails details = buildTaskDetails(toChange);
          XCDEDocumentAnnotation a = buildXCDEAnnotation(annotModel.getPosition(current).offset, annotModel.getPosition(current).length, details);
          if (!((XCDEDocumentAnnotation)annotations.get(current)).details.equals(details))
            {
            makeChange(new XCDEDocumentAnnotationStimulusChange(parentRegister.getUsername(),
                  (XCDEDocumentAnnotation)annotations.get(current),a));
            }
          annotations.put(current,a);
          }
        found.remove(current);
        }
      }
   
    for (Iterator i = found.iterator(); i.hasNext(); )
      {
      Annotation current = (Annotation)i.next();
      // This check should be unnecessary, because we only store MarkerAnnotations in the annotations map.
      //if (!(current instanceof MarkerAnnotation))
      //  continue;
      MarkerAnnotation toDelete = (MarkerAnnotation)current;
      if (toDelete.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
View Full Code Here

    String text = "";
    if (a.details instanceof XCDEBookmarkDetails)
      text = ((XCDEBookmarkDetails)a.details).text;
    else if (a.details instanceof XCDETaskDetails)
      text = ((XCDETaskDetails)a.details).text;
    Annotation toRemove = findAnnotation(type,offset,length,text);
    if (toRemove != null)
      {
      // This check is unnecessary, because we only return MarkerAnnotations from findAnnotation().
      //if (toRemove instanceof MarkerAnnotation)
        //{
View Full Code Here

  private void updateAnnotations(XCDEDocChange ch)
    {
    annotModel.removeAnnotationModelListener(this);
    for (Iterator i = annotModel.getAnnotationIterator(); i.hasNext(); )
      {
      Annotation a = (Annotation)i.next();
      if (!annotationSupported(a))
        continue;
      annotations.remove(a);
      XCDEDocumentSelection newSel = new XCDEDocumentSelection(annotModel.getPosition(a).offset, annotModel.getPosition(a).length);
      //We do not update the annotation model because that updates itself, it
      //is the marker attributes that don't get updated that we care about
      IMarker marker = ((MarkerAnnotation)a).getMarker();
      try
        {
        marker.setAttribute(IMarker.CHAR_START, newSel.pos);
        marker.setAttribute(IMarker.CHAR_END, newSel.pos + newSel.length);
        marker.setAttribute(IMarker.LINE_NUMBER, document.getLineOfOffset(newSel.pos)+1);
        }
      catch (Exception e)
        {
        throw new RuntimeException(e);
        }
      if (a.getType().equals("org.eclipse.ui.workbench.texteditor.bookmark"))
        annotations.put(a,buildXCDEAnnotation(newSel.pos,newSel.length,buildBookmarkDetails((MarkerAnnotation)a)));
      else
        annotations.put(a,buildXCDEAnnotation(newSel.pos,newSel.length,buildTaskDetails((MarkerAnnotation)a)));
      }
    annotModel.addAnnotationModelListener(this);
View Full Code Here

  private List computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) {
    int offset= context.getOffset();
    ArrayList annotationList= new ArrayList();
    Iterator iter= model.getAnnotationIterator();
    while (iter.hasNext()) {
      Annotation annotation= (Annotation)iter.next();
      if (canFix(annotation)) {
        Position pos= model.getPosition(annotation);
        if (isAtPosition(offset, pos)) {
          collectSpellingProblems(annotation, pos, annotationList);
        }
View Full Code Here

   * @since 3.2
   */
  public Annotation gotoAnnotation(boolean forward) {
    ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
    Position position= new Position(0, 0);
    Annotation annotation= findAnnotation(selection.getOffset(), selection.getLength(), forward, position);
    setStatusLineErrorMessage(null);
    setStatusLineMessage(null);
   
    if (annotation != null) {
      selectAndReveal(position.getOffset(), position.getLength());
      setStatusLineMessage(annotation.getText());
    }
    return 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.