Search in sources :

Example 1 with ITemporaryAnnotation

use of org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation in project webtools.sourceediting by eclipse.

the class AnnotationHoverProcessor method getHoverInfo.

public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
    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);
            // concerned with
            if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
                String msg = a.getText();
                if ((msg != null) && msg.trim().length() > 0) {
                    // dups
                    if (a instanceof ITemporaryAnnotation) {
                        boolean duplicated = false;
                        int j = 0;
                        while (j < messages.size() && !duplicated) {
                            duplicated = messages.get(j).equals(msg);
                            ++j;
                        }
                        if (!duplicated) {
                            messages.add(msg);
                        }
                    } else {
                        messages.add(msg);
                    }
                }
            }
        }
        if (messages.size() > 1) {
            return formatMessages(messages);
        } else if (messages.size() > 0) {
            return formatMessage(messages.get(0).toString());
        }
    }
    return null;
}
Also used : SourceViewer(org.eclipse.jface.text.source.SourceViewer) ITemporaryAnnotation(org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation) Position(org.eclipse.jface.text.Position) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) Annotation(org.eclipse.jface.text.source.Annotation) ITemporaryAnnotation(org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation)

Example 2 with ITemporaryAnnotation

use of org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation in project webtools.sourceediting by eclipse.

the class AbstractStructuredTextReconcilingStrategy method getAllAnnotationsToRemove.

/**
 * Remove ALL temporary annotations that this strategy can handle.
 */
protected TemporaryAnnotation[] getAllAnnotationsToRemove() {
    List removals = new ArrayList();
    IAnnotationModel annotationModel = getAnnotationModel();
    if (annotationModel != null) {
        Iterator i = annotationModel.getAnnotationIterator();
        while (i.hasNext()) {
            Object obj = i.next();
            if (!(obj instanceof ITemporaryAnnotation))
                continue;
            ITemporaryAnnotation annotation = (ITemporaryAnnotation) obj;
            ReconcileAnnotationKey key = (ReconcileAnnotationKey) annotation.getKey();
            // partition type
            if (canHandlePartition(key.getPartitionType()))
                /*
																 * &&
																 * containsStep(key.getStep())
																 */
                removals.add(annotation);
        }
    }
    return (TemporaryAnnotation[]) removals.toArray(new TemporaryAnnotation[removals.size()]);
}
Also used : ITemporaryAnnotation(org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ITemporaryAnnotation(org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation)

Aggregations

ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)2 ITemporaryAnnotation (org.eclipse.wst.sse.ui.internal.ITemporaryAnnotation)2 Position (org.eclipse.jface.text.Position)1 Annotation (org.eclipse.jface.text.source.Annotation)1 SourceViewer (org.eclipse.jface.text.source.SourceViewer)1