Modify persistent component in storage xml file
Answered
In my @storage "configproject.xml"
<application>
<component name="mycomponent">
<option name="rulesDirectory" value="C:\Users\.AndroidStudio3.5\config\plugins\myproject\lib\Rules" />
</component>
</application>
I want to modify the value to a different path through code after version check. How should I proceed? I am a beginner.
Please sign in to leave a comment.
You can obtain the PersistentStateComponent for "configproject.xml" and set values accordingly? WDYM with "after version check"?
"You can obtain the PersistentStateComponent for "configproject.xml" and set values accordingly? "
How should I do that? Is there any specific function that checks it's value and take user's value?
"after version check" means comparing android studio version? How can I have a access android studio version?
Who is responsible for this config file? It should be exposed by some class implementing PersistentStateComponent.
For IDE version infos see com.intellij.openapi.application.ApplicationInfo
The class implementing persistent state component is just overriding get state and load state method with it's own. This class is extending another class where I am setting the value of the component. I have a function to set the path as a persistent state component.
problem is when I set this updated path directly, if the user gives a input by browse button that path doesn't get updated.
Can you show full sources of plugin and specify exact workflow?
This is my persistent component class:
@State(name = "setting", storages = {@Storage("config.xml")})
class SettingsPersistentComponent extends classSettings implements IPersistableSettings{
@Nullable @Override
public SettingsPersistentComponent getState(){
return this;
}
@Override
public void loadState(@NotNull SettingsPersistentComponent iSettings){
XmlSerializerUtil.copyBean(iSettings, this);
}}
I'm sorry but it's not possible to start debugging from some pieces of code. Please verify your Configurable actually stores new values from its apply() method and that isModified() and reset() are implemented correctly.
ok. Thank you.