From ee1467eb26cf6f292c3876e8114549c54cb33564 Mon Sep 17 00:00:00 2001 From: Denis Rosa Date: Tue, 2 Apr 2024 19:30:39 +0200 Subject: [PATCH] fixing bugs on windows and query template --- build.gradle.kts | 2 +- .../intellij/tree/NewScopeCreationDialog.java | 26 +++++++++++++------ .../intellij/workbench/chart/BarChart.java | 4 ++- .../intellij/workbench/chart/LineChart.java | 4 ++- .../intellij/workbench/chart/MapCbChart.java | 4 ++- .../workbench/chart/PieDoughnutChart.java | 4 ++- .../language/completion/SQLPPTemplates.java | 7 +++-- src/main/resources/chartTemplates/bar.html | 2 +- src/main/resources/chartTemplates/cmap.html | 8 +++--- src/main/resources/chartTemplates/lines.html | 2 +- .../chartTemplates/pie_doughnut.html | 2 +- 11 files changed, 41 insertions(+), 24 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index af2ac3a0..ded1af45 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "com.couchbase" -version = "1.0.8" +version = "1.0.9" java { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/java/com/couchbase/intellij/tree/NewScopeCreationDialog.java b/src/main/java/com/couchbase/intellij/tree/NewScopeCreationDialog.java index 66d5e4fe..bd5deb68 100644 --- a/src/main/java/com/couchbase/intellij/tree/NewScopeCreationDialog.java +++ b/src/main/java/com/couchbase/intellij/tree/NewScopeCreationDialog.java @@ -12,13 +12,13 @@ import java.util.List; - public class NewScopeCreationDialog extends DialogWrapper { private JTextField textField; private JLabel errorLabel; private String bucketName; private String scopeName; + protected NewScopeCreationDialog( Project project, String bucketName) { @@ -28,6 +28,7 @@ protected NewScopeCreationDialog( init(); setTitle("Create new Scope"); + getPeer().getWindow().setMinimumSize(new Dimension(360, 120)); } @Override @@ -35,24 +36,33 @@ protected NewScopeCreationDialog( protected JComponent createCenterPanel() { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); + + gbc.fill = GridBagConstraints.NONE; + gbc.gridwidth = GridBagConstraints.RELATIVE; gbc.gridx = 0; gbc.gridy = 0; - gbc.insets = JBUI.insets(5); + gbc.weightx = 0.3; + gbc.insets = JBUI.insets(3); gbc.anchor = GridBagConstraints.WEST; - JLabel nameLabel = new JLabel("Name of the Scope"); + JLabel nameLabel = new JLabel("Scope name"); panel.add(nameLabel, gbc); - gbc.gridy = 1; - textField = new JTextField(20); + gbc.gridx = 1; + gbc.weightx = 0.7; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.gridwidth = GridBagConstraints.REMAINDER; + textField = new JTextField(); panel.add(textField, gbc); - gbc.gridy = 2; errorLabel = new JLabel(""); errorLabel.setForeground(Color.decode("#FF4444")); - panel.add(errorLabel, gbc); - return panel; + JPanel wrapper = new JPanel(new BorderLayout()); + wrapper.add(panel, BorderLayout.NORTH); + wrapper.add(errorLabel, BorderLayout.SOUTH); + + return wrapper; } @Override diff --git a/src/main/java/com/couchbase/intellij/workbench/chart/BarChart.java b/src/main/java/com/couchbase/intellij/workbench/chart/BarChart.java index 543800e6..7ff789f7 100644 --- a/src/main/java/com/couchbase/intellij/workbench/chart/BarChart.java +++ b/src/main/java/com/couchbase/intellij/workbench/chart/BarChart.java @@ -12,9 +12,11 @@ import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.io.File; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; public class BarChart implements CbChart { @@ -114,7 +116,7 @@ private void renderChart() { String template = ChartUtil.loadResourceAsString("/chartTemplates/bar.html"); template = template.replace("JSON_DATA_TEMPLATE", JsonArray.from(results).toString()) - .replaceAll("JS_LIB_PATH", CBFolders.getInstance().getJsDependenciesPath()) + .replaceAll("JS_LIB_PATH_", Matcher.quoteReplacement(CBFolders.getInstance().getJsDependenciesPath() + File.separator)) .replace("DATA_LABELS", labels.toString()) .replace("DATA_VALUES", values.toString()) .replace("ISDARK", String.valueOf(ColorHelper.isDarkTheme())); diff --git a/src/main/java/com/couchbase/intellij/workbench/chart/LineChart.java b/src/main/java/com/couchbase/intellij/workbench/chart/LineChart.java index 5d437255..5981b39b 100644 --- a/src/main/java/com/couchbase/intellij/workbench/chart/LineChart.java +++ b/src/main/java/com/couchbase/intellij/workbench/chart/LineChart.java @@ -12,9 +12,11 @@ import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.io.File; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; public class LineChart implements CbChart { @@ -116,7 +118,7 @@ private void renderChart() { String template = ChartUtil.loadResourceAsString("/chartTemplates/lines.html"); template = template.replace("JSON_DATA_TEMPLATE", JsonArray.from(results).toString()) .replace("DATA_LABELS", labels.toString()) - .replaceAll("JS_LIB_PATH", CBFolders.getInstance().getJsDependenciesPath()) + .replaceAll("JS_LIB_PATH_", Matcher.quoteReplacement(CBFolders.getInstance().getJsDependenciesPath() + File.separator)) .replace("DATA_VALUES", values.toString()) .replace("ISDARK", String.valueOf(ColorHelper.isDarkTheme())); browser.loadHTML(template); diff --git a/src/main/java/com/couchbase/intellij/workbench/chart/MapCbChart.java b/src/main/java/com/couchbase/intellij/workbench/chart/MapCbChart.java index c1a43a09..da6aac1d 100644 --- a/src/main/java/com/couchbase/intellij/workbench/chart/MapCbChart.java +++ b/src/main/java/com/couchbase/intellij/workbench/chart/MapCbChart.java @@ -27,9 +27,11 @@ import java.awt.event.ItemListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; public class MapCbChart implements CbChart { @@ -195,7 +197,7 @@ private void renderChart() { template = template.replace("JSON_DATA_TEMPLATE", JsonArray.from(results).toString()) .replace("GEO_CIRCLE_LIST", circles) .replace("GEO_POLYGON_LIST", polygons) - .replaceAll("JS_LIB_PATH", CBFolders.getInstance().getJsDependenciesPath()) + .replaceAll("JS_LIB_PATH_", Matcher.quoteReplacement(CBFolders.getInstance().getJsDependenciesPath() + File.separator)) .replace("GEO_LAT_TEMPLATE", latBox.getSelectedItem().toString()) .replace("GEO_LON_TEMPLATE", lonBox.getSelectedItem().toString()); browser.loadHTML(template); diff --git a/src/main/java/com/couchbase/intellij/workbench/chart/PieDoughnutChart.java b/src/main/java/com/couchbase/intellij/workbench/chart/PieDoughnutChart.java index 7d06c1ad..22f43a47 100644 --- a/src/main/java/com/couchbase/intellij/workbench/chart/PieDoughnutChart.java +++ b/src/main/java/com/couchbase/intellij/workbench/chart/PieDoughnutChart.java @@ -12,10 +12,12 @@ import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; public class PieDoughnutChart implements CbChart { @@ -129,7 +131,7 @@ private void renderChart() { String template = ChartUtil.loadResourceAsString("/chartTemplates/pie_doughnut.html"); template = template.replace("JSON_DATA_TEMPLATE", JsonArray.from(results).toString()) .replace("CHART_TYPE", type == Type.PIE ? "pie" : "doughnut") - .replaceAll("JS_LIB_PATH", CBFolders.getInstance().getJsDependenciesPath()) + .replaceAll("JS_LIB_PATH_", Matcher.quoteReplacement(CBFolders.getInstance().getJsDependenciesPath() + File.separator)) .replace("DATA_LABELS", labels.toString()) .replace("DATA_VALUES", values.toString()) .replace("ISDARK", String.valueOf(ColorHelper.isDarkTheme())); diff --git a/src/main/java/org/intellij/sdk/language/completion/SQLPPTemplates.java b/src/main/java/org/intellij/sdk/language/completion/SQLPPTemplates.java index 5a1c8d90..0c8e287f 100644 --- a/src/main/java/org/intellij/sdk/language/completion/SQLPPTemplates.java +++ b/src/main/java/org/intellij/sdk/language/completion/SQLPPTemplates.java @@ -19,7 +19,6 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.ProcessingContext; -import generated.GeneratedTypes; import org.intellij.sdk.language.psi.SqlppFile; import org.jetbrains.annotations.NotNull; @@ -101,8 +100,8 @@ private String getPreviewSelect(String collection, Set attributes) { } private Set getCollectionAttributes(CouchbaseCollection col) { - if (col == null || col.getChildren() == null ) { - return new HashSet<>(); + if (col == null || col.getChildren() == null) { + return new HashSet<>(); } return col.getChildren().stream() .flatMap(e -> Optional.ofNullable(e.getChildren()) @@ -285,7 +284,7 @@ private Template createSelectWithAttrsTemplate(Project project, String collectio List attributesList = new ArrayList<>(attributes); String attrStream = IntStream.range(0, attributesList.size()) - .mapToObj(i -> (i == 0 ? "" : "\t\t") + collection + "." + attributesList.get(i)) + .mapToObj(i -> (i == 0 ? "" : "\t\t") + collection + ".`" + attributesList.get(i) + "`") .collect(Collectors.joining(", \n")); TemplateManager templateManager = TemplateManager.getInstance(project); diff --git a/src/main/resources/chartTemplates/bar.html b/src/main/resources/chartTemplates/bar.html index 1ef7b29b..c30aaa9c 100644 --- a/src/main/resources/chartTemplates/bar.html +++ b/src/main/resources/chartTemplates/bar.html @@ -16,7 +16,7 @@ visibility: hidden; } - +
diff --git a/src/main/resources/chartTemplates/cmap.html b/src/main/resources/chartTemplates/cmap.html index 65968041..ab4b1c12 100644 --- a/src/main/resources/chartTemplates/cmap.html +++ b/src/main/resources/chartTemplates/cmap.html @@ -2,10 +2,10 @@ Interactive Map with JSON Data - - - - + + + + - +
diff --git a/src/main/resources/chartTemplates/pie_doughnut.html b/src/main/resources/chartTemplates/pie_doughnut.html index c56c428a..22ece7ef 100644 --- a/src/main/resources/chartTemplates/pie_doughnut.html +++ b/src/main/resources/chartTemplates/pie_doughnut.html @@ -17,7 +17,7 @@ visibility: hidden; } - +