Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.1.3 release #214

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -96,10 +96,17 @@ private static String getEmptyExplain() {
return "<html><body style=\" background: #3c3f41\"><span style='color:#ccc'>Nothing to show</span></body></html>";
}

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);
Expand Down Expand Up @@ -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);

Expand All @@ -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();
Expand All @@ -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"));

Expand All @@ -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());
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -384,11 +395,14 @@ public void updateQueryStats(List<String> queryValues, List<JsonObject> results,

removeAllActionListeners(csvMenuItem);
removeAllActionListeners(jsonMenuItem);
csvMenuItem.addActionListener(actionEvent -> FileExporter.exportResultToCSV(project, model.tableModelToCSV()));
jsonMenuItem.addActionListener(actionEvent -> FileExporter.exportResultToJson(project, gson.toJson(convertedResults)));
csvMenuItem.addActionListener(
actionEvent -> FileExporter.exportResultToCSV(project, model.tableModelToCSV()));
jsonMenuItem.addActionListener(
actionEvent -> FileExporter.exportResultToJson(project, gson.toJson(convertedResults)));


statusIcon.setIcon(IconLoader.getIcon("/assets/icons/check_mark_big.svg", QueryResultToolWindowFactory.class));
statusIcon.setIcon(
IconLoader.getIcon("/assets/icons/check_mark_big.svg", QueryResultToolWindowFactory.class));
ApplicationManager.getApplication().runWriteAction(() -> {
editor.getDocument().setText(gson.toJson(convertedResults));
});
Expand Down Expand Up @@ -476,9 +490,9 @@ public void updateQueryStats(List<String> queryValues, List<JsonObject> results,
for (Component component : popupMenu.getComponents()) {
if (component instanceof JMenuItem) {
JMenuItem menuItem = (JMenuItem) component;
if (menuItem.getText().equals("SQL++ UPSERT") ||
menuItem.getText().equals("SQL++ INSERT") ||
menuItem.getText().equals("SQL++ UPDATE")) {
if (menuItem.getText().equals("SQL++ UPSERT") || menuItem.getText()
.equals("SQL++ INSERT") || menuItem
.getText().equals("SQL++ UPDATE")) {
popupMenu.remove(menuItem);
}

Expand All @@ -494,8 +508,10 @@ public void updateQueryStats(List<String> queryValues, List<JsonObject> results,

} else {
cachedResults = null;
statusIcon.setIcon(IconLoader.getIcon("/assets/icons/warning-circle-big.svg", QueryResultToolWindowFactory.class));
ApplicationManager.getApplication().runWriteAction(() -> editor.getDocument().setText(gson.toJson(error.getErrors())));
statusIcon.setIcon(
IconLoader.getIcon("/assets/icons/warning-circle-big.svg", QueryResultToolWindowFactory.class));
ApplicationManager.getApplication()
.runWriteAction(() -> editor.getDocument().setText(gson.toJson(error.getErrors())));
}
});
}
Expand All @@ -507,7 +523,8 @@ public void setStatusAsLoading() {
}
statusIcon.setIcon(new AnimatedIcon.Default());

ApplicationManager.getApplication().runWriteAction(() -> editor.getDocument().setText("{ \"status\": \"Executing Statement\"}"));
ApplicationManager.getApplication().runWriteAction(
() -> editor.getDocument().setText("{ \"status\": \"Executing Statement\"}"));
});
}

Expand All @@ -516,15 +533,10 @@ public void setStatusAsCanceled() {
for (JLabel label : queryStatsList) {
label.setText("-");
}
statusIcon.setIcon(IconLoader.getIcon("/assets/icons/warning-circle-big.svg", QueryResultToolWindowFactory.class));
ApplicationManager.getApplication().runWriteAction(() -> editor.getDocument().setText("{ \"status\": \"Query cancelled\"}"));
statusIcon.setIcon(
IconLoader.getIcon("/assets/icons/warning-circle-big.svg", QueryResultToolWindowFactory.class));
ApplicationManager.getApplication()
.runWriteAction(() -> editor.getDocument().setText("{ \"status\": \"Query cancelled\"}"));
});
}

public static void removeAllActionListeners(JMenuItem menuItem) {
ActionListener[] listeners = menuItem.getActionListeners();
for (ActionListener listener : listeners) {
menuItem.removeActionListener(listener);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<![CDATA[
<h2>New Features</h2>
<ul>
<li>You can now import data from DynamoDB</li>
<li>Adding Couchbase Search and Vector Search Support</li>
<li>You can now apply key range filters on documents</li>
<li>Support for named parameters</li>
Expand Down
Loading