Skip to content

Commit

Permalink
Support record last gozeroTextField value
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaorx authored and kesonan committed Oct 30, 2023
1 parent e8b1707 commit 1e8d049
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/java/cn/xiaoheiban/ui/FileChooseDialog.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package cn.xiaoheiban.ui;

import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.TextBrowseFolderListener;
Expand Down Expand Up @@ -69,8 +70,14 @@ protected JComponent createCenterPanel() {
final JLabel styleLabel = new JLabel();
styleLabel.setText("Style");
stylePanel.add(styleLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, labelDimension, null, 0, false));

// 获取上次录入的style
String styleText = PropertiesComponent.getInstance().getValue("cn.xiaoheiban.go-zero" + "_style");
if ("".equals(styleText) || styleText==null) {
styleText = "gozero";
}
gozeroTextField = new JTextField();
gozeroTextField.setText("gozero");
gozeroTextField.setText(styleText);
stylePanel.add(gozeroTextField, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, textFieldDimension, null, 0, false));

final JPanel templatePanel = new JPanel();
Expand Down Expand Up @@ -129,7 +136,10 @@ protected ValidationInfo doValidate() {
String goctlHome = templateBrowseButton.getText();
String outputBrowserPath = textFieldWithBrowseButton.getText();

// 这里记录历史值
String style = gozeroTextField.getText();
PropertiesComponent.getInstance().setValue("cn.xiaoheiban.go-zero" + "_style", style);


String output = "", protoPath = "";
VirtualFile outputFile = LocalFileSystem.getInstance().findFileByPath(outputBrowserPath);
Expand Down

0 comments on commit 1e8d049

Please sign in to comment.