Package org.eclipse.jface.text.source

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


  private void syncAnnotations() {
   
    removeAllAnnotations();
   
    // Remove all annotation from the model
    IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput());
    ((IAnnotationModelExtension) annotationModel).removeAllAnnotations();
   
    // Add all annotation to the model
    // copy annotations into annotation model
    final Iterator<AnnotationFS> mAnnotations = getDocument().getCAS().getAnnotationIndex()
View Full Code Here


  @Override
  protected IAnnotationModel createAnnotationModel(Object element)
      throws CoreException {
    if (element instanceof  MethodEditorInput) {
      MethodEditorInput input = (MethodEditorInput) element;
      IAnnotationModel model =  new ResourceMarkerAnnotationModel(input.getFile());
      input.setAnnotationModel(model);
      return model;
        }

        return null;
View Full Code Here

        SearchPattern.R_EXACT_MATCH);

    SearchRequestor requestor = new SearchRequestor() {
      @Override
      public void acceptSearchMatch(final SearchMatch match) {
        IAnnotationModel model = textEditor.getDocumentProvider().getAnnotationModel(textEditor.getEditorInput());
        Annotation annotation = new Annotation("org.eclipse.jdt.ui.occurrences", false, "wicket id constant");
        model.addAnnotation(annotation, new Position(match.getOffset(), match.getLength()));
      }
    };

    SearchEngine searchEngine = new SearchEngine();
    try {
View Full Code Here

    if (docProvider == null) {
      return;
    }

    IAnnotationModel model = docProvider.getAnnotationModel(fEditor
        .getEditorInput());

    if (model == null)
      return;

    if (model instanceof IAnnotationModelExtension) {
      IAnnotationModelExtension modelExt = (IAnnotationModelExtension) model;
      Annotation[] oldAnnotations = fAnnotations
          .toArray(new Annotation[fAnnotations.size()]);

      modelExt.replaceAnnotations(oldAnnotations, Collections.EMPTY_MAP);
    } else {
      for (Iterator i = model.getAnnotationIterator(); i.hasNext();) {
        Annotation a = (Annotation) i.next();

        if (a.getType().equals(fAnnotationType)) {
          model.removeAnnotation(a);
        }
      }
    }
    // System.out.println("Annotations removed.");
    fAnnotations.clear();
View Full Code Here

  /**
   * End messages.
   */
  public void endMessages() {
    IAnnotationModel model = fEditor.getDocumentProvider()
        .getAnnotationModel(fEditor.getEditorInput());
    if (model instanceof IAnnotationModelExtension) {
      IAnnotationModelExtension modelExt = (IAnnotationModelExtension) model;
      Annotation[] oldAnnotations = fAnnotations
          .toArray(new Annotation[fAnnotations.size()]);
      Map<Annotation, Position> newAnnotations = new HashMap<Annotation, Position>(
          fMessages.size());
      for (PositionedMessage pm : fMessages) {
        Annotation anno = new Annotation(fAnnotationType, false,
            pm.message);
        newAnnotations.put(anno, pm.pos);
        fAnnotations.add(anno);
      }
      modelExt.replaceAnnotations(oldAnnotations, newAnnotations);
    } else {
      for (Iterator i = model.getAnnotationIterator(); i.hasNext();) {
        Annotation a = (Annotation) i.next();

        if (a.getType().equals(fAnnotationType)) {
          model.removeAnnotation(a);
        }
      }
      for (PositionedMessage pm : fMessages) {
        Annotation annotation = new Annotation(fAnnotationType, false,
            pm.message);

        model.addAnnotation(annotation, pm.pos);
        fAnnotations.add(annotation);
      }
    }
    // System.out.println("Annotation model updated.");
    fMessages.clear();
View Full Code Here

         * TODO Investigate if this is really needed here
         */
        {
            IEditorInput input = changedEditor.getEditorInput();
            IDocumentProvider provider = getDocumentProvider(input);
            IAnnotationModel model = provider.getAnnotationModel(input);
            contributionAnnotationManager.splitAnnotation(model, offset);
        }
    }
View Full Code Here

            for (IEditorPart editorPart : editorPool.getEditors(path)) {

                if (editorPart instanceof ITextEditor) {
                    ITextEditor textEditor = (ITextEditor) editorPart;
                    IAnnotationModel model = textEditor.getDocumentProvider()
                        .getAnnotationModel(textEditor.getEditorInput());
                    contributionAnnotationManager.insertAnnotation(model,
                        offset, text.length(), source);
                }
            }
            IAnnotationModel model = provider.getAnnotationModel(input);
            contributionAnnotationManager.insertAnnotation(model, offset,
                text.length(), source);
        } finally {
            provider.disconnect(input);
        }
View Full Code Here

        try {
            IDocument doc = provider.getDocument(input);

            // TODO Why do we need to connect to the annotation model here?
            IAnnotationModel model = provider.getAnnotationModel(input);
            if (model != null)
                model.connect(doc);

            log.trace("EditorManager.saveText Annotations on the IDocument "
                + "are set");

            // dirtyStateListener.enabled = false;

            /*
             * BlockingProgressMonitor monitor = new BlockingProgressMonitor();
             *
             * try { provider.saveDocument(monitor, input, doc, true);
             * log.debug("Saved document: " + path); } catch (CoreException e) {
             * log.error("Failed to save document: " + path, e); }
             *
             * // Wait for saving to be done try { if (!monitor.await(10)) {
             * log.warn("Timeout expired on saving document: " + path); } }
             * catch (InterruptedException e) {
             * log.error("Code not designed to be interruptable", e);
             * Thread.currentThread().interrupt(); }
             *
             * if (monitor.isCanceled()) {
             * log.warn("Saving was canceled by buddy: " + path); }
             */
            // dirtyStateListener.enabled = true;

            if (model != null)
                model.disconnect(doc);

            log.trace("EditorManager.saveText File " + file.getName()
                + " will be reseted");

        } finally {
View Full Code Here

    @SuppressWarnings("unchecked")
    protected void removeAllAnnotations(IEditorPart editor,
        Predicate<SarosAnnotation> predicate) {
        IEditorInput input = editor.getEditorInput();
        IDocumentProvider provider = getDocumentProvider(input);
        IAnnotationModel model = provider.getAnnotationModel(input);

        if (model == null) {
            return;
        }

        // Collect annotations.
        ArrayList<Annotation> annotations = new ArrayList<Annotation>(128);
        for (Iterator<Annotation> it = model.getAnnotationIterator(); it
            .hasNext();) {
            Annotation annotation = it.next();

            if (annotation instanceof SarosAnnotation) {
                SarosAnnotation sarosAnnontation = (SarosAnnotation) annotation;
                if (predicate.evaluate(sarosAnnontation)) {
                    annotations.add(annotation);
                }
            }
        }

        // Remove collected annotations.
        if (model instanceof IAnnotationModelExtension) {
            IAnnotationModelExtension extension = (IAnnotationModelExtension) model;
            extension.replaceAnnotations(
                annotations.toArray(new Annotation[annotations.size()]),
                Collections.emptyMap());
        } else {
            if (!errorPrinted) {
                log.error("AnnotationModel does not "
                    + "support IAnnoationModelExtension: " + model);
                errorPrinted = true;
            }
            for (Annotation annotation : annotations) {
                model.removeAnnotation(annotation);
            }
        }
    }
View Full Code Here

        IDocumentProvider docProvider = textEditor.getDocumentProvider();

        if (docProvider != null) {
            IEditorInput input = textEditor.getEditorInput();
            IAnnotationModel model = docProvider.getAnnotationModel(input);

            if (model == null) {
                return;
            }
            if (selection.isEmpty()) {
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.