12
12
import com .intellij .ui .components .JBTextField ;
13
13
import com .intellij .util .ui .FormBuilder ;
14
14
import ee .carlrobert .codegpt .CodeGPTBundle ;
15
- import ee .carlrobert .codegpt .settings .service .ServiceSelectionForm ;
16
15
import ee .carlrobert .codegpt .settings .service .ServiceType ;
16
+ import ee .carlrobert .codegpt .settings .service .anthropic .AnthropicSettings ;
17
+ import ee .carlrobert .codegpt .settings .service .anthropic .AnthropicSettingsForm ;
18
+ import ee .carlrobert .codegpt .settings .service .azure .AzureSettings ;
19
+ import ee .carlrobert .codegpt .settings .service .azure .AzureSettingsForm ;
20
+ import ee .carlrobert .codegpt .settings .service .custom .CustomServiceForm ;
21
+ import ee .carlrobert .codegpt .settings .service .llama .LlamaSettings ;
22
+ import ee .carlrobert .codegpt .settings .service .llama .form .LlamaSettingsForm ;
23
+ import ee .carlrobert .codegpt .settings .service .openai .OpenAISettings ;
24
+ import ee .carlrobert .codegpt .settings .service .openai .OpenAISettingsForm ;
25
+ import ee .carlrobert .codegpt .settings .service .you .YouSettings ;
26
+ import ee .carlrobert .codegpt .settings .service .you .YouSettingsForm ;
17
27
import java .awt .CardLayout ;
18
28
import java .awt .Component ;
19
29
import java .awt .Container ;
@@ -29,21 +39,30 @@ public class GeneralSettingsComponent {
29
39
private final JPanel mainPanel ;
30
40
private final JBTextField displayNameField ;
31
41
private final ComboBox <ServiceType > serviceComboBox ;
32
- private final ServiceSelectionForm serviceSelectionForm ;
42
+ private final OpenAISettingsForm openAISettingsForm ;
43
+ private final CustomServiceForm customConfigurationSettingsForm ;
44
+ private final AnthropicSettingsForm anthropicSettingsForm ;
45
+ private final AzureSettingsForm azureSettingsForm ;
46
+ private final YouSettingsForm youSettingsForm ;
47
+ private final LlamaSettingsForm llamaSettingsForm ;
33
48
34
49
public GeneralSettingsComponent (Disposable parentDisposable , GeneralSettings settings ) {
35
50
displayNameField = new JBTextField (settings .getState ().getDisplayName (), 20 );
36
- serviceSelectionForm = new ServiceSelectionForm (parentDisposable );
51
+ openAISettingsForm = new OpenAISettingsForm (OpenAISettings .getCurrentState ());
52
+ customConfigurationSettingsForm = new CustomServiceForm ();
53
+ anthropicSettingsForm = new AnthropicSettingsForm (AnthropicSettings .getCurrentState ());
54
+ azureSettingsForm = new AzureSettingsForm (AzureSettings .getCurrentState ());
55
+ youSettingsForm = new YouSettingsForm (YouSettings .getCurrentState (), parentDisposable );
56
+ llamaSettingsForm = new LlamaSettingsForm (LlamaSettings .getCurrentState ());
57
+
37
58
var cardLayout = new DynamicCardLayout ();
38
59
var cards = new JPanel (cardLayout );
39
- cards .add (serviceSelectionForm .getOpenAISettingsForm ().getForm (), OPENAI .getCode ());
40
- cards .add (
41
- serviceSelectionForm .getCustomConfigurationSettingsForm ().getForm (),
42
- CUSTOM_OPENAI .getCode ());
43
- cards .add (serviceSelectionForm .getAnthropicSettingsForm ().getForm (), ANTHROPIC .getCode ());
44
- cards .add (serviceSelectionForm .getAzureSettingsForm ().getForm (), AZURE .getCode ());
45
- cards .add (serviceSelectionForm .getYouSettingsForm (), YOU .getCode ());
46
- cards .add (serviceSelectionForm .getLlamaSettingsForm (), LLAMA_CPP .getCode ());
60
+ cards .add (openAISettingsForm .getForm (), OPENAI .getCode ());
61
+ cards .add (customConfigurationSettingsForm .getForm (), CUSTOM_OPENAI .getCode ());
62
+ cards .add (anthropicSettingsForm .getForm (), ANTHROPIC .getCode ());
63
+ cards .add (azureSettingsForm .getForm (), AZURE .getCode ());
64
+ cards .add (youSettingsForm , YOU .getCode ());
65
+ cards .add (llamaSettingsForm , LLAMA_CPP .getCode ());
47
66
var serviceComboBoxModel = new DefaultComboBoxModel <ServiceType >();
48
67
serviceComboBoxModel .addAll (Arrays .stream (ServiceType .values ()).toList ());
49
68
serviceComboBox = new ComboBox <>(serviceComboBoxModel );
@@ -63,6 +82,30 @@ public GeneralSettingsComponent(Disposable parentDisposable, GeneralSettings set
63
82
.getPanel ();
64
83
}
65
84
85
+ public OpenAISettingsForm getOpenAISettingsForm () {
86
+ return openAISettingsForm ;
87
+ }
88
+
89
+ public CustomServiceForm getCustomConfigurationSettingsForm () {
90
+ return customConfigurationSettingsForm ;
91
+ }
92
+
93
+ public AnthropicSettingsForm getAnthropicSettingsForm () {
94
+ return anthropicSettingsForm ;
95
+ }
96
+
97
+ public AzureSettingsForm getAzureSettingsForm () {
98
+ return azureSettingsForm ;
99
+ }
100
+
101
+ public LlamaSettingsForm getLlamaSettingsForm () {
102
+ return llamaSettingsForm ;
103
+ }
104
+
105
+ public YouSettingsForm getYouSettingsForm () {
106
+ return youSettingsForm ;
107
+ }
108
+
66
109
public ServiceType getSelectedService () {
67
110
return serviceComboBox .getItem ();
68
111
}
@@ -79,10 +122,6 @@ public JComponent getPreferredFocusedComponent() {
79
122
return displayNameField ;
80
123
}
81
124
82
- public ServiceSelectionForm getServiceSelectionForm () {
83
- return serviceSelectionForm ;
84
- }
85
-
86
125
public String getDisplayName () {
87
126
return displayNameField .getText ();
88
127
}
@@ -91,6 +130,15 @@ public void setDisplayName(String displayName) {
91
130
displayNameField .setText (displayName );
92
131
}
93
132
133
+ public void resetForms () {
134
+ openAISettingsForm .resetForm ();
135
+ customConfigurationSettingsForm .resetForm ();
136
+ anthropicSettingsForm .resetForm ();
137
+ azureSettingsForm .resetForm ();
138
+ youSettingsForm .resetForm ();
139
+ llamaSettingsForm .resetForm ();
140
+ }
141
+
94
142
static class DynamicCardLayout extends CardLayout {
95
143
96
144
@ Override
0 commit comments