Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Markers don't seem to be created on resources.
Markers don't seem to be created on resources. [message #264563] Thu, 29 July 2004 19:10 Go to next message
Eclipse UserFriend
Hi,
I'm having some trouble with resource markers. I've worked with them before,
and everthing was fine. But I can't seem to get it to work this time.

My basic problem is this: I have an xml file that stores information about
where and how to apply markers to files. I want to read that xml file, find
the resources and mark them up (that is what the recursiveMark method below
does). I've stepped through the code, and it seems that the markers are
being created because I'm not getting any errors or exceptions (I've also
tried using resource.createMarker(...), and I always got a marker back).
But, when I try and run this code again, it seems that the markers that I
thought were created can't be found. That is, the project.findMarker(...)
call below always returns an empty array. Does anywone have any ideas?

Del

private static class ReannotateRunnable implements IWorkspaceRunnable {
private IProject project;
public ReannotateRunnable(IProject project) {
this.project = project;
}
/* (non-Javadoc)
* @see
org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclips e.core.runtime.I
ProgressMonitor)
*/
public void run(IProgressMonitor monitor) throws CoreException {
IMarkingProject mp = getProjectMarks(project);
if (mp == null) {
return;
}
IMarker[] markers = project.findMarkers(RESOURCE_MARKER, true,
IResource.DEPTH_INFINITE);
for (int i = 0; i < markers.length; i++) {
try {
markers[i].delete();
} catch (CoreException e) {
}
}
recursiveMark(mp);

}

private void recursiveMark(IMarkingContainer c) throws CoreException {
Iterator i = c.getChildren().iterator();
while (i.hasNext()) {
IMarkingNode node = (IMarkingNode)i.next();
if (node instanceof IMarkingContainer) {
recursiveMark((IMarkingContainer)node);
} else if (node instanceof IMarkingAnnotationNode) {
IMarkingAnnotationNode annotation = (IMarkingAnnotationNode)node;
IResource resource = project.findMember(new
Path(annotation.getResourcePath()));
if (resource == null || !resource.exists()) {
continue;
}
try {
HashMap attrs = new HashMap();
attrs.put(IMarker.LINE_NUMBER, new Integer(annotation.getLine()));
attrs.put(
IMarker.MESSAGE,
annotation.getMessage() + " " + annotation.getPersonalMessage() + ".
\n\tScore: " + annotation.getScore()
);
attrs.put(RESOURCE_MARKER_ID, new Integer(annotation.getSchemaId()));
attrs.put(RESOURCE_MARKER_LENGTH, new
Integer(annotation.getLength()));
attrs.put(RESOURCE_MARKER_OFFSET, new
Integer(annotation.getOffset()));
attrs.put(RESOURCE_MARKER_NAME, annotation.getQualifiedName());
attrs.put(RESOURCE_MARKER_PERSONAL, annotation.getPersonalMessage());
attrs.put(RESOURCE_MARKER_SCORE, annotation.getScore()+"");
MarkerUtilities.createMarker(resource, attrs, RESOURCE_MARKER);
} catch (CoreException e) {
e.printStackTrace();
}


}
}
}

}
Re: Markers don't seem to be created on resources. [message #267381 is a reply to message #264563] Tue, 17 August 2004 13:45 Go to previous message
Eclipse UserFriend
Originally posted by: dj_houghton.nospam.ca.ibm.com

Not sure of your exact problem but try using the Core tools to help
debug. (available from the Platform/Core home page)

The Resource Delta views will show you if the markers are being created
and there are also the Marker and Resource spies to help give you more
information at the Core level.


Del wrote:

> Hi,
> I'm having some trouble with resource markers. I've worked with them before,
> and everthing was fine. But I can't seem to get it to work this time.
>
> My basic problem is this: I have an xml file that stores information about
> where and how to apply markers to files. I want to read that xml file, find
> the resources and mark them up (that is what the recursiveMark method below
> does). I've stepped through the code, and it seems that the markers are
> being created because I'm not getting any errors or exceptions (I've also
> tried using resource.createMarker(...), and I always got a marker back).
> But, when I try and run this code again, it seems that the markers that I
> thought were created can't be found. That is, the project.findMarker(...)
> call below always returns an empty array. Does anywone have any ideas?
>
> Del
>
> private static class ReannotateRunnable implements IWorkspaceRunnable {
> private IProject project;
> public ReannotateRunnable(IProject project) {
> this.project = project;
> }
> /* (non-Javadoc)
> * @see
> org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclips e.core.runtime.I
> ProgressMonitor)
> */
> public void run(IProgressMonitor monitor) throws CoreException {
> IMarkingProject mp = getProjectMarks(project);
> if (mp == null) {
> return;
> }
> IMarker[] markers = project.findMarkers(RESOURCE_MARKER, true,
> IResource.DEPTH_INFINITE);
> for (int i = 0; i < markers.length; i++) {
> try {
> markers[i].delete();
> } catch (CoreException e) {
> }
> }
> recursiveMark(mp);
>
> }
>
> private void recursiveMark(IMarkingContainer c) throws CoreException {
> Iterator i = c.getChildren().iterator();
> while (i.hasNext()) {
> IMarkingNode node = (IMarkingNode)i.next();
> if (node instanceof IMarkingContainer) {
> recursiveMark((IMarkingContainer)node);
> } else if (node instanceof IMarkingAnnotationNode) {
> IMarkingAnnotationNode annotation = (IMarkingAnnotationNode)node;
> IResource resource = project.findMember(new
> Path(annotation.getResourcePath()));
> if (resource == null || !resource.exists()) {
> continue;
> }
> try {
> HashMap attrs = new HashMap();
> attrs.put(IMarker.LINE_NUMBER, new Integer(annotation.getLine()));
> attrs.put(
> IMarker.MESSAGE,
> annotation.getMessage() + " " + annotation.getPersonalMessage() + ".
> \n\tScore: " + annotation.getScore()
> );
> attrs.put(RESOURCE_MARKER_ID, new Integer(annotation.getSchemaId()));
> attrs.put(RESOURCE_MARKER_LENGTH, new
> Integer(annotation.getLength()));
> attrs.put(RESOURCE_MARKER_OFFSET, new
> Integer(annotation.getOffset()));
> attrs.put(RESOURCE_MARKER_NAME, annotation.getQualifiedName());
> attrs.put(RESOURCE_MARKER_PERSONAL, annotation.getPersonalMessage());
> attrs.put(RESOURCE_MARKER_SCORE, annotation.getScore()+"");
> MarkerUtilities.createMarker(resource, attrs, RESOURCE_MARKER);
> } catch (CoreException e) {
> e.printStackTrace();
> }
>
>
> }
> }
> }
>
> }
>
>
Previous Topic:[RCP] IPreferencesService and FieldEditors
Next Topic:Any guidelines for splitting code into plug-ins?
Goto Forum:
  


Current Time: Tue May 06 22:55:16 EDT 2025

Powered by FUDForum. Page generated in 0.03327 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top