diff --git a/build.gradle.kts b/build.gradle.kts
index 78fd1c08..752d86d1 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,7 +4,7 @@ plugins {
}
group = "ee.carlrobert"
-version = "1.1.0"
+version = "1.1.1"
repositories {
mavenCentral()
diff --git a/src/main/java/ee/carlrobert/chatgpt/ide/notification/NotificationService.java b/src/main/java/ee/carlrobert/chatgpt/ide/notification/NotificationService.java
deleted file mode 100644
index b515eec2..00000000
--- a/src/main/java/ee/carlrobert/chatgpt/ide/notification/NotificationService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package ee.carlrobert.chatgpt.ide.notification;
-
-import com.intellij.notification.Notification;
-import com.intellij.notification.NotificationGroupManager;
-import com.intellij.notification.NotificationType;
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.options.ShowSettingsUtil;
-import com.intellij.openapi.project.Project;
-import ee.carlrobert.chatgpt.ide.settings.SettingsConfigurable;
-import org.jetbrains.annotations.NotNull;
-
-public class NotificationService {
-
- private Notification notification;
-
- public void createAndNotify(@NotNull Project project) {
- createNotification();
- notify(project);
- }
-
- public void expire() {
- if (notification != null) {
- notification.expire();
- }
- }
-
- private void notify(@NotNull Project project) {
- this.notification
- .addAction(new AnAction("Open Settings") {
- @Override
- public void actionPerformed(@NotNull AnActionEvent event) {
- DataContext dataContext = event.getDataContext();
- Project project = PlatformDataKeys.PROJECT.getData(dataContext);
- ShowSettingsUtil.getInstance().showSettingsDialog(project, SettingsConfigurable.class);
- }
- })
- .notify(project);
- }
-
- private void createNotification() {
- this.notification = NotificationGroupManager.getInstance()
- .getNotificationGroup("ChatGPT-Empty-API-Key")
- .createNotification("ChatGPT API key not set", NotificationType.WARNING);
- }
-}
diff --git a/src/main/java/ee/carlrobert/chatgpt/ide/notification/ShowNotificationActivity.java b/src/main/java/ee/carlrobert/chatgpt/ide/notification/ShowNotificationActivity.java
deleted file mode 100644
index ada44485..00000000
--- a/src/main/java/ee/carlrobert/chatgpt/ide/notification/ShowNotificationActivity.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package ee.carlrobert.chatgpt.ide.notification;
-
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.startup.StartupActivity;
-import ee.carlrobert.chatgpt.ide.settings.SettingsState;
-import org.jetbrains.annotations.NotNull;
-
-public class ShowNotificationActivity implements StartupActivity {
-
- @Override
- public void runActivity(@NotNull Project project) {
- var notificationService = ApplicationManager.getApplication().getService(NotificationService.class);
- var apiKey = SettingsState.getInstance().apiKey;
- if (apiKey == null || apiKey.isEmpty()) {
- notificationService.createAndNotify(project);
- }
- }
-}
diff --git a/src/main/java/ee/carlrobert/chatgpt/ide/toolwindow/ToolWindowService.java b/src/main/java/ee/carlrobert/chatgpt/ide/toolwindow/ToolWindowService.java
index b7c195d9..fc6201c7 100644
--- a/src/main/java/ee/carlrobert/chatgpt/ide/toolwindow/ToolWindowService.java
+++ b/src/main/java/ee/carlrobert/chatgpt/ide/toolwindow/ToolWindowService.java
@@ -3,6 +3,7 @@ package ee.carlrobert.chatgpt.ide.toolwindow;
import static ee.carlrobert.chatgpt.ide.toolwindow.ToolWindowUtil.createIconLabel;
import static ee.carlrobert.chatgpt.ide.toolwindow.ToolWindowUtil.createTextArea;
import static ee.carlrobert.chatgpt.ide.toolwindow.ToolWindowUtil.justifyLeft;
+import static java.lang.String.format;
import com.intellij.ide.ui.LafManager;
import com.intellij.ide.ui.LafManagerListener;
@@ -60,16 +61,11 @@ public class ToolWindowService implements LafManagerListener {
addIconLabel(Icons.DefaultImageIcon, "ChatGPT:");
addSpacing(8);
- var apiKey = SettingsState.getInstance().apiKey;
- if (apiKey == null || apiKey.isEmpty()) {
- var label = new JLabel("API key not provided. Open Settings to set one.");
- label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- label.addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- ShowSettingsUtil.getInstance().showSettingsDialog(project, SettingsConfigurable.class);
- }
- });
- scrollablePanel.add(justifyLeft(label));
+ var settings = SettingsState.getInstance();
+ if (settings.isGPTOptionSelected && settings.apiKey.isEmpty()) {
+ notifyMissingCredential(project, "API key not provided.");
+ } else if (settings.isChatGPTOptionSelected && settings.accessToken.isEmpty()) {
+ notifyMissingCredential(project, "Access token not provided.");
} else {
var textArea = new SyntaxTextArea();
scrollablePanel.add(textArea);
@@ -135,6 +131,17 @@ public class ToolWindowService implements LafManagerListener {
scrollablePanel.add(justifyLeft(createIconLabel(imageIcon, text)));
}
+ private void notifyMissingCredential(Project project, String text) {
+ var label = new JLabel(format("%s Open Settings to set one.", text));
+ label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ label.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ ShowSettingsUtil.getInstance().showSettingsDialog(project, SettingsConfigurable.class);
+ }
+ });
+ scrollablePanel.add(justifyLeft(label));
+ }
+
@Override
public void lookAndFeelChanged(@NotNull LafManager source) {
for (var textArea : textAreas) {
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index db3b7e3e..2d641ffd 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -8,11 +8,11 @@
Available commands
Before using the plugin, it is necessary to configure the API key in the Settings → Tools → ChatGPT
@@ -21,6 +21,8 @@