Modify source folders and resources

Hi,

I'm trying to write a Plugin which modifies source folders and resources. This will be used in a large project (> 100 modules).
Sometime all modules will be modified at once.
What I would like to do is change the modules and then let IntelliJ know that something's changed and do its thing.
What I would NOT like to do is change a module, let IntelliJ notice the change, change anoter module, etc...
So is it possible to change multiple modules and then let IntelliJ know that I made changes?
BTW what's the correct way of adding a source folder to a module from a plugin?

Dan

3 comments
Comment actions Permalink

             1.
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(changes);
             2. ApplicationManager.getApplication().runWriteAction(new
Runnable() {
       @Override
       public void run() {
         ModifiableRootModel model =
ModuleRootManager.getInstance(module).getModifiableModel();
         VirtualFile baseDir = ...;
         ContentEntry entry = model.addContentEntry(baseDir);
         entry.addSourceFolder(baseDir, false);
         model.commit();
       }
     });

On 10/12/2015 11:05 PM, Daniel Fritsi wrote:

Hi,

>

I'm trying to write a Plugin which modifies source folders and resources. This will be used in a large project (> 100 modules).
Sometime all modules will be modified at once.
What I would like to do is change the modules and then let IntelliJ know that something's changed and do its thing.
What I would NOT like to do is change a module, let IntelliJ notice the change, change anoter module, etc...
So is it possible to change multiple modules and then let IntelliJ know that I made changes?
BTW what's the correct way of adding a source folder to a module from a plugin?

>

Dan

>

---
Original message URL: https://devnet.jetbrains.com/message/5560469#5560469

>

0
Comment actions Permalink

Many thanks.

So for "locking" I can either use 1. or 2.?
I can see that ApplicationManager.getApplication().runWriteAction should be invoked from a UI thread, but what if I'm not on a UI thread? Then I should use 1.) ?

0
Comment actions Permalink

Use ApplicationManager.invokeAndWait()

source code marked as 2 describes how to attach source folder to the module

On 10/13/2015 6:43 PM, Daniel Fritsi wrote:

Many thanks.

>

So for "locking" I can either use 1. or 2.?
I can see that ApplicationManager.getApplication().runWriteAction should be invoked from a UI thread, but what if I'm not on a UI thread? Then I should use 1.) ?

>

---
Original message URL: https://devnet.jetbrains.com/message/5560551#5560551

>

0

Please sign in to leave a comment.