Reputation: 6202
I'm developing a plugin for IntelliJ-IDEA. My plugin is a synchronization plugin which requires an ID for the data that it's synchronizing. Right now, whenever a user either pushes or pulls data from the cloud, they need to enter that ID. I want the user to be able to specify the ID at the time they create the module for their project. I want to save data associated with a module.
This is what I have so far.
package com.michaelsnowden.gas.module;
import com.intellij.ide.util.projectWizard.ModuleWizardStep;
import javax.swing.*;
/**
* @author michael.snowden
*/
public class GASModuleWizardStep extends ModuleWizardStep {
@Override
public JComponent getComponent() {
final JPanel jPanel = new JPanel();
JTextField textField = new JTextField("My GAS project id");
jPanel.add(textField);
return jPanel;
}
@Override
public void updateDataModel() {
JTextField textField = (JTextField) getComponent().getComponent(0);
String projectId = textField.getText();
System.out.println(projectId);
// Now how do I save this projectId and associate it with the module?
}
}
How do I save the projectId
with the module I'm creating so that I can access it later?
Upvotes: 1
Views: 244
Reputation: 26562
com.intellij.openapi.module.Module
provides some methods to store simple arbitrary string values with user specifiable string keys. These methods are setOption
, getOption
and clearOption
. The keys and values will be stored in the module's .iml file as attibutes to the <module>
tag.
For more elaborate configuration storage you can implement a PersistentStorageComponent. Use this if you want to store more than one value or more complex data structures than a simple string. See org.jetbrains.idea.devkit.build.PluginBuildConfiguration for an example of storing state to the module file.
Upvotes: 2