use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class SearchResultViewer method isPotentialMatchSelected.
private boolean isPotentialMatchSelected() {
if (getSelectedEntriesCount() == 0)
return false;
Iterator<?> iter = Collections.emptyList().iterator();
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection)
iter = ((IStructuredSelection) selection).iterator();
while (iter.hasNext()) {
Object entry = iter.next();
if (entry instanceof ISearchResultViewEntry) {
IMarker marker = ((ISearchResultViewEntry) entry).getSelectedMarker();
if (marker != null && marker.getAttribute(SearchUI.POTENTIAL_MATCH, false))
return true;
}
}
return false;
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method updateMarkerViews.
/**
* Updates visible views that show markers.
* <p>
* If the given annotation can be associated with a marker then this method tries select the
* this marker in views that show markers.
* </p>
*
* @param annotation the annotation
* @since 3.2
*/
protected void updateMarkerViews(Annotation annotation) {
if (fIsComingFromGotoMarker) {
fIsComingFromGotoMarker = false;
return;
}
IMarker marker = null;
if (annotation instanceof MarkerAnnotation)
marker = ((MarkerAnnotation) annotation).getMarker();
if (marker != null) {
try {
fIsUpdatingMarkerViews = true;
IWorkbenchPage page = getSite().getPage();
MarkerViewUtil.showMarker(page, marker, false);
} finally {
fIsUpdatingMarkerViews = false;
}
}
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class AbstractMarkerAnnotationModel method removeAnnotations.
@Override
protected void removeAnnotations(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) {
if (annotations != null && annotations.size() > 0) {
List<Annotation> markerAnnotations = new ArrayList<>();
for (Iterator<? extends Annotation> e = annotations.iterator(); e.hasNext(); ) {
Annotation a = e.next();
if (a instanceof MarkerAnnotation)
markerAnnotations.add(a);
// remove annotations from annotation model
removeAnnotation(a, false);
}
if (markerAnnotations.size() > 0) {
if (modelInitiated) {
// if model initiated also remove it from the marker manager
listenToMarkerChanges(false);
try {
IMarker[] m = new IMarker[markerAnnotations.size()];
for (int i = 0; i < m.length; i++) {
MarkerAnnotation ma = (MarkerAnnotation) markerAnnotations.get(i);
m[i] = ma.getMarker();
}
deleteMarkers(m);
} catch (CoreException x) {
handleCoreException(x, TextEditorMessages.AbstractMarkerAnnotationModel_removeAnnotations);
}
listenToMarkerChanges(true);
} else {
// remember deleted annotations in order to remove their markers later on
fDeletedAnnotations.addAll(markerAnnotations);
}
}
if (fireModelChanged)
fireModelChanged();
}
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class AbstractMarkerAnnotationModel method updateMarkers.
/**
* Updates the markers managed by this annotation model by calling
* all registered marker updaters (<code>IMarkerUpdater</code>).
*
* @param document the document to which this model is currently connected
* @throws CoreException if there is a problem updating the markers
*/
public void updateMarkers(IDocument document) throws CoreException {
Assert.isTrue(fDocument == document);
IAnnotationMap annotationMap = getAnnotationMap();
if (annotationMap.size() == 0 && fDeletedAnnotations.size() == 0)
return;
if (fMarkerUpdaterSpecifications == null)
installMarkerUpdaters();
listenToMarkerChanges(false);
try {
// update all markers with the positions known by the annotation model
for (Iterator<Annotation> e = getAnnotationIterator(false); e.hasNext(); ) {
Object o = e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a = (MarkerAnnotation) o;
IMarker marker = a.getMarker();
Position position = annotationMap.get(a);
if (!updateMarker(marker, document, position)) {
if (!fDeletedAnnotations.contains(a))
fDeletedAnnotations.add(a);
}
}
}
if (!fDeletedAnnotations.isEmpty()) {
removeAnnotations(fDeletedAnnotations, true, true);
fDeletedAnnotations.clear();
}
} finally {
listenToMarkerChanges(true);
}
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class ResourceMarkerAnnotationModel method batchedUpdate.
/**
* Updates this model to the given marker deltas.
*
* @param markerDeltas the array of marker deltas
*/
private void batchedUpdate(IMarkerDelta[] markerDeltas) {
HashSet<IMarker> removedMarkers = new HashSet<>(markerDeltas.length);
HashSet<IMarker> modifiedMarkers = new HashSet<>(markerDeltas.length);
for (int i = 0; i < markerDeltas.length; i++) {
IMarkerDelta delta = markerDeltas[i];
switch(delta.getKind()) {
case IResourceDelta.ADDED:
addMarkerAnnotation(delta.getMarker());
break;
case IResourceDelta.REMOVED:
removedMarkers.add(delta.getMarker());
break;
case IResourceDelta.CHANGED:
modifiedMarkers.add(delta.getMarker());
break;
}
}
if (modifiedMarkers.isEmpty() && removedMarkers.isEmpty())
return;
Iterator<Annotation> e = getAnnotationIterator(false);
while (e.hasNext()) {
Object o = e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a = (MarkerAnnotation) o;
IMarker marker = a.getMarker();
if (removedMarkers.remove(marker))
removeAnnotation(a, false);
if (modifiedMarkers.remove(marker)) {
Position p = createPositionFromMarker(marker);
if (p != null) {
a.update();
modifyAnnotationPosition(a, p, false);
}
}
if (modifiedMarkers.isEmpty() && removedMarkers.isEmpty())
return;
}
}
Iterator<IMarker> iter = modifiedMarkers.iterator();
while (iter.hasNext()) addMarkerAnnotation(iter.next());
}
Aggregations