Changing and saving configuration during plugin initialization

I've got a following usecase - I check if some plugin services are enabled I would like to change plugin configuration accordingly.
To propagate these changes to configuration gui I must persist mutated changes.

Right now I'm invoking:
Application.saveSettings() in components initComponent() method

However this leads to deadlock when some other plugin is present.

My question is - is this correct way to approach such usecase or is there some other way of doing things ?
I was thinking of offloading save to invokeLater however I'm not sure if this is viable approach.

1 comment

Hello,

You shouldn't call Application.saveSettings() from initComponent() because DI container is not fully initialized at that moment.

I suggest you to do the following instead:

  1. Register custom com.intellij.openapi.startup.StartupActivity (project initialization callback);
  2. When StartupActivity.runActivity() is called, do the job;


Denis

0

Please sign in to leave a comment.