@@ -77,19 +77,20 @@ public JComponent createComponent() {
7777 container .setLayout (new BorderLayout ());
7878
7979 // todo: only one language engine for now, will add a few more in the future
80- currentEngine = TranslationEngineType .Bing ;
80+ currentEngine = TranslationEngineType .fromName (
81+ PropertiesComponent .getInstance ().getValue (StorageDataKey .SettingLanguageEngine ));
8182 TranslationEngineType [] items = TranslationEngineType .getLanguageEngineArray ();
8283 languageEngineBox = new JComboBox (items );
8384 languageEngineBox .setEnabled (true );
84- languageEngineBox .setSelectedIndex ( 0 );
85+ languageEngineBox .setSelectedItem ( currentEngine );
8586 languageEngineBox .addActionListener (this );
8687
8788 container .add (new JLabel ("Language engine: " ), BorderLayout .WEST );
8889 container .add (languageEngineBox , BorderLayout .CENTER );
8990
9091 settingPanel .add (container , BorderLayout .PAGE_START );
9192
92- // todo: at first, only bing
93+ // todo: at first, only bing, add a function: initUI(TranslationEngineType)
9394 initBingContainer ();
9495 settingPanel .add (bingContainer , BorderLayout .CENTER );
9596 }
@@ -147,7 +148,7 @@ public void apply() throws ConfigurationException {
147148 PropertiesComponent propertiesComponent = PropertiesComponent .getInstance ();
148149
149150 languageEngineChanged = false ;
150- //todo: set currentLanguageEngine
151+ propertiesComponent . setValue ( StorageDataKey . SettingLanguageEngine , currentEngine . toName ());
151152
152153 switch (currentEngine ) {
153154 case Bing : {
@@ -178,20 +179,21 @@ public void apply() throws ConfigurationException {
178179
179180 @ Override
180181 public void reset () {
181- if (settingPanel == null || currentEngine == null || languageEngineBox == null )
182+ if (settingPanel == null || languageEngineBox == null )
182183 return ;
184+ PropertiesComponent propertiesComponent = PropertiesComponent .getInstance ();
183185
184- //todo: reset languageEngineBox
186+ currentEngine = TranslationEngineType .fromName (
187+ propertiesComponent .getValue (StorageDataKey .SettingLanguageEngine ));
188+ languageEngineBox .setSelectedItem (currentEngine );
185189 languageEngineChanged = false ;
186-
187190 Log .i ("reset, current engine: " + currentEngine );
188191
189192 switch (currentEngine ) {
190193 case Bing : {
191194 if (bingClientIdField == null || bingClientSecretField == null )
192195 return ;
193196
194- PropertiesComponent propertiesComponent = PropertiesComponent .getInstance ();
195197 String bingClientIdStored = propertiesComponent .getValue (StorageDataKey .BingClientIdStored );
196198 String bingClientSecretStored = propertiesComponent .getValue (StorageDataKey .BingClientSecretStored );
197199
@@ -232,6 +234,7 @@ public void actionPerformed(ActionEvent e) {
232234
233235 languageEngineChanged = true ;
234236 Log .i ("selected type: " + type .name ());
237+ currentEngine = type ;
235238
236239 //todo: change other JComponents
237240 // currentEngine = ...
0 commit comments