Skip to main content

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

Hi,

You can't modify the workspace tree in the notification thread, that's why
you get "The resource tree is locked for modifications."

Preferences are moved along with their project. So if you have "Proj1" with
some preferences
and you rename it to "Proj2", the preferences will be moved to "Proj2" node
in the preferences tree.

If I understand you well, you use project names to name preferences, e.g.

you have "Project1" with project preference "preference.Project2 = true"
and
"Project2" with project preference "preference.Project1 = false", or
something like this.

I can see couple possible solutions. Generally speking I would keep a map
old name -> new name
and start a sync job periodically to update preferences,

Regards
--
Szymon Brandys



                                                                           
             "Gabriel                                                      
             Petrovay"                                                     
             <gabipetrovay@gma                                          To 
             il.com>                   platform-core-dev@xxxxxxxxxxx       
             Sent by:                                                   cc 
             platform-core-dev                                             
             -bounces@eclipse.                                     Subject 
             org                       [platform-core-dev] Updating        
                                       project properties during           
                                       resourceChanged event...            
             2008-06-12 16:38                                              
                                                                           
                                                                           
             Please respond to                                             
             "Eclipse Platform                                             
              Core component                                               
             developers list."                                             
             <platform-core-de                                             
              v@xxxxxxxxxxx>                                               
                                                                           
                                                                           




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 _______________________________________________
platform-core-dev mailing list
platform-core-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-core-dev




Back to the top