diff --git a/build.gradle.kts b/build.gradle.kts
index a30eae7f..af2ac3a0 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -75,7 +75,7 @@ tasks {
}
patchPluginXml {
- sinceBuild.set("230.*")
+ sinceBuild.set("232.*")
untilBuild.set("246.*")
}
diff --git a/src/main/java/com/couchbase/intellij/database/ActiveCluster.java b/src/main/java/com/couchbase/intellij/database/ActiveCluster.java
index 20864127..47af8292 100644
--- a/src/main/java/com/couchbase/intellij/database/ActiveCluster.java
+++ b/src/main/java/com/couchbase/intellij/database/ActiveCluster.java
@@ -12,6 +12,7 @@
import com.couchbase.intellij.tree.overview.apis.ServerOverview;
import com.couchbase.intellij.utils.Subscribable;
import com.couchbase.intellij.workbench.Log;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
@@ -22,7 +23,6 @@
import org.jetbrains.annotations.VisibleForTesting;
import utils.CBConfigUtil;
-import javax.swing.*;
import java.awt.*;
import java.time.Duration;
import java.util.List;
@@ -173,7 +173,7 @@ public void run(@NotNull ProgressIndicator indicator) {
return;
}
Log.info("Disconnected from cluster " + savedCluster.getId());
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
try {
Messages.showErrorDialog(
String.format("Lost connection to cluster '%s'", savedCluster.getId()),
@@ -222,7 +222,7 @@ public void run(@NotNull ProgressIndicator indicator) {
});
INSTANCE.set(ActiveCluster.this);
} catch (Exception e) {
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog(
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(
String.format("Error while connecting to cluster '%s': \n %s", savedCluster.getId(), e.getMessage()),
"Failed to connect to cluster"
));
@@ -338,7 +338,7 @@ public Stream extends CouchbaseClusterEntity> getChild(String name) {
if (getChildren() == null) {
return Stream.empty();
}
-
+
return getChildren().stream()
.flatMap(b -> Stream.concat(
Stream.of(b),
@@ -383,7 +383,7 @@ public void run(@NotNull ProgressIndicator indicator) {
if (onComplete != null) {
onComplete.accept(e);
}
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not read cluster schema.", "Couchbase Connection Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not read cluster schema.", "Couchbase Connection Error"));
disconnect();
}
}
diff --git a/src/main/java/com/couchbase/intellij/database/DataLoader.java b/src/main/java/com/couchbase/intellij/database/DataLoader.java
index 71fb8c7a..432aabe2 100644
--- a/src/main/java/com/couchbase/intellij/database/DataLoader.java
+++ b/src/main/java/com/couchbase/intellij/database/DataLoader.java
@@ -45,7 +45,6 @@
import org.jetbrains.annotations.Nullable;
import utils.IndexUtils;
-import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import java.time.Duration;
@@ -88,7 +87,7 @@ public static void listBuckets(DefaultMutableTreeNode parentNode, Tree tree) {
parentNode.add(new DefaultMutableTreeNode(new NoResultsNodeDescriptor()));
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
});
@@ -128,7 +127,7 @@ public static void listScopes(DefaultMutableTreeNode parentNode, Tree tree) {
parentNode.add(new DefaultMutableTreeNode(new NoResultsNodeDescriptor()));
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
});
} catch (Exception e) {
@@ -169,7 +168,7 @@ public static void listCollections(DefaultMutableTreeNode parentNode, Tree tree)
} else {
parentNode.add(new DefaultMutableTreeNode(new NoResultsNodeDescriptor()));
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
});
@@ -244,7 +243,7 @@ public static void listDocuments(DefaultMutableTreeNode parentNode, Tree tree, i
} else if (newOffset == 0) {
parentNode.add(new DefaultMutableTreeNode(new NoResultsNodeDescriptor()));
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
});
}
@@ -296,7 +295,7 @@ private static void loadKVDocuments(DefaultMutableTreeNode parentNode, Tree tree
parentNode.add(new DefaultMutableTreeNode(new NoResultsNodeDescriptor()));
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
});
}
@@ -340,18 +339,18 @@ public static void loadDocument(Project project, FileNodeDescriptor node, @Nulla
}
} catch (DocumentNotFoundException dnf) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("The document " + node.getId() + " doesn't exists anymore.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("The document " + node.getId() + " doesn't exists anymore.", "Couchbase Plugin Error"));
return;
} catch (TimeoutException te) {
te.printStackTrace();
Log.error("Request to get the document " + node.getId() + " timed out.", te);
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("The request to get the document " + node.getId() + " timed out. Please try again or check your network connection.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("The request to get the document " + node.getId() + " timed out. Please try again or check your network connection.", "Couchbase Plugin Error"));
return;
} catch (Exception e) {
Log.error("Could not load the document " + node.getId() + ".", e);
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
return;
} finally {
if (tree != null) {
@@ -384,7 +383,7 @@ public static void loadDocument(Project project, FileNodeDescriptor node, @Nulla
tree.setPaintBusy(false);
}
Log.error("An error occurred while trying to load the file", e);
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
}
}
@@ -414,7 +413,7 @@ public void run(@NotNull ProgressIndicator indicator) {
Log.debug("Could not infer the schema for " + colNode.getText());
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
treeModel.nodeStructureChanged(parentNode);
});
}
@@ -532,7 +531,7 @@ public static void createPrimaryIndex(String bucket, String scope, String collec
try {
ActiveCluster.getInstance().get().bucket(bucket).scope(scope).collection(collection).queryIndexes().createPrimaryIndex();
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("The primary index for the collection " + bucket + "." + scope + "." + collection + " was created successfully.", "Primary Index Creation"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("The primary index for the collection " + bucket + "." + scope + "." + collection + " was created successfully.", "Primary Index Creation"));
} catch (Exception e) {
Log.error(e);
e.printStackTrace();
@@ -563,7 +562,7 @@ public static void listIndexes(DefaultMutableTreeNode parentNode, Tree tree) {
} else {
parentNode.add(new DefaultMutableTreeNode(new NoResultsNodeDescriptor()));
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
tree.setPaintBusy(false);
});
diff --git a/src/main/java/com/couchbase/intellij/persistence/CouchbaseDocumentVirtualFile.java b/src/main/java/com/couchbase/intellij/persistence/CouchbaseDocumentVirtualFile.java
index 8ca53dc7..de48d659 100644
--- a/src/main/java/com/couchbase/intellij/persistence/CouchbaseDocumentVirtualFile.java
+++ b/src/main/java/com/couchbase/intellij/persistence/CouchbaseDocumentVirtualFile.java
@@ -4,6 +4,7 @@
import com.couchbase.client.java.kv.GetResult;
import com.couchbase.intellij.database.ActiveCluster;
import com.intellij.json.JsonFileType;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
@@ -13,7 +14,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
import java.io.*;
import java.util.Objects;
@@ -179,7 +179,7 @@ public void refresh(boolean asynchronous, boolean recursive, @Nullable Runnable
};
if (asynchronous) {
- SwingUtilities.invokeLater(refresh);
+ ApplicationManager.getApplication().invokeLater(refresh);
} else {
refresh.run();
}
diff --git a/src/main/java/com/couchbase/intellij/tools/DDLExport.java b/src/main/java/com/couchbase/intellij/tools/DDLExport.java
index f1306cec..de8e8696 100644
--- a/src/main/java/com/couchbase/intellij/tools/DDLExport.java
+++ b/src/main/java/com/couchbase/intellij/tools/DDLExport.java
@@ -6,6 +6,7 @@
import com.couchbase.intellij.database.ActiveCluster;
import com.couchbase.intellij.database.DataLoader;
import com.couchbase.intellij.workbench.Log;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
@@ -14,7 +15,6 @@
import utils.IndexUtils;
import utils.TimeUtils;
-import javax.swing.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -100,7 +100,7 @@ public void run(@NotNull ProgressIndicator indicator) {
Log.info("DDL file " + fullPath + " was exported successfully.");
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("File exported successfully.", "DDL Export"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("File exported successfully.", "DDL Export"));
} catch (Exception e) {
Log.error("An error occurred while writing to export the DDL: ", e);
diff --git a/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java b/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java
index 5c62b796..5917caf2 100644
--- a/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java
+++ b/src/main/java/com/couchbase/intellij/tools/cbmigrate/MigrationDialog.java
@@ -479,7 +479,7 @@ public void mouseEntered(MouseEvent e) {
}
public void tryToConnectToMongo(String mongoDBUri, JLabel errorLabel, Consumer> callback) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
try {
List databases = MongoConnection.testConnection(mongoDBUri);
@@ -500,7 +500,7 @@ public void tryToConnectToMongo(String mongoDBUri, JLabel errorLabel, Consumer> callback) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
try {
mongoConnection = new MongoConnection(mongoDBUri);
List databases = mongoConnection.listDatabases();
diff --git a/src/main/java/com/couchbase/intellij/tools/dialog/ImportDialog.java b/src/main/java/com/couchbase/intellij/tools/dialog/ImportDialog.java
index 0060598c..f3e7e9b4 100644
--- a/src/main/java/com/couchbase/intellij/tools/dialog/ImportDialog.java
+++ b/src/main/java/com/couchbase/intellij/tools/dialog/ImportDialog.java
@@ -11,6 +11,7 @@
import com.couchbase.intellij.tree.docfilter.DocumentFilterDialog;
import com.couchbase.intellij.workbench.Log;
import com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
@@ -1244,7 +1245,7 @@ protected void readJsonOrCsvFile() {
if (!isJsonArray) {
boolean isLines = sampleJSONLines(datasetPath);
if (!isLines) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("Your dateset is not in a JSON Array or JSON lines format", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("Your dateset is not in a JSON Array or JSON lines format", "Couchbase Plugin Error"));
}
}
} else if (datasetPath.endsWith(CSV_FILE_EXTENSION)) {
diff --git a/src/main/java/com/couchbase/intellij/tree/CouchbaseWindowContent.java b/src/main/java/com/couchbase/intellij/tree/CouchbaseWindowContent.java
index dced8374..a8ddea09 100644
--- a/src/main/java/com/couchbase/intellij/tree/CouchbaseWindowContent.java
+++ b/src/main/java/com/couchbase/intellij/tree/CouchbaseWindowContent.java
@@ -5,6 +5,7 @@
import com.couchbase.intellij.persistence.SavedCluster;
import com.couchbase.intellij.tree.node.*;
import com.couchbase.intellij.workbench.Log;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
@@ -171,7 +172,7 @@ public void treeCollapsed(TreeExpansionEvent event) {
});
if (DataLoader.getSavedClusters() == null || DataLoader.getSavedClusters().isEmpty()) {
Timer timer = new Timer(10000, e -> {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
try {
toolBarBuilder.showGotItTooltip();
} catch (Exception ex) {
diff --git a/src/main/java/com/couchbase/intellij/tree/NewBucketCreationDialog.java b/src/main/java/com/couchbase/intellij/tree/NewBucketCreationDialog.java
index 165c8a4d..ee9a7209 100644
--- a/src/main/java/com/couchbase/intellij/tree/NewBucketCreationDialog.java
+++ b/src/main/java/com/couchbase/intellij/tree/NewBucketCreationDialog.java
@@ -7,6 +7,7 @@
import com.couchbase.intellij.database.ActiveCluster;
import com.couchbase.intellij.tree.overview.apis.CouchbaseRestAPI;
import com.couchbase.intellij.tree.overview.apis.ServerOverview;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.DialogWrapper;
@@ -470,7 +471,7 @@ private void readClusterInformation() {
}
this.pack();
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
int locLeft = (int) Math.max(1, (Toolkit.getDefaultToolkit().getScreenSize().getWidth()) / 2 - getSize().getWidth() / 2);
int locTop = (int) Math.max(1, (Toolkit.getDefaultToolkit().getScreenSize().getHeight()) / 2 - getSize().getHeight() / 2);
diff --git a/src/main/java/com/couchbase/intellij/tree/NewConnectionDialog.java b/src/main/java/com/couchbase/intellij/tree/NewConnectionDialog.java
index 7483a36d..7e6a1b7d 100644
--- a/src/main/java/com/couchbase/intellij/tree/NewConnectionDialog.java
+++ b/src/main/java/com/couchbase/intellij/tree/NewConnectionDialog.java
@@ -11,6 +11,7 @@
import com.couchbase.intellij.tree.node.ConnectionNodeDescriptor;
import com.couchbase.intellij.tree.overview.NewConnectionBanner;
import com.couchbase.intellij.workbench.Log;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.IconLoader;
@@ -151,7 +152,7 @@ private void handleSaveConnection() {
return;
}
messageLabel.setText("Trying to Connect...");
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
try {
if (!hasCorrectBucketConnection()) {
messageLabel.setText("");
@@ -209,7 +210,7 @@ private void handleTestConnection() {
testConnectionButton.setEnabled(false);
messageLabel.setText("Trying to Connect...");
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (!defaultBucketTextField.getText().trim().isEmpty()) {
consoleScrollPane.setVisible(true);
thirdPanel.revalidate();
diff --git a/src/main/java/com/couchbase/intellij/tree/TreeActionHandler.java b/src/main/java/com/couchbase/intellij/tree/TreeActionHandler.java
index cb0f5f74..390956e4 100644
--- a/src/main/java/com/couchbase/intellij/tree/TreeActionHandler.java
+++ b/src/main/java/com/couchbase/intellij/tree/TreeActionHandler.java
@@ -6,6 +6,7 @@
import com.couchbase.intellij.tree.node.ConnectionNodeDescriptor;
import com.couchbase.intellij.tree.node.LoadingNodeDescriptor;
import com.couchbase.intellij.workbench.Log;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.ui.treeStructure.Tree;
@@ -29,7 +30,7 @@ public static void connectToCluster(Project project, SavedCluster savedCluster,
public static void connectToCluster(Project project, SavedCluster savedCluster, Tree tree, JPanel toolBarPanel, Consumer connectionListener, Runnable disconnectListener) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
tree.setPaintBusy(true);
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
Enumeration children = selectedNode.children();
@@ -75,7 +76,7 @@ public static void connectToCluster(Project project, SavedCluster savedCluster,
if (toolBarPanel != null) {
if (ActiveCluster.getInstance().getColor() != null) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (ActiveCluster.getInstance().getColor() != null) {
Border line = BorderFactory.createMatteBorder(0, 0, 1, 0, ActiveCluster.getInstance().getColor());
Border margin = BorderFactory.createEmptyBorder(0, 0, 1, 0); // Top, left, bottom, right margins
@@ -85,7 +86,7 @@ public static void connectToCluster(Project project, SavedCluster savedCluster,
}
});
} else {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
toolBarPanel.setBorder(JBUI.Borders.empty());
toolBarPanel.revalidate();
});
@@ -96,11 +97,11 @@ public static void connectToCluster(Project project, SavedCluster savedCluster,
if (!CBConfigUtil.isSupported(ActiveCluster.getInstance().getVersion())) {
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("This plugin doesn't work with versions bellow Couchbase 7.0", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("This plugin doesn't work with versions bellow Couchbase 7.0", "Couchbase Plugin Error"));
}
if (!CBConfigUtil.hasQueryService(ActiveCluster.getInstance().getServices())) {
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Your cluster doesn't have the Query Service. Some features might not work properly.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Your cluster doesn't have the Query Service. Some features might not work properly.", "Couchbase Plugin Error"));
}
} catch (Exception e) {
e.printStackTrace();
@@ -131,7 +132,7 @@ public static void connectToCluster(Project project, SavedCluster savedCluster,
} catch (Exception e) {
tree.setPaintBusy(false);
e.printStackTrace();
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not connect to the cluster. Please check your network connectivity, " +
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not connect to the cluster. Please check your network connectivity, " +
" if the cluster is active or if the credentials are still valid.", "Couchbase Connection Error"));
if (connectionListener != null) {
connectionListener.consume(e);
diff --git a/src/main/java/com/couchbase/intellij/tree/TreeRightClickListener.java b/src/main/java/com/couchbase/intellij/tree/TreeRightClickListener.java
index 6cfee645..db23f073 100644
--- a/src/main/java/com/couchbase/intellij/tree/TreeRightClickListener.java
+++ b/src/main/java/com/couchbase/intellij/tree/TreeRightClickListener.java
@@ -26,6 +26,7 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileChooser.*;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.fileTypes.FileTypeManager;
@@ -270,7 +271,7 @@ public void closed(@Nullable Color color) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
ActiveCluster.getInstance().setReadOnlyMode(true);
- SwingUtilities.invokeLater(() -> Messages.showWarningDialog("The Read Only Mode is a simple guardrail in the plugin to avoid unwanted changes in sensible environments. Please note that this is a best effort approach. For true read-only approach, connect to the cluster using read-only credentials.", "Couchbase Plugin Warning"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showWarningDialog("The Read Only Mode is a simple guardrail in the plugin to avoid unwanted changes in sensible environments. Please note that this is a best effort approach. For true read-only approach, connect to the cluster using read-only credentials.", "Couchbase Plugin Warning"));
}
};
@@ -421,7 +422,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
tree.collapsePath(treePath.getParentPath());
tree.expandPath(treePath.getParentPath());
} catch (Exception ex) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("An error occurred while creating the bucket. Check the Log tab for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("An error occurred while creating the bucket. Check the Log tab for more.", "Couchbase Plugin Error"));
Log.error("Bucket deletion failed ", ex);
}
}
diff --git a/src/main/java/com/couchbase/intellij/tree/TreeToolBarBuilder.java b/src/main/java/com/couchbase/intellij/tree/TreeToolBarBuilder.java
index 143f58c7..ac2606b8 100644
--- a/src/main/java/com/couchbase/intellij/tree/TreeToolBarBuilder.java
+++ b/src/main/java/com/couchbase/intellij/tree/TreeToolBarBuilder.java
@@ -159,7 +159,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
toolBarPanel.add(rightActionToolbar.getComponent(), BorderLayout.EAST);
ActiveCluster.getInstance().registerNewConnectionListener(() -> {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
leftActionToolbar.updateActionsImmediately();
toolBarPanel.revalidate();
});
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/CBLDataLoader.java b/src/main/java/com/couchbase/intellij/tree/cblite/CBLDataLoader.java
index 39ccc14a..ad268216 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/CBLDataLoader.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/CBLDataLoader.java
@@ -14,7 +14,6 @@
import com.intellij.ui.treeStructure.Tree;
import org.json.JSONObject;
-import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import java.util.Date;
@@ -92,7 +91,7 @@ public static void setDocumentExpiration(String scope, String collection, String
col.setDocumentExpiration(docId, date);
} catch (Exception e) {
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("An error ocurred while setting the expiration date for the document " + docId + ". Check the logs for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("An error ocurred while setting the expiration date for the document " + docId + ". Check the logs for more.", "Couchbase Plugin Error"));
Log.error("Failed to set the expiration for document " + docId, e);
}
@@ -261,7 +260,7 @@ public static void listBlobs(DefaultMutableTreeNode documentNode, Tree tree) {
Map blobs = CBLBlobHandler.getDocumentBlobsWithNames(document);
// Once the blobs are loaded, update the tree on the Swing event dispatch thread
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
documentNode.removeAllChildren();
for (Map.Entry entry : blobs.entrySet()) {
DefaultMutableTreeNode blobNode = new DefaultMutableTreeNode(new CBLBlobNodeDescriptor(entry.getValue(), entry.getKey(), fileNode.getScope(), fileNode.getCollection(), fileNode.getId()));
@@ -271,7 +270,7 @@ public static void listBlobs(DefaultMutableTreeNode documentNode, Tree tree) {
});
} catch (Exception e) {
Log.error("An error occurred while trying to load the blobs", e);
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("Could not load the blobs for the document " + documentNode.getUserObject() + ". Please check the log for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("Could not load the blobs for the document " + documentNode.getUserObject() + ". Please check the log for more.", "Couchbase Plugin Error"));
} finally {
tree.setPaintBusy(false);
}
@@ -304,7 +303,7 @@ public static void loadDocument(Project project, CBLFileNodeDescriptor node, Tre
} catch (CouchbaseLiteException e) {
Log.error("Could not load the document " + node.getId() + ".", e);
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
tree.setPaintBusy(false);
return;
}
@@ -323,7 +322,7 @@ public static void loadDocument(Project project, CBLFileNodeDescriptor node, Tre
});
} catch (Exception e) {
Log.error("An error occurred while trying to load the file", e);
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("Could not load the document " + node.getId() + ". Please check the log for more.", "Couchbase Plugin Error"));
} finally {
tree.setPaintBusy(false);
}
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/CBLDocumentVirtualFile.java b/src/main/java/com/couchbase/intellij/tree/cblite/CBLDocumentVirtualFile.java
index 9ab9d5fc..0dcb7303 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/CBLDocumentVirtualFile.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/CBLDocumentVirtualFile.java
@@ -5,6 +5,7 @@
import com.couchbase.intellij.workbench.Log;
import com.couchbase.lite.Document;
import com.intellij.json.JsonFileType;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.NlsSafe;
@@ -14,7 +15,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import javax.swing.*;
import java.io.*;
import java.util.Objects;
@@ -173,7 +173,7 @@ public void refresh(boolean asynchronous, boolean recursive, @Nullable Runnable
};
if (asynchronous) {
- SwingUtilities.invokeLater(refresh);
+ ApplicationManager.getApplication().invokeLater(refresh);
} else {
refresh.run();
}
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeHandler.java b/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeHandler.java
index d5a47267..a861fcc5 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeHandler.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeHandler.java
@@ -4,11 +4,11 @@
import com.couchbase.intellij.tree.cblite.storage.SavedCBLDatabase;
import com.couchbase.intellij.workbench.Log;
import com.couchbase.lite.CouchbaseLiteException;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.ui.treeStructure.Tree;
-import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
@@ -27,7 +27,7 @@ public static void disconnectFromCluster(DefaultMutableTreeNode node, CBLDatabas
}
public static void connectToDatabase(Project project, SavedCBLDatabase savedDatabase, Tree tree) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
tree.setPaintBusy(true);
DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) tree.getModel().getRoot();
Enumeration children = rootNode.children();
@@ -73,7 +73,7 @@ public static void connectToDatabase(Project project, SavedCBLDatabase savedData
} catch (Exception e) {
Log.error(e);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not connect to the specified database.", "Couchbase Connection Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not connect to the specified database.", "Couchbase Connection Error"));
((CBLDatabaseNodeDescriptor) newActiveNode.getUserObject()).setActive(false);
((DefaultTreeModel) tree.getModel()).reload();
} finally {
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeRightClickListener.java b/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeRightClickListener.java
index 380bca82..a619e46d 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeRightClickListener.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/CBLTreeRightClickListener.java
@@ -29,7 +29,6 @@
import com.intellij.ui.treeStructure.Tree;
import org.jetbrains.annotations.NotNull;
-import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
@@ -120,7 +119,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
CBLTreeHandler.disconnectFromCluster(clickedNode, userObject, tree);
} catch (CouchbaseLiteException ex) {
Log.error(ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not disconnect from the database.", "Couchbase Lite Connection Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not disconnect from the database.", "Couchbase Lite Connection Error"));
}
}
};
@@ -136,7 +135,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(clickedNode);
} catch (Exception ex) {
Log.error(ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not create the collection.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not create the collection.", COUCHBASE_LITE_PLUGIN_ERROR));
}
}
};
@@ -171,7 +170,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
CBLTreeHandler.deleteConnection(clickedNode, userObject, tree);
} catch (CouchbaseLiteException ex) {
Log.error(ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the connection.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the connection.", COUCHBASE_LITE_PLUGIN_ERROR));
}
}
};
@@ -214,7 +213,7 @@ public void run(@NotNull ProgressIndicator indicator) {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(parentNode);
} catch (Exception ex) {
Log.error(ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the scope.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the scope.", COUCHBASE_LITE_PLUGIN_ERROR));
}
}
};
@@ -269,7 +268,7 @@ public void run(@NotNull ProgressIndicator indicator) {
}
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) clickedNode.getParent();
Scope scope = ActiveCBLDatabase.getInstance().getDatabase().getScope(userObject.getScope());
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
((DefaultTreeModel) tree.getModel()).removeNodeFromParent(clickedNode);
// If the scope has no collections after deleting the collection, remove the
// scope
@@ -285,12 +284,12 @@ public void run(@NotNull ProgressIndicator indicator) {
}
} catch (CouchbaseLiteException e) {
Log.error(e);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the scope after deleting the collection.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the scope after deleting the collection.", COUCHBASE_LITE_PLUGIN_ERROR));
}
});
} catch (Exception ex) {
Log.error(ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the collection.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the collection.", COUCHBASE_LITE_PLUGIN_ERROR));
}
}
};
@@ -354,7 +353,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}
} catch (Exception ex) {
Log.error("An error occurred while trying to attach a blob to the document " + userObject.getId(), ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not attach the blob. Please check the logs for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not attach the blob. Please check the logs for more.", "Couchbase Plugin Error"));
}
}
};
@@ -386,7 +385,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
ActiveCBLDatabase.getInstance().getDatabase().getScope(userObject.getScope()).getCollection(userObject.getCollection()).delete(document);
DefaultMutableTreeNode parentNode = (DefaultMutableTreeNode) clickedNode.getParent();
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (parentNode != null) {
((DefaultTreeModel) tree.getModel()).removeNodeFromParent(clickedNode);
}
@@ -394,7 +393,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
});
} catch (Exception ex) {
Log.error("An error occurred while trying to delete the document " + userObject.getId(), ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the document. Please check the logs for more.", "Couchbase Plugin Error"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the document. Please check the logs for more.", "Couchbase Plugin Error"));
}
}
};
@@ -436,7 +435,7 @@ public void run(@NotNull ProgressIndicator indicator) {
ActiveCBLDatabase.getInstance().getDatabase().performMaintenance(MaintenanceType.COMPACT);
} catch (Exception ex) {
Log.error("An error occurred while trying to delete the blob " + userObject.getDigest(), ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the blob. Please check the logs for more.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the blob. Please check the logs for more.", COUCHBASE_LITE_PLUGIN_ERROR));
}
}
};
@@ -445,7 +444,7 @@ public void run(@NotNull ProgressIndicator indicator) {
((DefaultTreeModel) tree.getModel()).nodeStructureChanged(grandParentNode);
} catch (Exception ex) {
Log.error("An error occurred while trying to delete the blob " + userObject.getDigest(), ex);
- SwingUtilities.invokeLater(() -> Messages.showErrorDialog("Could not delete the blob. Please check the logs for more.", COUCHBASE_LITE_PLUGIN_ERROR));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog("Could not delete the blob. Please check the logs for more.", COUCHBASE_LITE_PLUGIN_ERROR));
}
}
};
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/CBLWindowContent.java b/src/main/java/com/couchbase/intellij/tree/cblite/CBLWindowContent.java
index 85c5c84e..fbf723f6 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/CBLWindowContent.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/CBLWindowContent.java
@@ -230,7 +230,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
public void actionPerformed(@NotNull AnActionEvent e) {
if (ActiveCBLDatabase.getInstance().getDatabase() == null) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
return;
}
new Task.ConditionalModal(project, String.format("Running Database Optimize for ",
@@ -256,7 +256,7 @@ public void run(@NotNull ProgressIndicator indicator) {
public void actionPerformed(@NotNull AnActionEvent e) {
if (ActiveCBLDatabase.getInstance().getDatabase() == null) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
return;
}
new Task.ConditionalModal(project, String.format("Running Database Full Optimize for ",
@@ -281,7 +281,7 @@ public void run(@NotNull ProgressIndicator indicator) {
public void actionPerformed(@NotNull AnActionEvent e) {
if (ActiveCBLDatabase.getInstance().getDatabase() == null) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
return;
}
new Task.ConditionalModal(project, String.format("Running Database Compact for ",
@@ -305,7 +305,7 @@ public void run(@NotNull ProgressIndicator indicator) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
if (ActiveCBLDatabase.getInstance().getDatabase() == null) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
return;
}
new Task.ConditionalModal(project, String.format("Running Database Integrity Check for ",
@@ -329,7 +329,7 @@ public void run(@NotNull ProgressIndicator indicator) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
if (ActiveCBLDatabase.getInstance().getDatabase() == null) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("You need to connect to a database before running this task", "Couchbase Plugin"));
return;
}
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/sqlppl/SQLLiteQueryExecutor.java b/src/main/java/com/couchbase/intellij/tree/cblite/sqlppl/SQLLiteQueryExecutor.java
index 9efcefa8..354004e2 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/sqlppl/SQLLiteQueryExecutor.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/sqlppl/SQLLiteQueryExecutor.java
@@ -14,7 +14,6 @@
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowManager;
-import javax.swing.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -27,7 +26,7 @@ public class SQLLiteQueryExecutor {
public static void runQuery(String query, int historyIndex, Project project) {
if (ActiveCBLDatabase.getInstance().getDatabase() == null) {
- SwingUtilities.invokeLater(() -> Messages.showInfoMessage("There is no active Couchbase Lite connection to execute this query.", "Couchbase Plugin"));
+ ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage("There is no active Couchbase Lite connection to execute this query.", "Couchbase Plugin"));
return;
}
@@ -70,7 +69,7 @@ private static QueryResultToolWindowFactory getOutputWindow(Project project) {
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
toolWindow = toolWindowManager.getToolWindow("Couchbase Output");
}
- SwingUtilities.invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> toolWindow.show()));
+ ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> toolWindow.show()));
if (resultWindow == null) {
resultWindow = QueryResultToolWindowFactory.instance;
diff --git a/src/main/java/com/couchbase/intellij/tree/cblite/sync/SyncGatewayTablePanel.java b/src/main/java/com/couchbase/intellij/tree/cblite/sync/SyncGatewayTablePanel.java
index 4886fbf5..7199bf15 100644
--- a/src/main/java/com/couchbase/intellij/tree/cblite/sync/SyncGatewayTablePanel.java
+++ b/src/main/java/com/couchbase/intellij/tree/cblite/sync/SyncGatewayTablePanel.java
@@ -2,6 +2,7 @@
import com.couchbase.intellij.workbench.Log;
import com.intellij.icons.AllIcons;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.ui.components.JBScrollPane;
@@ -315,7 +316,7 @@ public void actionPerformed(ActionEvent e) {
filters.collections.add(collectionCombo.getSelectedItem().toString());
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
table.getTableHeader().revalidate();
table.revalidate();
reapplyFilters();
@@ -358,7 +359,7 @@ private void handleScopeFilter(MouseEvent e) {
filters.scopes.add(scopeCombo.getSelectedItem().toString());
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
table.getTableHeader().revalidate();
table.revalidate();
reapplyFilters();
@@ -434,7 +435,7 @@ private void handleIdFilter(MouseEvent e, JPopupMenu filterPopup) {
}
private void hidePopup(JPopupMenu filterPopup) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
table.getTableHeader().revalidate();
table.revalidate();
reapplyFilters();
@@ -528,7 +529,7 @@ public void reapplyFilters() {
.filter(this::shouldShowOnTable)
.collect(Collectors.toList());
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
model.setItems(filtered);
model.fireTableDataChanged();
});
@@ -555,7 +556,7 @@ public void addEntry(JsonEntry entry) {
model.removeRow(0);
}
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (shouldShowOnTable(entry)) {
model.addRow(entry);
model.fireTableDataChanged();
@@ -573,7 +574,7 @@ public void clearTable() {
pullCountLabel.setText("0");
pushCountLabel.setText("0");
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
model.fireTableDataChanged();
pushCountLabel.revalidate();
pullCountLabel.revalidate();
@@ -618,7 +619,7 @@ static class SyncFilters {
public void updateSyncStatus(String text) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
syncStatus.setText(text);
syncStatus.revalidate();
});
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java b/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java
index 8807d90f..df43d37a 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/IQWindowContent.java
@@ -12,6 +12,7 @@
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
@@ -137,7 +138,7 @@ public void onOrgSelected(CapellaOrganization organization) {
}
this.removeAll();
this.updateUI();
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
IQStorage.getInstance().getState().setActiveOrganization(organization.getId());
final String iqUrl = String.format(IQ_URL.get(), organization.getId());
iqGptConfig = new OpenAISettingsState.OpenAIConfig();
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/chat/ChatGptHandler.java b/src/main/java/com/couchbase/intellij/tree/iq/chat/ChatGptHandler.java
index d2cd37ab..ede1a979 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/chat/ChatGptHandler.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/chat/ChatGptHandler.java
@@ -1,6 +1,7 @@
package com.couchbase.intellij.tree.iq.chat;
import com.couchbase.intellij.tree.iq.OpenAIServiceHolder;
+import com.intellij.openapi.application.ApplicationManager;
import com.theokanning.openai.completion.chat.*;
import io.reactivex.Flowable;
import io.reactivex.functions.Action;
@@ -8,7 +9,6 @@
import org.apache.commons.lang3.StringUtils;
import org.reactivestreams.Subscription;
-import javax.swing.SwingUtilities;
import java.util.*;
public class ChatGptHandler {
@@ -45,13 +45,13 @@ public ChatCompletionHandler(ChatMessageListener listener) {
public Consumer onSubscribe(ChatMessageEvent.Initiating event) {
return subscription -> {
- SwingUtilities.invokeLater(() -> listener.exchangeStarted(this.event = event.started(subscription)));
+ ApplicationManager.getApplication().invokeLater(() -> listener.exchangeStarted(this.event = event.started(subscription)));
};
}
public Action onComplete(ConversationContext ctx) {
return () -> {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
try {
final List assistantMessages = toMessages(partialResponseChoices);
if (!assistantMessages.isEmpty()) {
@@ -68,7 +68,7 @@ public Action onComplete(ConversationContext ctx) {
public Consumer onNextChunk() {
return chunk -> {
if (!chunk.getChoices().isEmpty()) {
- SwingUtilities.invokeLater(() -> listener.responseArriving(event.responseArriving(chunk, formResponse(chunk.getChoices()))));
+ ApplicationManager.getApplication().invokeLater(() -> listener.responseArriving(event.responseArriving(chunk, formResponse(chunk.getChoices()))));
}
};
}
@@ -76,7 +76,7 @@ public Consumer onNextChunk() {
public Consumer onNext() {
return result -> {
if (result != null && result.getChoices() != null && !result.getChoices().isEmpty()) {
- SwingUtilities.invokeLater(() -> listener.responseArrived(event.responseArrived(formResponse(result.getChoices()))));
+ ApplicationManager.getApplication().invokeLater(() -> listener.responseArrived(event.responseArrived(formResponse(result.getChoices()))));
}
};
}
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/ChatPanel.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/ChatPanel.java
index dd761305..61f722b3 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/ChatPanel.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/ChatPanel.java
@@ -38,10 +38,8 @@
import javax.swing.text.AbstractDocument;
import java.awt.*;
import java.awt.event.KeyEvent;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
import static java.awt.event.InputEvent.CTRL_DOWN_MASK;
import static org.apache.commons.lang3.StringUtils.isEmpty;
@@ -149,7 +147,7 @@ private int computeTokenCount(TextInputContextEntry info) {
tokenCount = getModelType().getTokenizer().encode(TextContent.toString(info.getTextContent().get())).size();
info.setTokenCount(tokenCount);
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
contextStack.getListModel().syncModel();
actionPanel.revalidate();
@@ -214,7 +212,7 @@ public void exchangeStarting(ChatMessageEvent.Starting event) throws ChatExchang
TextFragment userMessage = TextFragment.of(event.getUserMessage().getContent());
question = new MessageComponent(this, userMessage, null);
answer = new MessageComponent(this, TextFragment.of("Thinking..."), getModelType());
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
setSearchText("");
aroundRequest(true);
@@ -235,7 +233,7 @@ public void exchangeStarting(ChatMessageEvent.Starting event) throws ChatExchang
public void exchangeStarted(ChatMessageEvent.Started event) {
setRequestHolder(event.getSubscription());
- SwingUtilities.invokeLater(contentPanel::updateLayout);
+ ApplicationManager.getApplication().invokeLater(contentPanel::updateLayout);
}
protected boolean presetCheck() {
@@ -279,7 +277,7 @@ public void responseCompleted(ChatMessageEvent.ResponseArrived event) {
}
setContent(response);
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
aroundRequest(false);
});
}
@@ -316,7 +314,7 @@ public void exchangeFailed(ChatMessageEvent.Failed event) {
Log.debug("Received 401 error from Capella iQ");
if (messageRetryCount == 0) {
if (!logoutListener.onLogout(err)) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
messageRetryCount = 1;
contentPanel.removeLastMessage();
submitAction.submitPrompt(event.getUserMessage().getContent());
@@ -355,7 +353,7 @@ public void responseArrivalFailed(ChatMessageEvent.Failed event) {
return;
}
answer.setErrorContent("*Response failure*, cause: " + event.getCause().getMessage() + ", please try again.\n\n Tips: if proxy is enabled, please check if the proxy server is working.");
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
aroundRequest(false);
contentPanel.scrollToBottom();
});
@@ -402,7 +400,7 @@ public Dimension getPreferredSize() {
}
public void addMessageComponent(JBPanel> component) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
contentPanel.add(component);
lastChatComponent = component;
contentPanel.revalidate();
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/ExpandableTextFieldExt.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/ExpandableTextFieldExt.java
index dbfa5f95..96fb837a 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/ExpandableTextFieldExt.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/ExpandableTextFieldExt.java
@@ -1,6 +1,7 @@
package com.couchbase.intellij.tree.iq.ui;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.textarea.TextComponentEditor;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
@@ -237,7 +238,7 @@ protected void textChanged(@NotNull DocumentEvent e) {
String newText = e.getDocument().getText(e.getOffset(), e.getLength());
if (newText.indexOf(NEWLINE_REPLACEMENT) >= 0 && !StringUtils.containsOnly(newText, NEWLINE_REPLACEMENT)) {
if (!expandable.isExpanded())
- SwingUtilities.invokeLater(expandable::expand);
+ ApplicationManager.getApplication().invokeLater(expandable::expand);
}
} catch (BadLocationException ignored) {
}
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/LoginPanel.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/LoginPanel.java
index 90ae22c2..937eb3cb 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/LoginPanel.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/LoginPanel.java
@@ -1,9 +1,8 @@
package com.couchbase.intellij.tree.iq.ui;
import com.couchbase.intellij.tree.iq.core.IQCredentials;
-import com.intellij.credentialStore.Credentials;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.util.ui.JBUI;
-import kotlin.reflect.jvm.internal.impl.load.java.typeEnhancement.JavaTypeEnhancement;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
@@ -152,12 +151,12 @@ private JPanel createLoginForm(IQCredentials storedCredentials) {
JButton loginButton = new JButton("Sign in");
loginForm.add(loginButton, gbc);
loginButton.addActionListener(e -> {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
invalidLogin.setVisible(false);
loginButton.setEnabled(false);
loginButton.setText("Signing in...");
updateUI();
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (!doLogin(username.getText(), new String(password.getPassword()), saveLogin.isSelected())) {
loginButton.setText("Sign in");
loginButton.setEnabled(true);
@@ -183,7 +182,7 @@ private JPanel createLoginForm(IQCredentials storedCredentials) {
gbc.anchor = GridBagConstraints.SOUTHEAST;
gbc.fill = GridBagConstraints.NONE;
gbc.insets = JBUI.insets(5, 10, 20, 20);
- JEditorPane signupLink = new JEditorPane("text/html","Don't have an account yet?");
+ JEditorPane signupLink = new JEditorPane("text/html", "Don't have an account yet?");
signupLink.setEditable(false);
signupLink.setBackground(null);
signupLink.addHyperlinkListener(e -> {
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageComponent.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageComponent.java
index c3659a8b..517f2495 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageComponent.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageComponent.java
@@ -1,19 +1,19 @@
package com.couchbase.intellij.tree.iq.ui;
-import com.couchbase.client.java.json.JsonArray;
import com.couchbase.client.java.json.JsonObject;
import com.couchbase.intellij.persistence.storage.IQStorage;
-import com.couchbase.intellij.workbench.Log;
-import com.didalgo.gpt3.ModelType;
import com.couchbase.intellij.tree.iq.ChatGptBundle;
import com.couchbase.intellij.tree.iq.ChatGptIcons;
import com.couchbase.intellij.tree.iq.settings.OpenAISettingsState;
import com.couchbase.intellij.tree.iq.text.CodeSnippetManipulator;
import com.couchbase.intellij.tree.iq.text.TextFragment;
+import com.couchbase.intellij.workbench.Log;
+import com.didalgo.gpt3.ModelType;
import com.intellij.icons.AllIcons;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ide.CopyPasteManager;
import com.intellij.openapi.project.Project;
@@ -72,7 +72,7 @@ public class MessageComponent extends JBPanel implements ChatP
public MessageComponent(ChatPanel chat, TextFragment text, ModelType model) {
this.chat = chat;
this.text = text;
- this.component = new MessagePanel(chat.getProject());
+ this.component = new MessagePanel(chat.getProject());
var fromUser = (model == null);
if (!fromUser) {
if (chat.getQuestion() != null) {
@@ -136,7 +136,7 @@ public MessageComponent(ChatPanel chat, TextFragment text, ModelType model) {
@Override
public void mouseClicked(MouseEvent e) {
if (feedbackForm == null) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
feedbackThumbupAction.setIcon(getThumbUpInvertedIcon());
feedbackThumbdownAction.setEnabled(false);
feedbackThumbupAction.setCursor(Cursor.getDefaultCursor());
@@ -156,7 +156,7 @@ public void mouseClicked(MouseEvent e) {
@Override
public void mouseClicked(MouseEvent e) {
if (feedbackForm == null) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
feedbackThumbdownAction.setIcon(getThumbDownInvertedIcon());
feedbackThumbupAction.setEnabled(false);
feedbackThumbdownAction.setCursor(Cursor.getDefaultCursor());
@@ -183,7 +183,7 @@ public void mouseClicked(MouseEvent e) {
Notifications.Bus.notify(
new Notification(ChatGptBundle.message("group.id"),
"Copied successfully",
- "IQ " + (fromUser? "prompt":"reply") + " content has been successfully copied to the clipboard.",
+ "IQ " + (fromUser ? "prompt" : "reply") + " content has been successfully copied to the clipboard.",
NotificationType.INFORMATION));
}
});
@@ -223,6 +223,7 @@ private ImageIcon getThumbDownInvertedIcon() {
}
return thumbdownInverted;
}
+
private ImageIcon getThumbUpInvertedIcon() {
if (thumbupInverted == null) {
ImageIcon loaded = new ImageIcon(MessageComponent.class.getResource("/icons/thumbup_inverted.png"));
@@ -256,7 +257,8 @@ public String toDisplayText(TextFragment text, boolean fromUser) {
boolean onLineStart = true;
for (int i = 0; i < markdown.length(); i++) {
switch (ch = markdown.charAt(i)) {
- case '\r' -> { }
+ case '\r' -> {
+ }
case '\n' -> {
onLineStart = true;
buf.append("
");
@@ -298,7 +300,7 @@ public Component createContentComponent(@NotNull Project project, TextFragment c
if (fromUser)
editorKit.getStyleSheet().addRule("body {white-space:pre-wrap}");
component.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, getText().markdown());
- component.updateMessage(fromUser? TextFragment.of(content.markdown(), CodeSnippetManipulator.makeCodeSnippetBlocksCollapsible(toDisplayText(content, true))) : content);
+ component.updateMessage(fromUser ? TextFragment.of(content.markdown(), CodeSnippetManipulator.makeCodeSnippetBlocksCollapsible(toDisplayText(content, true))) : content);
component.setEditable(false);
if (component.getCaret() != null) {
component.setCaretPosition(0);
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java
index 8c5acf51..2e458662 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/MessageGroupComponent.java
@@ -15,6 +15,7 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.NullableComponent;
@@ -30,31 +31,21 @@
import com.intellij.util.ui.JBFont;
import com.intellij.util.ui.JBUI;
import com.intellij.util.ui.UIUtil;
-import com.thaiopensource.xml.dtd.om.Def;
-import lombok.Builder;
import org.jetbrains.annotations.NotNull;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JSeparator;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
import static com.couchbase.intellij.workbench.CustomSqlFileEditor.NO_QUERY_CONTEXT_SELECTED;
public class MessageGroupComponent extends JBPanel implements NullableComponent, SystemMessageHolder {
private final JPanel myList = new JPanel(new VerticalLayout(0));
private final JBScrollPane myScrollPane = new JBScrollPane(myList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
private final CapellaOrganization organization;
private final ChatPanel.OrganizationListener orgChangeListener;
private int myScrollValue = 0;
@@ -82,7 +73,7 @@ public MessageGroupComponent(ChatPanel chat, @NotNull Project project, CapellaOr
HideableTitledPanel cPanel = new HideableTitledPanel("Settings", false);
cPanel.setContentComponent(createSettingsPanel(organizationList, logoutListener));
cPanel.setOn(false);
- cPanel.setBorder(JBUI.Borders.empty(0,8,10,0));
+ cPanel.setBorder(JBUI.Borders.empty(0, 8, 10, 0));
add(cPanel, BorderLayout.NORTH);
add(mainPanel, BorderLayout.CENTER);
@@ -92,7 +83,7 @@ public MessageGroupComponent(ChatPanel chat, @NotNull Project project, CapellaOr
myTitle.setFont(JBFont.label());
JPanel panel = new JPanel(new BorderLayout());
- panel.setBorder(JBUI.Borders.empty(0,10,10,0));
+ panel.setBorder(JBUI.Borders.empty(0, 10, 10, 0));
panel.add(myTitle, BorderLayout.WEST);
@@ -181,7 +172,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
bucketActions.clear();
contextAction.removeAll();
- contextAction.getTemplatePresentation().setIcon(IconLoader.getIcon("/assets/icons/query_context.svg",MessageGroupComponent.class));
+ contextAction.getTemplatePresentation().setIcon(IconLoader.getIcon("/assets/icons/query_context.svg", MessageGroupComponent.class));
contextAction.addSeparator("Buckets");
activeCluster.getChildren().stream()
.sorted(Comparator.comparing(b -> b.getName().toLowerCase()))
@@ -211,7 +202,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}
private JPanel createSettingsPanel(CapellaOrganizationList organizationList, ChatPanel.LogoutListener logoutListener) {
- JPanel panel = new NonOpaquePanel(new GridLayout(0,1));
+ JPanel panel = new NonOpaquePanel(new GridLayout(0, 1));
JPanel orgPanel = new NonOpaquePanel(new BorderLayout());
orgSelector = new ComboBox<>(organizationList.getData().stream()
.map(org -> org.getData())
@@ -220,7 +211,7 @@ private JPanel createSettingsPanel(CapellaOrganizationList organizationList, Cha
.toArray(String[]::new));
orgSelector.setSelectedIndex(organizationList.indexOf(organization));
- orgSelector.addActionListener(e -> SwingUtilities.invokeLater(() -> {
+ orgSelector.addActionListener(e -> ApplicationManager.getApplication().invokeLater(() -> {
CapellaOrganization selectedOrg = organizationList.getData().get(orgSelector.getSelectedIndex()).getData();
if (selectedOrg != organization) {
orgChangeListener.onOrgSelected(selectedOrg);
@@ -233,7 +224,7 @@ private JPanel createSettingsPanel(CapellaOrganizationList organizationList, Cha
toolbarActions.add(new AnAction(() -> "Logout", AllIcons.Actions.Exit) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
logoutListener.onLogout(null);
});
}
@@ -244,10 +235,10 @@ public boolean displayTextInToolbar() {
}
});
- ActionToolbarImpl actonPanel = new ActionToolbarImpl("System Role Toolbar",toolbarActions,true);
+ ActionToolbarImpl actonPanel = new ActionToolbarImpl("System Role Toolbar", toolbarActions, true);
actonPanel.setTargetComponent(this);
panel.add(orgPanel);
- panel.setBorder(JBUI.Borders.empty(0,8,10,8));
+ panel.setBorder(JBUI.Borders.empty(0, 8, 10, 8));
JCheckBox enableTelemetry = new JCheckBox("Allow prompt and response collection to help make Capella iQ better.");
enableTelemetry.setSelected(IQStorage.getInstance().getState().isAllowTelemetry());
@@ -257,14 +248,14 @@ public boolean displayTextInToolbar() {
panel.add(enableTelemetry);
JPanel bottomPanel = new JPanel(new BorderLayout());
- bottomPanel.add(actonPanel,BorderLayout.EAST);
+ bottomPanel.add(actonPanel, BorderLayout.EAST);
panel.add(bottomPanel);
return panel;
}
public void addSeparator(JComponent comp) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
JSeparator separator = new JSeparator();
separator.setForeground(JBColor.border());
comp.add(separator);
@@ -289,7 +280,7 @@ protected MessageComponent createAssistantTips() {
var modelType = chat.getChatLink().getConversationContext().getModelType();
return new MessageComponent(chat, TextFragment.of("""
Hi, I'm your iQ-powered couchbase assistant. How can I assist you today?
-
+
Here are some suggestions to get you started:
[✦ What is Couchbase](assistant://?prompt=What+is+Couchbase)
[✦ How do I connect to Couchbase using Java SDK](assistant://?prompt=How+do+I+connect+to+Couchbase+using+Java+SDK)
@@ -298,7 +289,7 @@ protected MessageComponent createAssistantTips() {
}
public void add(JBPanel> messageComponent) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
myList.add(messageComponent);
updateLayout();
scrollToBottom();
@@ -335,7 +326,7 @@ protected void paintComponent(Graphics g) {
public boolean isVisible() {
if (super.isVisible()) {
int count = myList.getComponentCount();
- for (int i = 0 ; i < count ; i++) {
+ for (int i = 0; i < count; i++) {
if (myList.getComponent(i).isVisible()) {
return true;
}
@@ -355,7 +346,7 @@ public String getSystemMessage() {
}
public void removeLastMessage() {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
myList.remove(myList.getComponentCount() - 1);
myList.remove(myList.getComponentCount() - 1);
updateLayout();
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/action/editor/CustomPromptAction.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/action/editor/CustomPromptAction.java
index fbe85dfe..aef17cf8 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/action/editor/CustomPromptAction.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/action/editor/CustomPromptAction.java
@@ -8,6 +8,7 @@
import com.intellij.CommonBundle;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.*;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.event.DocumentEvent;
@@ -98,7 +99,7 @@ public CustomActionDialog(@Nullable Project project, CodeFragment selected, Stri
panel.setLayout(new VerticalLayout(JBUIScale.scale(8)));
panel.setBorder(JBUI.Borders.empty(10));
panel.add(createItemPanel());
- SwingUtilities.invokeLater(question::requestFocusInWindow);
+ ApplicationManager.getApplication().invokeLater(question::requestFocusInWindow);
return panel;
}
@@ -141,8 +142,8 @@ private JPanel createItemPanel() {
JPanel codePanel = new NonOpaquePanel(new BorderLayout());
JBLabel codeLabel = new JBLabel("Code block:");
- codeLabel.setBorder(JBUI.Borders.empty(10,0,5,0));
- codePanel.add(codeLabel,BorderLayout.NORTH);
+ codeLabel.setBorder(JBUI.Borders.empty(10, 0, 5, 0));
+ codePanel.add(codeLabel, BorderLayout.NORTH);
editorFactory = EditorFactory.getInstance();
FileType fileType = FileTypeManager.getInstance().getFileTypeByExtension(fileExtension);
LightVirtualFile virtualFile = new LightVirtualFile(UUID.randomUUID() + "." + fileExtension, selected.content());
@@ -157,11 +158,11 @@ public void documentChanged(@NotNull DocumentEvent event) {
}
});
- String originalGroupId = ((EditorEx)this.editor).getContextMenuGroupId();
+ String originalGroupId = ((EditorEx) this.editor).getContextMenuGroupId();
AnAction originalGroup = (originalGroupId == null) ? null : ActionManager.getInstance().getAction(originalGroupId);
DefaultActionGroup group = new DefaultActionGroup();
if (originalGroup instanceof ActionGroup)
- group.addAll(((ActionGroup)originalGroup).getChildren(null));
+ group.addAll(((ActionGroup) originalGroup).getChildren(null));
EditorEx editorEx = (EditorEx) editor;
editorEx.installPopupHandler(new ContextMenuPopupHandler.Simple(group));
@@ -176,7 +177,7 @@ public void documentChanged(@NotNull DocumentEvent event) {
editorSettings.setAdditionalLinesCount(3);
editorSettings.setCaretRowShown(true);
editorSettings.setAnimatedScrolling(true);
- codePanel.setPreferredSize(new Dimension(600,400));
+ codePanel.setPreferredSize(new Dimension(600, 400));
codePanel.add(editor.getComponent(), BorderLayout.CENTER);
basePanel.add(codePanel, BorderLayout.CENTER);
@@ -186,7 +187,7 @@ public void documentChanged(@NotNull DocumentEvent event) {
prefixPanel.add(prefixLabel, BorderLayout.NORTH);
question.getEmptyText().setText("Type your prompt here");
prefixPanel.add(question, BorderLayout.CENTER);
- prefixPanel.setBorder(JBUI.Borders.empty(5,0));
+ prefixPanel.setBorder(JBUI.Borders.empty(5, 0));
basePanel.add(prefixPanel, BorderLayout.SOUTH);
return basePanel;
@@ -207,7 +208,7 @@ protected void doAction(ActionEvent e) {
@Override
public Action @NotNull [] getOptions() {
- return new Action[] { new SendAndSaveAction() };
+ return new Action[]{new SendAndSaveAction()};
}
}
diff --git a/src/main/java/com/couchbase/intellij/tree/iq/ui/view/RSyntaxTextAreaView.java b/src/main/java/com/couchbase/intellij/tree/iq/ui/view/RSyntaxTextAreaView.java
index 04f87d1a..f566ce42 100644
--- a/src/main/java/com/couchbase/intellij/tree/iq/ui/view/RSyntaxTextAreaView.java
+++ b/src/main/java/com/couchbase/intellij/tree/iq/ui/view/RSyntaxTextAreaView.java
@@ -1,8 +1,6 @@
package com.couchbase.intellij.tree.iq.ui.view;
-import com.couchbase.intellij.database.ActiveCluster;
import com.couchbase.intellij.database.QueryContext;
-import com.couchbase.intellij.persistence.storage.QueryHistoryStorage;
import com.couchbase.intellij.tree.iq.ChatGptBundle;
import com.couchbase.intellij.tree.iq.IQWindowContent;
import com.couchbase.intellij.tree.iq.ui.view.rsyntaxtextarea.RSyntaxTextAreaUIEx;
@@ -15,6 +13,7 @@
import com.intellij.notification.Notifications;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.impl.ActionButton;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.WriteCommandAction;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
@@ -56,7 +55,6 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
-import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.stream.Collectors;
@@ -113,7 +111,7 @@ public String getText() throws BadLocationException {
var element = getElement();
var text = getDocument().getText(element.getStartOffset(), element.getEndOffset() - element.getStartOffset());
if (text.endsWith("\n"))
- text = text.substring(0, text.length() + (text.endsWith("\r\n")? -2: -1));
+ text = text.substring(0, text.length() + (text.endsWith("\r\n") ? -2 : -1));
//text = Escaping.unescapeHtml(text);
return text;
@@ -188,7 +186,7 @@ public Dimension getPreferredSize() {
ActionGroup actionGroup = new ActionGroup() {
@Override
public AnAction @NotNull [] getChildren(@Nullable AnActionEvent e) {
- return new AnAction[] { new MyCopyAction(icon1) };
+ return new AnAction[]{new MyCopyAction(icon1)};
}
};
@@ -277,7 +275,7 @@ protected JTextArea getTextArea(AnActionEvent event) {
protected String getTextContent(JTextArea textArea) {
String selectedText = textArea.getSelectedText();
- return (selectedText == null || selectedText.isEmpty())? textArea.getText() : selectedText;
+ return (selectedText == null || selectedText.isEmpty()) ? textArea.getText() : selectedText;
}
}
@@ -300,6 +298,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
private static class MyRunSqlAction extends RSyntaxTextAreaAction {
private Project project;
+
MyRunSqlAction(Project project, Icon icon) {
super("Run SQL code", "Run SQL code on the cluster", icon);
this.project = project;
@@ -330,7 +329,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
new Task.ConditionalModal(null, "Running SQL++ query", true, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (script.size() > 1) {
QueryExecutor.executeScript(new LinkedBlockingQueue<>(), NORMAL, context, script, 0, project);
} else {
@@ -382,9 +381,9 @@ public void actionPerformed(@NotNull AnActionEvent e) {
if (textEditors.size() > 1) {
JBPopupFactory.getInstance().createActionGroupPopup(ChatGptBundle.message("popup.title.paste.target"),
- new PasteTargetGroup(textEditors, targetText), e.getDataContext(),
- JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false)
- .showUnderneathOf(e.getInputEvent().getComponent());
+ new PasteTargetGroup(textEditors, targetText), e.getDataContext(),
+ JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false)
+ .showUnderneathOf(e.getInputEvent().getComponent());
return;
}
diff --git a/src/main/java/com/couchbase/intellij/workbench/CustomSqlFileEditor.java b/src/main/java/com/couchbase/intellij/workbench/CustomSqlFileEditor.java
index 465becd4..f91b9969 100644
--- a/src/main/java/com/couchbase/intellij/workbench/CustomSqlFileEditor.java
+++ b/src/main/java/com/couchbase/intellij/workbench/CustomSqlFileEditor.java
@@ -178,7 +178,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
boolean query = false;
boolean script = false;
QueryContext context = ActiveCluster.getInstance().getQueryContext().getValue();
@@ -195,7 +195,7 @@ public void run(@NotNull ProgressIndicator indicator) {
if (query || script) {
int historySize = QueryHistoryStorage.getInstance().getValue().getHistory().size();
currentHistoryIndex = historySize - 1;
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
historyLabel.setText("history (" + historySize + "/" + historySize + ")");
historyLabel.revalidate();
});
@@ -221,7 +221,7 @@ public void run(@NotNull ProgressIndicator indicator) {
executeGroup.add(new AnAction("Advise", "Get index recommendations about focused query", adviseIcon) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (!isSameConnection()) {
return;
}
@@ -236,7 +236,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
executeGroup.add(new AnAction("Explain", "Explains query phases for focused statement", explainIcon) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (!isSameConnection()) {
return;
}
@@ -284,7 +284,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
ApplicationManager.getApplication().runWriteAction(() -> queryEditor.getDocument().setText(QueryHistoryStorage.getInstance().getValue().getHistory().get(currentHistoryIndex)));
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
historyLabel.setText("history (" + (currentHistoryIndex + 1) + "/" + QueryHistoryStorage.getInstance().getValue().getHistory().size() + ")");
historyLabel.revalidate();
});
@@ -302,7 +302,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
ApplicationManager.getApplication().runWriteAction(() -> queryEditor.getDocument().setText(QueryHistoryStorage.getInstance().getValue().getHistory().get(currentHistoryIndex)));
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
historyLabel.setText("history (" + (currentHistoryIndex + 1) + "/" + QueryHistoryStorage.getInstance().getValue().getHistory().size() + ")");
historyLabel.revalidate();
});
@@ -495,7 +495,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
ActiveCluster.subscribe(activeCluster -> {
activeCluster.getQueryContext().subscribe(this, queryContext -> {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (queryContext.isPresent()) {
contextLabel.setText(String.format("%s > %s", queryContext.get().getBucket(), queryContext.get().getScope()));
contextLabel.revalidate();
diff --git a/src/main/java/com/couchbase/intellij/workbench/NewFavoriteCatalog.java b/src/main/java/com/couchbase/intellij/workbench/NewFavoriteCatalog.java
index 4353097e..4a5d9b09 100644
--- a/src/main/java/com/couchbase/intellij/workbench/NewFavoriteCatalog.java
+++ b/src/main/java/com/couchbase/intellij/workbench/NewFavoriteCatalog.java
@@ -7,6 +7,7 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.event.DocumentEvent;
import com.intellij.openapi.editor.event.DocumentListener;
@@ -89,7 +90,7 @@ protected void doOKAction() {
FavoriteQueryStorage.getInstance().getValue().getList().add(new FavoriteQuery(textField.getText(),
document.getText()));
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
AnAction updatedAction = new AnAction("Favorite Query", "Favorite query", IconLoader.getIcon("/assets/icons/star-filled.svg", NewFavoriteCatalog.class)) {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
diff --git a/src/main/java/com/couchbase/intellij/workbench/QueryExecutor.java b/src/main/java/com/couchbase/intellij/workbench/QueryExecutor.java
index bb0e5493..b2b51b12 100644
--- a/src/main/java/com/couchbase/intellij/workbench/QueryExecutor.java
+++ b/src/main/java/com/couchbase/intellij/workbench/QueryExecutor.java
@@ -21,7 +21,6 @@
import com.intellij.openapi.wm.ToolWindowManager;
import reactor.core.publisher.Mono;
-import javax.swing.*;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.time.Duration;
@@ -45,7 +44,7 @@ private static QueryResultToolWindowFactory getOutputWindow(Project project) {
ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project);
toolWindow = toolWindowManager.getToolWindow("Couchbase Output");
}
- SwingUtilities.invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> toolWindow.show()));
+ ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> toolWindow.show()));
if (resultWindow == null) {
resultWindow = QueryResultToolWindowFactory.instance;
diff --git a/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java b/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java
index 35a8edb0..0caed4d9 100644
--- a/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java
+++ b/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java
@@ -253,7 +253,7 @@ public void selectionChanged(TabInfo oldSelection, TabInfo newSelection) {
ActiveCluster.getInstance().registerNewConnectionListener(() -> {
- SwingUtilities.invokeLater(() -> {
+ ApplicationManager.getApplication().invokeLater(() -> {
if (!ActiveCluster.getInstance().hasQueryService()) {
queryResultTab.setEnabled(false);
queryResultTab.revalidate();
@@ -372,7 +372,7 @@ public List