use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class MarkerAnnotation method initialize.
/**
* Initializes the annotation's icon representation and its drawing layer
* based upon the properties of the underlying marker.
*
* @deprecated As of 3.0, visual presentation is no longer supported,
* annotation with a visible presentation should implement
* {@link org.eclipse.jface.text.source.IAnnotationPresentation}
*/
@Deprecated
protected void initialize() {
IMarker marker = getMarker();
String name = getUnknownImageName(marker);
if (MarkerUtilities.isMarkerType(marker, IMarker.TASK)) {
name = IDE.SharedImages.IMG_OBJS_TASK_TSK;
} else if (MarkerUtilities.isMarkerType(marker, IMarker.BOOKMARK)) {
name = IDE.SharedImages.IMG_OBJS_BKMRK_TSK;
} else if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {
switch(MarkerUtilities.getSeverity(marker)) {
case IMarker.SEVERITY_INFO:
name = ISharedImages.IMG_OBJS_INFO_TSK;
break;
case IMarker.SEVERITY_WARNING:
name = ISharedImages.IMG_OBJS_WARN_TSK;
break;
case IMarker.SEVERITY_ERROR:
name = ISharedImages.IMG_OBJS_ERROR_TSK;
break;
}
}
fImage = null;
fImageName = name;
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class MarkerRulerAction method removeMarkers.
/**
* Removes the given markers.
*
* @param markers the markers to be deleted
*/
protected void removeMarkers(final List<? extends IMarker> markers) {
IMarker[] markersArray = markers.toArray(new IMarker[markers.size()]);
execute(new DeleteMarkersOperation(markersArray, getOperationName()));
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class MarkerRulerAction method getMarkers.
/**
* Returns all markers which include the ruler's line of activity.
*
* @return all a list of markers which include the ruler's line of activity
*/
protected List<IMarker> getMarkers() {
List<IMarker> markers = new ArrayList<>();
IResource resource = getResource();
IDocument document = getDocument();
AbstractMarkerAnnotationModel model = getAnnotationModel();
if (resource != null && model != null && resource.exists()) {
try {
IMarker[] allMarkers = resource.findMarkers(fMarkerType, true, IResource.DEPTH_ZERO);
if (allMarkers != null) {
for (int i = 0; i < allMarkers.length; i++) {
if (includesRulerLine(model.getMarkerPosition(allMarkers[i]), document)) {
markers.add(allMarkers[i]);
}
}
}
} catch (CoreException x) {
handleCoreException(x, TextEditorMessages.MarkerRulerAction_getMarker);
}
}
return markers;
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class MarkerUtilities method createMarker.
/**
* Creates a marker on the given resource with the given type and attributes.
* <p>
* This method modifies the workspace (progress is not reported to the user).</p>
*
* @param resource the resource
* @param attributes the attribute map
* @param markerType the type of marker
* @throws CoreException if this method fails
* @see IResource#createMarker(java.lang.String)
*/
public static void createMarker(final IResource resource, final Map<String, Object> attributes, final String markerType) throws CoreException {
IWorkspaceRunnable r = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IMarker marker = resource.createMarker(markerType);
marker.setAttributes(attributes);
}
};
resource.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
}
use of org.eclipse.core.resources.IMarker in project eclipse.platform.text by eclipse.
the class SelectMarkerRulerAction method getMarkers.
/**
* Returns all markers which include the ruler's line of activity.
*
* @return an unmodifiable list with all markers which include the ruler's line of activity
*/
protected final List<IMarker> getMarkers() {
final IResource resource = getResource();
if (resource == null || !resource.exists())
return Collections.emptyList();
final IDocument document = getDocument();
if (document == null)
return Collections.emptyList();
final AbstractMarkerAnnotationModel model = getAnnotationModel();
if (model == null)
return Collections.emptyList();
final IMarker[] allMarkers;
try {
allMarkers = resource.findMarkers(null, true, IResource.DEPTH_ZERO);
} catch (CoreException x) {
handleCoreException(x, TextEditorMessages.SelectMarkerRulerAction_getMarker);
return Collections.emptyList();
}
if (allMarkers.length == 0)
return Collections.emptyList();
final int activeLine = fRuler.getLineOfLastMouseButtonActivity();
if (activeLine == -1)
return Collections.emptyList();
Iterator<Annotation> it;
try {
IRegion line = document.getLineInformation(activeLine);
it = model.getAnnotationIterator(line.getOffset(), line.getLength() + 1, true, true);
} catch (BadLocationException e) {
Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
Platform.getLog(bundle).log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, e.getLocalizedMessage(), e));
it = model.getAnnotationIterator();
}
List<IMarker> markers = null;
while (it.hasNext()) {
Annotation annotation = it.next();
if (annotation instanceof MarkerAnnotation) {
Position position = model.getPosition(annotation);
if (includesLine(position, document, activeLine)) {
if (markers == null)
markers = new ArrayList<>(10);
markers.add(((MarkerAnnotation) annotation).getMarker());
}
}
}
if (markers == null)
return Collections.emptyList();
return Collections.unmodifiableList(markers);
}
Aggregations