Skip to content

Commit

Permalink
fixing bugs on windows and query template
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Rosa authored and Denis Rosa committed Apr 2, 2024
1 parent c8d46a6 commit ee1467e
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 24 deletions.
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.0.8"
version = "1.0.9"
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -28,31 +28,41 @@ protected NewScopeCreationDialog(

init();
setTitle("Create new Scope");
getPeer().getWindow().setMinimumSize(new Dimension(360, 120));
}

@Override
@Nullable
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -101,8 +100,8 @@ private String getPreviewSelect(String collection, Set<String> attributes) {
}

private Set<String> 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())
Expand Down Expand Up @@ -285,7 +284,7 @@ private Template createSelectWithAttrsTemplate(Project project, String collectio

List<String> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/chartTemplates/bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
visibility: hidden;
}
</style>
<script src="JS_LIB_PATH/chart.js"></script>
<script src="JS_LIB_PATH_chart.js"></script>
</head>
<body>
<div class="chart-container">
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/chartTemplates/cmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<html>
<head>
<title>Interactive Map with JSON Data</title>
<link rel="stylesheet" href="JS_LIB_PATH/leaflet.css"/>
<script src="JS_LIB_PATH/leaflet.js"></script>
<link rel="stylesheet" href="JS_LIB_PATH/leaflet.draw.css"/>
<script src="JS_LIB_PATH/leaflet.draw.js"></script>
<link rel="stylesheet" href="JS_LIB_PATH_leaflet.css"/>
<script src="JS_LIB_PATH_leaflet.js"></script>
<link rel="stylesheet" href="JS_LIB_PATH_leaflet.draw.css"/>
<script src="JS_LIB_PATH_leaflet.draw.js"></script>

<style>
body, html {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/chartTemplates/lines.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
visibility: hidden;
}
</style>
<script src="JS_LIB_PATH/chart.js"></script>
<script src="JS_LIB_PATH_chart.js"></script>
</head>
<body>
<div class="chart-container">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/chartTemplates/pie_doughnut.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
visibility: hidden;
}
</style>
<script src="JS_LIB_PATH/chart.js"></script>
<script src="JS_LIB_PATH_chart.js"></script>
</head>
<body>
<div class="chart-container">
Expand Down

0 comments on commit ee1467e

Please sign in to comment.