3535import org .apache .http .util .TextUtils ;
3636
3737public class EnterKeywordDialog extends JDialog {
38- private static final String NAME_CHECK_STR = "[a-zA-Z]+[0-9a-zA-Z_]" ;
39- private final Project mProject ;
40- private JPanel contentPane ;
41- private JButton buttonOK ;
42- private JButton buttonCancel ;
43- private JTextField et_name ;
44- private JRadioButton mJavaRadioButton ;
45- private JRadioButton mKotlinRadioButton ;
46- private JRadioButton mActivityRadioButton ;
47- private JRadioButton mFragmentRadioButton ;
48- private JCheckBox mViewCheckBox ;
49- private JCheckBox mPresenterCheckBox ;
50- private JCheckBox mModelCheckBox ;
51- private JComboBox <String > cob_v ;
52- private JComboBox <String > cob_p ;
53- private JComboBox <String > cob_m ;
54- private JRadioButton mGlobalRadioButton ;
55- private JRadioButton mCurrentProjectRadioButton ;
56- private JCheckBox mcbModel ;
57- private OnOkListener onOkListener ;
58- private PropertiesComponent mState ;
38+ private static final String NAME_CHECK_STR = "[a-zA-Z]+[0-9a-zA-Z_]" ;
39+ private final Project mProject ;
40+ private JPanel contentPane ;
41+ private JButton buttonOK ;
42+ private JButton buttonCancel ;
43+ private JTextField et_name ;
44+ private JRadioButton mJavaRadioButton ;
45+ private JRadioButton mKotlinRadioButton ;
46+ private JRadioButton mActivityRadioButton ;
47+ private JRadioButton mFragmentRadioButton ;
48+ private JCheckBox mViewCheckBox ;
49+ private JCheckBox mPresenterCheckBox ;
50+ private JCheckBox mModelCheckBox ;
51+ private JComboBox <String > cob_v ;
52+ private JComboBox <String > cob_p ;
53+ private JComboBox <String > cob_m ;
54+ private JRadioButton mGlobalRadioButton ;
55+ private JRadioButton mCurrentProjectRadioButton ;
56+ private JCheckBox mcbModel ;
57+ private OnOkListener onOkListener ;
58+ private PropertiesComponent mState ;
59+
60+ {
61+ // GUI initializer generated by IntelliJ IDEA GUI Designer
62+ // >>> IMPORTANT!! <<<
63+ // DO NOT EDIT OR ADD ANY CODE HERE!
64+ $$$setupUI$$$ ();
65+ }
5966
6067 private EnterKeywordDialog (Project project ) {
6168 mProject = project ;
@@ -84,13 +91,8 @@ public void windowClosing(WindowEvent e) {
8491 }
8592 if (mGlobalRadioButton .isSelected ()) {
8693 mState = PropertiesComponent .getInstance ();
87- PropertiesComponent instance = PropertiesComponent .getInstance (mProject );
88- instance .setValue (ConsKt .USE_PROJECT_CONFIG , false );
89- instance .setValue (ConsKt .GENERATE_MODEL_CONFIG , mcbModel .isSelected ());
9094 } else {
9195 mState = PropertiesComponent .getInstance (mProject );
92- mState .setValue (ConsKt .USE_PROJECT_CONFIG , true );
93- mState .setValue (ConsKt .GENERATE_MODEL_CONFIG , mcbModel .isSelected ());
9496 }
9597 setSavedSuperClass (this , mState );
9698 });
@@ -99,8 +101,8 @@ public void windowClosing(WindowEvent e) {
99101 public static EnterKeywordDialog getDialog (Project project , OnOkListener onOkListener ) {
100102 EnterKeywordDialog dialog = new EnterKeywordDialog (project );
101103 Dimension screensize = Toolkit .getDefaultToolkit ().getScreenSize ();
102- int x = (int ) screensize .getWidth () / 2 - dialog .getWidth () / 2 ;
103- int y = (int ) screensize .getHeight () / 2 - dialog .getHeight () / 2 ;
104+ int x = (int ) screensize .getWidth () / 2 - dialog .getPreferredSize (). width / 2 ;
105+ int y = (int ) screensize .getHeight () / 2 - dialog .getPreferredSize (). height / 2 ;
104106 dialog .setTitle ("MvpAutoCodePlus" );
105107 dialog .setLocation (x , y );
106108 dialog .onOkListener = onOkListener ;
@@ -111,8 +113,8 @@ public static EnterKeywordDialog getDialog(Project project, OnOkListener onOkLis
111113 dialog .mCurrentProjectRadioButton .setSelected (true );
112114 } else {
113115 dialog .mState = PropertiesComponent .getInstance ();
114- setSavedSuperClass (dialog , dialog .mState );
115116 }
117+ setSavedSuperClass (dialog , dialog .mState );
116118 boolean generateModel = state .getBoolean (ConsKt .GENERATE_MODEL_CONFIG , true );
117119 dialog .mcbModel .setSelected (generateModel );
118120 dialog .pack ();
@@ -123,9 +125,9 @@ public static EnterKeywordDialog getDialog(Project project, OnOkListener onOkLis
123125 private static void setSavedSuperClass (EnterKeywordDialog dialog , PropertiesComponent state ) {
124126 dialog .mActivityRadioButton .addChangeListener (e -> {
125127 if (dialog .mActivityRadioButton .isSelected ()) {
126- setSuperClass (dialog .cob_v , state .getValue (ConsKt .SUPER_VIEW_ACTIVITY ), dialog .mViewCheckBox , ConsKt .IS_NOT_SET + "," + ConsKt .GOTO_SETTING );
128+ setSuperClass (dialog .cob_v , dialog . mState .getValue (ConsKt .SUPER_VIEW_ACTIVITY ), dialog .mViewCheckBox , ConsKt .IS_NOT_SET + "," + ConsKt .GOTO_SETTING );
127129 } else {
128- setSuperClass (dialog .cob_v , state .getValue (ConsKt .SUPER_VIEW_FRAGMENT ), dialog .mViewCheckBox , ConsKt .IS_NOT_SET + "," + ConsKt .GOTO_SETTING );
130+ setSuperClass (dialog .cob_v , dialog . mState .getValue (ConsKt .SUPER_VIEW_FRAGMENT ), dialog .mViewCheckBox , ConsKt .IS_NOT_SET + "," + ConsKt .GOTO_SETTING );
129131 }
130132 });
131133 setSuperClass (dialog .cob_v , state .getValue (ConsKt .SUPER_VIEW_ACTIVITY ), dialog .mViewCheckBox , ConsKt .IS_NOT_SET + "," + ConsKt .GOTO_SETTING );
@@ -155,13 +157,6 @@ private static String getSelectedContent(JComboBox<String> cob) {
155157 }
156158 }
157159
158- {
159- // GUI initializer generated by IntelliJ IDEA GUI Designer
160- // >>> IMPORTANT!! <<<
161- // DO NOT EDIT OR ADD ANY CODE HERE!
162- $$$setupUI$$$ ();
163- }
164-
165160 private void onCancel () {
166161 // add your code here if necessary
167162 dispose ();
@@ -205,6 +200,9 @@ private void onOK() {
205200 return ;
206201 }
207202 buttonOK .setEnabled (false );
203+ PropertiesComponent instance = PropertiesComponent .getInstance (mProject );
204+ instance .setValue (ConsKt .USE_PROJECT_CONFIG , !mGlobalRadioButton .isSelected ());
205+ instance .setValue (ConsKt .GENERATE_MODEL_CONFIG , mcbModel .isSelected (), true );
208206 if (onOkListener != null ) {
209207 onOkListener .onOk (new ItemConfigBean (key , mJavaRadioButton .isSelected (), mActivityRadioButton .isSelected (), getSelectedContent (cob_v ), getSelectedContent (cob_p ),
210208 getSelectedContent (cob_m ), mState , mcbModel .isSelected ()));
0 commit comments