diff --git a/build.gradle.kts b/build.gradle.kts index 53de2383..6d44d95c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "com.couchbase" -version = "1.1.2" +version = "1.1.3" java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java b/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java index 0caed4d9..12bb2609 100644 --- a/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java +++ b/src/main/java/com/couchbase/intellij/workbench/QueryResultToolWindowFactory.java @@ -35,9 +35,9 @@ import com.intellij.ui.content.ContentManager; import com.intellij.ui.table.JBTable; import com.intellij.ui.tabs.JBTabs; +import com.intellij.ui.tabs.JBTabsFactory; import com.intellij.ui.tabs.TabInfo; import com.intellij.ui.tabs.TabsListener; -import com.intellij.ui.tabs.impl.JBTabsImpl; import com.intellij.util.ui.JBUI; import org.jetbrains.annotations.NotNull; @@ -96,10 +96,17 @@ private static String getEmptyExplain() { return "
Nothing to show"; } + public static void removeAllActionListeners(JMenuItem menuItem) { + ActionListener[] listeners = menuItem.getActionListeners(); + for (ActionListener listener : listeners) { + menuItem.removeActionListener(listener); + } + } + @Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { this.project = project; - JBTabs tabs = new JBTabsImpl(project); + JBTabs tabs = JBTabsFactory.createTabs(project); model = new JsonTableModel(); JBTable table = new JBTable(model); table.setCellSelectionEnabled(true); @@ -158,7 +165,8 @@ public void actionPerformed(@NotNull AnActionEvent e) { } }); - ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("QueryResultToolbar", executeGroup, true); + ActionToolbar toolbar = ActionManager.getInstance() + .createActionToolbar("QueryResultToolbar", executeGroup, true); toolbar.getComponent().setBorder(JBUI.Borders.emptyRight(10)); toolbar.setTargetComponent(topPanel); @@ -182,8 +190,9 @@ public void actionPerformed(@NotNull AnActionEvent e) { topPanel.add(rightPanel, BorderLayout.EAST); - VirtualFile virtualFile = new LightVirtualFile("query_result", FileTypeManager.getInstance().getFileTypeByExtension("json"), - "{\n\"No data to display\": \"Hit 'execute' in the query editor to run a statement.\"\n}"); + VirtualFile virtualFile = new LightVirtualFile("query_result", + FileTypeManager.getInstance().getFileTypeByExtension("json"), + "{\n\"No data to display\": \"Hit 'execute' in the query editor to run a statement.\"\n}"); Document document = FileDocumentManager.getInstance().getDocument(virtualFile); editor = (EditorEx) EditorFactory.getInstance().createEditor(document, project, JsonFileType.INSTANCE, true); EditorSettings editorSettings = editor.getSettings(); @@ -196,7 +205,7 @@ public void actionPerformed(@NotNull AnActionEvent e) { latestExplain = getEmptyExplain(); - JBTabs resultTabs = new JBTabsImpl(project); + JBTabs resultTabs = JBTabsFactory.createTabs(project); resultTabs.addTab(new TabInfo(editor.getComponent()).setText("JSON")); resultTabs.addTab(new TabInfo(new JBScrollPane(table)).setText("Table")); @@ -208,7 +217,8 @@ public void actionPerformed(@NotNull AnActionEvent e) { explainTab = new TabInfo(explainPanel).setText("Explain"); resultTabs.addTab(explainTab); } catch (Exception e) { - Log.error("Failed to load the explain tab. Double check if the JRE that you are running your IDE has support for JCEF. https://plugins.jetbrains.com/docs/intellij/jcef.html#enabling-jcef"); + Log.error( + "Failed to load the explain tab. Double check if the JRE that you are running your IDE has support for JCEF. https://plugins.jetbrains.com/docs/intellij/jcef.html#enabling-jcef"); } JPanel charts = new JPanel(new BorderLayout()); @@ -288,11 +298,12 @@ public void actionPerformed(@NotNull AnActionEvent e) { console.clear(); } }; - clearAction.getTemplatePresentation().setIcon( - IconLoader.getIcon("/assets/icons/clear.svg", QueryResultToolWindowFactory.class)); + clearAction.getTemplatePresentation() + .setIcon(IconLoader.getIcon("/assets/icons/clear.svg", QueryResultToolWindowFactory.class)); actionGroup.add(clearAction); - ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("ConsoleToolbar", actionGroup, true); + ActionToolbar actionToolbar = ActionManager.getInstance() + .createActionToolbar("ConsoleToolbar", actionGroup, true); JPanel actionPanel = new JPanel(new FlowLayout()); actionPanel.add(actionToolbar.getComponent()); @@ -384,11 +395,14 @@ public void updateQueryStats(List