保存与 IntelliJ 插件模块关联的数据
Save data associated with module for IntelliJ plugin
我正在为 IntelliJ-IDEA 开发一个插件。我的插件是一个同步插件,它需要同步数据的 ID。现在,每当用户从云端推送或提取数据时,他们都需要输入该 ID。我希望用户能够在为项目创建模块时指定 ID。我想保存与模块关联的数据。
这是我目前所拥有的。
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?
}
}
如何将 projectId
与我正在创建的模块一起保存以便我以后可以访问它?
com.intellij.openapi.module.Module
提供了一些方法来使用用户可指定的字符串键来存储简单的任意字符串值。这些方法是 setOption
、getOption
和 clearOption
。键和值将作为 <module>
标记的属性存储在模块的 .iml 文件中。
对于更详细的配置存储,您可以实现一个 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 作为将状态存储到模块文件的示例。
我正在为 IntelliJ-IDEA 开发一个插件。我的插件是一个同步插件,它需要同步数据的 ID。现在,每当用户从云端推送或提取数据时,他们都需要输入该 ID。我希望用户能够在为项目创建模块时指定 ID。我想保存与模块关联的数据。
这是我目前所拥有的。
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?
}
}
如何将 projectId
与我正在创建的模块一起保存以便我以后可以访问它?
com.intellij.openapi.module.Module
提供了一些方法来使用用户可指定的字符串键来存储简单的任意字符串值。这些方法是 setOption
、getOption
和 clearOption
。键和值将作为 <module>
标记的属性存储在模块的 .iml 文件中。
对于更详细的配置存储,您可以实现一个 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 作为将状态存储到模块文件的示例。