1.0.2 - Visual improvements, code refactoring

This commit is contained in:
Carl-Robert Linnupuu 2023-02-15 19:56:21 +00:00
parent 1ef33b85e8
commit c0f340ecad
32 changed files with 100 additions and 486 deletions

View file

@ -0,0 +1,52 @@
package ee.carlrobert.chatgpt.settings;
import com.intellij.openapi.options.Configurable;
import javax.swing.JComponent;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.Nullable;
public class SettingsConfigurable implements Configurable {
private SettingsComponent settingsComponent;
@Nls(capitalization = Nls.Capitalization.Title)
@Override
public String getDisplayName() {
return "ChatGPT: Settings";
}
@Override
public JComponent getPreferredFocusedComponent() {
return settingsComponent.getPreferredFocusedComponent();
}
@Nullable
@Override
public JComponent createComponent() {
settingsComponent = new SettingsComponent();
return settingsComponent.getPanel();
}
@Override
public boolean isModified() {
SettingsState settings = SettingsState.getInstance();
return !settingsComponent.getApiKeyField().equals(settings.secretKey);
}
@Override
public void apply() {
SettingsState settings = SettingsState.getInstance();
settings.secretKey = settingsComponent.getApiKeyField();
}
@Override
public void reset() {
SettingsState settings = SettingsState.getInstance();
settingsComponent.setApiKeyField(settings.secretKey);
}
@Override
public void disposeUIResources() {
settingsComponent = null;
}
}