Package org.eclipse.jface.text.source

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


        // 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);
View Full Code Here


        if (length > 0) {
            /* Return early if there already is an annotation at that offset */
            for (Iterator<Annotation> it = model.getAnnotationIterator(); it
                .hasNext();) {
                Annotation annotation = it.next();

                if (annotation instanceof ContributionAnnotation
                    && model.getPosition(annotation).includes(offset)
                    && ((ContributionAnnotation) annotation).getSource()
                        .equals(source)) {
View Full Code Here

    @SuppressWarnings("unchecked")
    public void splitAnnotation(IAnnotationModel model, int offset) {
        for (Iterator<Annotation> it = model.getAnnotationIterator(); it
            .hasNext();) {
            Annotation annotation = it.next();

            if (annotation instanceof ContributionAnnotation) {

                Position pos = model.getPosition(annotation);
View Full Code Here

        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);
            }
View Full Code Here

      }
    }
  }
 
  public Annotation gotoAnnotation(boolean forward) {
    Annotation result = super.gotoAnnotation(forward);
    if(result != null)
      fSelectionChangedFromGoto = true;
    return result;
  }
View Full Code Here

    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) {
            // it is possible for temporary annotations to
            // duplicate other annotations so make sure not to add
            // dups
            if (a instanceof ITemporaryAnnotation) {
View Full Code Here

    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
View Full Code Here

  }

  protected void addQuickFixProposals(StructuredTextViewer viewer, ArrayList proposals, int documentOffset) {
    Iterator iter = fAnnotationModel.getAnnotationIterator();
    while (iter.hasNext()) {
      Annotation annotation = (Annotation) iter.next();
      Position pos = fAnnotationModel.getPosition(annotation);
      if (pos != null && documentOffset >= pos.offset && documentOffset <= pos.offset + pos.length) {
        IQuickFixProcessor processor = getQuickFixProcessor();
        if (processor != null && processor.canFix(annotation)) {
          try {
View Full Code Here

      annotationsComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

      final TableViewer annotationsTable = new TableViewer(annotationsComposite, SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
      annotationsTable.setComparator(new ViewerComparator(new Comparator() {
        public int compare(Object o1, Object o2) {
          Annotation annotation1 = (Annotation) o1;
          Annotation annotation2 = (Annotation) o2;
          String line1 = getLineNumber(annotation1);
          String line2 = getLineNumber(annotation2);
          return Integer.parseInt(line1) - Integer.parseInt(line2);
        }
      }));
      annotationsTable.setContentProvider(new ArrayContentProvider());
      annotationsTable.getTable().setHeaderVisible(true);
      annotationsTable.getTable().setLinesVisible(true);
      String[] columns = new String[]{"Line", "Owner", "Type", "Class", "Message"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
      annotationsTable.setLabelProvider(new ITableLabelProvider() {
        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public Image getColumnImage(Object element, int columnIndex) {
          return null;
        }

        public String getColumnText(Object element, int columnIndex) {
          Annotation annotation = (Annotation) element;
          String text = null;
          switch (columnIndex) {
            case 0 :
              text = getLineNumber(annotation);
              break;
            case 1 :
              text = getOwner(annotation);
              break;
            case 2 :
              text = getType(annotation); //$NON-NLS-1$
              break;
            case 3 :
              text = annotation.getClass().getName();
              break;
            case 4 :
              text = annotation.getText();
              break;
          }
          if (text == null)
            text = ""; //$NON-NLS-1$
          return text;
        }


        private String getOwner(Annotation annotation) {
          String owner = null;
          if (annotation instanceof MarkerAnnotation) {
            owner = ((MarkerAnnotation) annotation).getMarker().getAttribute("owner", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$       
          }
          else if (annotation instanceof TemporaryAnnotation) {
            Object key = ((TemporaryAnnotation) annotation).getKey();
            if (key != null) {
              if (key instanceof ReconcileAnnotationKey) {
                key = key.getClass().getName();
              }
              if (key != null)
                owner = key.toString();
            }
          }
          return owner;
        }

        private String getType(Annotation annotation) {
          String type = null;
          if (annotation instanceof MarkerAnnotation) {
            type = "M:"+MarkerUtilities.getMarkerType(((MarkerAnnotation) annotation).getMarker()); //$NON-NLS-1$
          }
          else {
            type = "A:"+annotation.getType(); //$NON-NLS-1$
          }
          if (type == null)
            type = ""; //$NON-NLS-1$
          return type;
        }

        public boolean isLabelProperty(Object element, String property) {
          return true;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
      });

      TableLayout tlayout = new TableLayout();
      CellEditor[] cellEditors = new CellEditor[columns.length];
      int columnWidths[] = new int[]{Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 7, Display.getCurrent().getBounds().width / 7, Display.getCurrent().getBounds().width / 14, Display.getCurrent().getBounds().width / 7};
      for (int i = 0; i < columns.length; i++) {
        tlayout.addColumnData(new ColumnWeightData(1));
        TableColumn tc = new TableColumn(annotationsTable.getTable(), SWT.NONE);
        tc.setText(columns[i]);
        tc.setResizable(true);
        tc.setWidth(columnWidths[i]);
      }
      annotationsTable.setCellEditors(cellEditors);
      annotationsTable.setColumnProperties(columns);
      List matchingAnnotations = new ArrayList(0);
      if (fTextEditor != null) {
        IAnnotationModel annotationModel = fTextEditor.getDocumentProvider().getAnnotationModel(fTextEditor.getEditorInput());
        if (annotationModel != null) {
          Iterator iterator = annotationModel.getAnnotationIterator();
          while (iterator.hasNext()) {
            Annotation element = (Annotation) iterator.next();
            if (true) {
              matchingAnnotations.add(element);
            }
          }
        }
View Full Code Here

        WARNING_LAYER= computeLayer("org.eclipse.wst.sse.ui.temp.warning", lookup); //$NON-NLS-1$
        ERROR_LAYER= computeLayer("org.eclipse.wst.sse.ui.temp.error", lookup); //$NON-NLS-1$
    }
   
    private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
        Annotation annotation= new Annotation(annotationType, false, null);
        AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
        if (preference != null)
            return preference.getPresentationLayer() + 1;
        else
            return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
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.