2626import java .awt .*;
2727import java .awt .event .ActionEvent ;
2828import java .awt .event .ActionListener ;
29+
30+ import org .jetbrains .annotations .NotNull ;
2931import org .jetbrains .annotations .Nullable ;
3032
3133public class WatsonxSettingsForm {
3234
3335 private final JBCheckBox onPremCheckbox ;
3436 private final JBPasswordField apiKeyField ;
37+ private final ComboBox regionComboBox ;
3538 private final JBPasswordField onPremApiKeyField ;
3639 private final JBTextField onPremHostField ;
3740 private final JBTextField usernameField ;
@@ -43,6 +46,7 @@ public class WatsonxSettingsForm {
4346 private final String getStartedText = "Click here to get started with IBM watsonx.ai as a Service" ;
4447 private final String getStartedUrl = "https://dataplatform.cloud.ibm.com/registration/stepone?context=wx" ;
4548 private final JButton getStartedLink ;
49+
4650 private final JBTextField apiVersionField ;
4751 private final JBTextField projectIdField ;
4852 private final JBTextField spaceIdField ;
@@ -82,6 +86,8 @@ class OpenUrlAction implements ActionListener {
8286 getStartedLink .setToolTipText (getStartedUrl );
8387 getStartedLink .addActionListener (new OpenUrlAction ());
8488
89+ regionComboBox = new ComboBox (new String [] {"Dallas" , "Frankfurt" , "London" , "Tokyo" });
90+ regionComboBox .setSelectedItem (settings .getRegion ());
8591 apiKeyField = new JBPasswordField ();
8692 apiKeyField .setColumns (35 );
8793 ApplicationManager .getApplication ().executeOnPooledThread (() -> {
@@ -117,6 +123,10 @@ class OpenUrlAction implements ActionListener {
117123
118124 onCloudAuthenticationFieldPanel = new UI .PanelFactory ().grid ()
119125 .add (UI .PanelFactory .panel (getStartedLink ))
126+ .add (UI .PanelFactory .panel (regionComboBox )
127+ .withLabel (CodeGPTBundle .get ("settingsConfigurable.service.watsonx.cloudRegion.label" ))
128+ .withComment (CodeGPTBundle .get ("settingsConfigurable.service.watsonx.cloudRegion.comment" ))
129+ .resizeX (false ))
120130 .add (UI .PanelFactory .panel (apiKeyField )
121131 .withLabel (CodeGPTBundle .get ("settingsConfigurable.service.watsonx.onCloudApiKey.label" ))
122132 .withComment (CodeGPTBundle .get (
@@ -258,6 +268,7 @@ public WatsonxSettingsState getCurrentState() {
258268 state .setOnPremHost (onPremHostField .getText ());
259269 state .setUsername (usernameField .getText ());
260270 state .setZenApiKey (zenApiKeyCheckbox .isSelected ());
271+ state .setRegion ((String )regionComboBox .getSelectedItem ());
261272 state .setApiVersion (apiVersionField .getText ());
262273 state .setSpaceId (spaceIdField .getText ());
263274 state .setProjectId (projectIdField .getText ());
@@ -281,6 +292,7 @@ public void resetForm() {
281292 usernameField .setText (state .getUsername ());
282293 zenApiKeyCheckbox .setSelected (state .isZenApiKey ());
283294 apiKeyField .setText (CredentialsStore .getCredential (WATSONX_API_KEY ));
295+ regionComboBox .setSelectedItem (state .getRegion ());
284296 apiVersionField .setText (state .getApiVersion ());
285297 spaceIdField .setText (state .getSpaceId ());
286298 projectIdField .setText (state .getProjectId ());
0 commit comments