Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-core-dev] Updating project properties during resourceChanged event...

H all,

I want to make sure a project remains consistent even after a project rename. For this reason, I want to update some project preferences that contain the project name, let's say "Proj1" and repace it it the new name "Proj2". Therefore I implement the IResourceChangeListener and during the renaming I change all properties that have "Proj1". For this I use this code:

        IScopeContext fCurrContext = new ProjectScope(myProj1);
        IEclipsePreferences node = fCurrContext.getNode(PLUGIN_ID);
        node.remove("my_property");
        node.put("my_property", value);
        node.flush();

This will cause a CoreException with the message: "The resource tree is locked for modifications."

So I remove the flush() and take benefit of the Eclipse property caching mechanisms. Everything works fine if I only rename a project once. When I rename it the second time (in the same session), since the new properties containing "Proj2" are only in the Eclipse cache, the new project (say Proj3) will have again all the properties containing "Proj1" and not "Proj2". This is because during the second renaming, Proj2 is copied and than deleted, but the copy contains the original settings from the disk of Proj1 because the ones of Proj2 were still in cache.

How can I force a cache flush() before the renaming of the project? Or how can I persistently change the properties of a project during the resourceChanged event?

Thanks!

--
MSc Gabriel Petrovay
MCSA, MCDBA, MCAD
Mobile: +41(0)787978034

Back to the top