use of org.eclipse.wst.sse.ui.internal.StructuredMarkerAnnotation in project webtools.sourceediting by eclipse.
the class AbstractStructuredTextReconcilingStrategy method getAnnotationsToRemove.
protected TemporaryAnnotation[] getAnnotationsToRemove(DirtyRegion dr, List stepsRun) {
List remove = new ArrayList();
IAnnotationModel annotationModel = getAnnotationModel();
// can be null when closing the editor
if (getAnnotationModel() != null) {
// clear validator annotations
getMarkerAnnotations().clear();
Iterator i = annotationModel.getAnnotationIterator();
while (i.hasNext()) {
Object obj = i.next();
// if it is save it for comparision later (to "gray" icons)
if (obj instanceof StructuredMarkerAnnotation) {
StructuredMarkerAnnotation sma = (StructuredMarkerAnnotation) obj;
if (sma.getAnnotationType() == TemporaryAnnotation.ANNOT_ERROR || sma.getAnnotationType() == TemporaryAnnotation.ANNOT_WARNING)
fMarkerAnnotations.add(sma);
}
if (!(obj instanceof TemporaryAnnotation))
continue;
TemporaryAnnotation annotation = (TemporaryAnnotation) obj;
ReconcileAnnotationKey key = (ReconcileAnnotationKey) annotation.getKey();
// partition type
if (canHandlePartition(key.getPartitionType()) && stepsRun.contains(key.getStep())) {
if (key.getScope() == ReconcileAnnotationKey.PARTIAL && annotation.getPosition().overlapsWith(dr.getOffset(), dr.getLength())) {
remove.add(annotation);
} else if (key.getScope() == ReconcileAnnotationKey.TOTAL) {
remove.add(annotation);
}
}
}
}
return (TemporaryAnnotation[]) remove.toArray(new TemporaryAnnotation[remove.size()]);
}
use of org.eclipse.wst.sse.ui.internal.StructuredMarkerAnnotation in project webtools.sourceediting by eclipse.
the class AbstractStructuredTextReconcilingStrategy method addResultToAnnotationModel.
/**
* This is where we add results to the annotationModel, doing any special
* "extra" processing.
*/
protected void addResultToAnnotationModel(IReconcileResult result) {
if (!(result instanceof TemporaryAnnotation))
return;
// can be null when closing the editor
if (getAnnotationModel() != null) {
TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) result;
StructuredMarkerAnnotation sma = getCorrespondingMarkerAnnotation(tempAnnotation);
if (sma != null) {
// un-gray out the marker annotation
sma.setGrayed(false);
}
getAnnotationModel().addAnnotation(tempAnnotation, tempAnnotation.getPosition());
}
}
use of org.eclipse.wst.sse.ui.internal.StructuredMarkerAnnotation in project webtools.sourceediting by eclipse.
the class AbstractStructuredTextReconcilingStrategy method getCorrespondingMarkerAnnotation.
private StructuredMarkerAnnotation getCorrespondingMarkerAnnotation(TemporaryAnnotation tempAnnotation) {
Iterator it = getMarkerAnnotations().iterator();
while (it.hasNext()) {
StructuredMarkerAnnotation markerAnnotation = (StructuredMarkerAnnotation) it.next();
// $NON-NLS-1$
String message = "";
try {
message = (String) markerAnnotation.getMarker().getAttribute(IMarker.MESSAGE);
} catch (CoreException e) {
if (DEBUG)
Logger.logException(e);
}
// it would be nice to check line number here...
if (message != null && message.equals(tempAnnotation.getText()))
return markerAnnotation;
}
return null;
}
use of org.eclipse.wst.sse.ui.internal.StructuredMarkerAnnotation in project webtools.sourceediting by eclipse.
the class AbstractStructuredTextReconcilingStrategy method removeAnnotations.
private void removeAnnotations(TemporaryAnnotation[] annotationsToRemove) {
IAnnotationModel annotationModel = getAnnotationModel();
// can be null when closing the editor
if (annotationModel != null) {
for (int i = 0; i < annotationsToRemove.length; i++) {
if (isCanceled()) {
if (DEBUG)
// $NON-NLS-1$
System.out.println("[trace reconciler] >** REMOVAL WAS CANCELLED **");
return;
}
StructuredMarkerAnnotation sma = getCorrespondingMarkerAnnotation(annotationsToRemove[i]);
if (sma != null) {
// gray out the marker annotation
sma.setGrayed(true);
}
// remove the temp one
annotationModel.removeAnnotation(annotationsToRemove[i]);
}
}
if (DEBUG) {
StringBuffer traceString = new StringBuffer();
for (int i = 0; i < annotationsToRemove.length; i++) // $NON-NLS-1$ //$NON-NLS-2$
traceString.append("\n (-) :" + annotationsToRemove[i] + ":\n");
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("[trace reconciler] > REMOVED (" + annotationsToRemove.length + ") annotations in AbstractStructuredTextReconcilingStrategy :" + traceString);
}
}
Aggregations