Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Adding markers during project refresh
Adding markers during project refresh [message #336577] Wed, 24 June 2009 13:23 Go to next message
Julien Manankiandrianana is currently offline Julien ManankiandriananaFriend
Messages: 37
Registered: July 2009
Member
Hi everyone,

I have to create markers on resources, the thing is that I find the
resources to associate with markers during a project refresh which I think
locks the resource for modifications (I get a ResourceException : the
resource tree is locked for modifications).

So I'd like to know if there's a way to unlock the resource tree for
modifications or if there's any other way to add visual informations in
java editors.

Thanks,

Julien
Re: Adding markers during project refresh [message #336613 is a reply to message #336577] Thu, 25 June 2009 08:35 Go to previous messageGo to next message
Hitesh  is currently offline Hitesh Friend
Messages: 19
Registered: July 2009
Junior Member
Julien M. wrote:

> Hi everyone,

> I have to create markers on resources, the thing is that I find the
> resources to associate with markers during a project refresh which I think
> locks the resource for modifications (I get a ResourceException : the
> resource tree is locked for modifications).

> So I'd like to know if there's a way to unlock the resource tree for
> modifications or if there's any other way to add visual informations in
> java editors.

> Thanks,

> Julien


Julien, are you trying to create markers inside IResourceChangeListener ?
Listeners are not allowed to modify resources during the notification
except during PRE_BUILD and POST_BUILD type of events.Instead, you could
try scheduling a Job from the listener to create the desired markers.

Hitesh
Re: Adding markers during project refresh [message #336625 is a reply to message #336613] Thu, 25 June 2009 14:01 Go to previous messageGo to next message
Julien Manankiandrianana is currently offline Julien ManankiandriananaFriend
Messages: 37
Registered: July 2009
Member
Thanks for your answer Hitesh.

The attempt to create markers is not inside an IResourceChangeListener but
is indirectly triggered by one.

I read the eclipse article about jobs
( http://www.eclipse.org/articles/Article-Concurrency/jobs-api .html) and
tried to create a job that waits 'till the resource allows modifications
but I get the following exception :
java.lang.NullPointerException
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:71)

I created a sub class of Job and put the following in the run method :

if( resource != null ){
IMarker m = null;
IResourceRuleFactory ruleFactory;
ruleFactory = ResourcesPlugin.getWorkspace().getRuleFactory();
ISchedulingRule rule = ruleFactory.createRule(resource);
IJobManager jobManager = Job.getJobManager();
try {
jobManager.beginRule(rule, monitor);
m = resource.createMarker(IMarker.PROBLEM);
m.setAttribute(IMarker.MESSAGE, "Test message");
} catch (CoreException e) {
e.printStackTrace();
}
finally{
jobManager.endRule(rule);
}
}

Any idea how I could get rid of the exception ?

Julien
Re: Adding markers during project refresh [message #336633 is a reply to message #336625] Thu, 25 June 2009 15:14 Go to previous messageGo to next message
Julien Manankiandrianana is currently offline Julien ManankiandriananaFriend
Messages: 37
Registered: July 2009
Member
Silly me I was just returning null (...) thanks for the tip !

Now I need to get the line number and position of IField, IMethod and
IType. I think it's possible is there any other than using the AST/DOM API
?

Julien
Re: Adding markers during project refresh [message #336634 is a reply to message #336633] Thu, 25 June 2009 15:25 Go to previous message
Dani Megert is currently offline Dani MegertFriend
Messages: 3802
Registered: July 2009
Senior Member
Julien M. wrote:
> Silly me I was just returning null (...) thanks for the tip !
>
> Now I need to get the line number and position of IField, IMethod and
> IType. I think it's possible is there any other than using the AST/DOM
> API ?
For declarations you can use the cheaper Java element API (see
org.eclipse.jdt.core.ISourceReference).

Dani
>
> Julien
>
Previous Topic:Galileo Release - ClearCase-Plugin is not correct
Next Topic:random launch config started?
Goto Forum:
  


Current Time: Fri Apr 19 18:50:46 GMT 2024

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

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

Back to the top