XML DOM API and Persisting State of Components


Hello everyone! Need help, hope someone responds.
In general, my problem is the formation of an xml file from the state of the component.
My SettingsDialogWrapper component is a modal window with a checkbox tree where the user selects files (VirtualFile) and is called by the action (!!!). Further, these files are saved in the state of the component and when the modal window is closed, they are taken from the state and processed.
And here a problem arises - I need to save these files so that the next time I initialize the component, I can use them. Since I call the SettingsDialogWrapper component using the action, I cannot use the same state class in the root class as this component.
There is, in my opinion, one solution, saving the xml file with the necessary data in the .idea of ​​the project in which the plugin will be used.
I researched this documentation:



And the dictionary module in Intellij IDEA itself:



The dictionary module uses the @Tag and @XCollection attributes in the DictionaryState state. As I understand it, based on the XML DOM API documentation, it is possible to build an xml file using these attributes. That is, IDEA itself does it.

And my question is, is it really possible to build an xml file using attributes and what is needed for this?
Perhaps you could provide an example of how this can be done?

MY PROJECT GIT: https://github.com/al-petrushin/translations-manager

Thanks in advance for your reply!

1 comment
Comment actions Permalink

If I understand correctly, you want to persist users settings in .idea settings file - then approach taken by DictionaryState.java is correct way ("Persisting State of Components"). This has _nothing_ todo with "XML DOM API" which is used to interact with XML files located in project (e.g. framework configuration file).


Please sign in to leave a comment.