public String getHoverInfo()

in CasViewerEclipsePlugin/uimaj-ep-casviewer-core/src/main/java/org/apache/uima/casviewer/ui/internal/hover/AnnotationHover.java [50:97]


  public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
    IAnnotationModel model = fSourceViewer.getAnnotationModel();
    if (model == null) {
      Trace.err("No annotation model");
      return null;
    }
    
    // Find all annotations inside hoverRegion
    // Trace.err(hoverRegion.getOffset() + " " + hoverRegion.getLength());
    Iterator e = model.getAnnotationIterator();
    List list = new ArrayList();
    while (e.hasNext()) {
      Annotation a = (Annotation) e.next();
      Position p = model.getPosition(a);
      // Trace.err(a.getText() + " type:" + a.getType() + " offset:" + p.offset + " lenght:" + p.length);
      if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
        String t = a.getText();
        if (t != null && t.trim().length() > 0) {
          list.add(a);
        }
      }
    }
    
    // Sort list of annotations
    if (list.size() > 0) {
        Collections.sort(list, new MyComparator());
        Annotation a;
        String msg = "";
        for (int i=0; i<list.size(); ++i) {
            a = (Annotation) list.get(i);
            String t = a.getText();
            t = t.replace("\n", " "); // need to handle splitted text of annotation
            if (t.length() > MAX_LINE_LENGTH) {
                t = t.substring(0, LINE_LENGTH_BEFORE) + " ... " 
                + t.substring(t.length() - LINE_LENGTH_AFTER);
            }
            // msg += "<li>[<b>" + a.getType() + "</b>] " + t + "</li>"; 
            if (a instanceof IVisualDecoration) {
                msg += "[" + ((IVisualDecoration)a).getUimaTypeName() + "]" + t + "\n"; 
            } else {
                msg += "[" + a.getType() + "]" + t + "\n";       
            }
        }
        return msg;
    }
    
    return null;
  }