Skip to content

Commit 0fbdb13

Browse files
committed
updated output text area in mctimings dialog box
1 parent 6f4e0da commit 0fbdb13

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

src/main/java/com/couchbase/intellij/tools/dialog/MctimingsDialog.java

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.couchbase.intellij.database.ActiveCluster;
44
import com.couchbase.intellij.tools.CBTools;
5+
import com.couchbase.intellij.workbench.Log;
56
import com.intellij.openapi.ui.DialogWrapper;
67
import com.intellij.util.ui.JBUI;
78
import org.jetbrains.annotations.Nullable;
@@ -13,7 +14,6 @@
1314
import org.jfree.chart.axis.NumberAxis;
1415
import org.jfree.chart.plot.PlotOrientation;
1516
import org.jfree.data.category.DefaultCategoryDataset;
16-
1717
import utils.ProcessUtils;
1818
import utils.TemplateUtil;
1919

@@ -76,6 +76,7 @@ protected JComponent createCenterPanel() {
7676
c.gridx = 1;
7777
c.gridy = 1;
7878
outputFormatComboBox = new JComboBox<>();
79+
outputFormatComboBox.addItem("Summary of All Operations");
7980
outputFormatComboBox.addItem("Histogram");
8081
outputFormatComboBox.addItem("Json");
8182
outputFormatComboBox.addItem("Json pretty printed");
@@ -133,6 +134,7 @@ protected JComponent createSouthPanel() {
133134
return southPanel;
134135
}
135136

137+
136138
public static class ChartGenerator {
137139
protected JPanel generateBarChart(String[] labels, int[] values) {
138140
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
@@ -151,23 +153,26 @@ protected JPanel generateBarChart(String[] labels, int[] values) {
151153

152154
// Set dynamic range for Y-axis
153155
NumberAxis rangeAxis = (NumberAxis) barChart.getCategoryPlot().getRangeAxis();
154-
rangeAxis.setRange(0, Arrays.stream(values).max().getAsInt());
156+
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
155157

156158
// Rotate X-axis labels
157159
CategoryAxis domainAxis = barChart.getCategoryPlot().getDomainAxis();
158160
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
159161

160162
ChartPanel chartPanel = new ChartPanel(barChart);
161163
chartPanel.setDisplayToolTips(true); // Enable tooltips
164+
chartPanel.setMouseWheelEnabled(true); // Enable zooming using mouse wheel
165+
chartPanel.setMouseZoomable(true); // Enable zooming using mouse drag
162166

163167
return chartPanel;
164168
}
165169
}
166170

171+
167172
@Override
168173
protected void doOKAction() {
169174
dialogPanel.add(outputPanel, c);
170-
getWindow().setMinimumSize(new Dimension(1800, 1000));
175+
getWindow().setMinimumSize(new Dimension(1600, 800));
171176

172177
String selectedOutputFormat = (String) outputFormatComboBox.getSelectedItem();
173178
if (Objects.equals(selectedOutputFormat, "Histogram")) {
@@ -201,27 +206,37 @@ protected void doOKAction() {
201206
JPanel chartPanel = chartGenerator.generateBarChart(labels, values);
202207
outputPanel.removeAll();
203208
outputPanel.add(chartPanel, BorderLayout.CENTER);
204-
outputPanel.revalidate();
205-
outputPanel.repaint();
206-
} else if (Objects.requireNonNull(selectedOutputFormat).startsWith("Json")) {
207-
// Generate an empty text area
209+
210+
} else {
208211
JTextArea outputTextArea = new JTextArea();
209212

210213
outputTextArea.setEditable(false);
214+
outputTextArea.setLineWrap(true); // Enable line wrapping
215+
outputTextArea.setWrapStyleWord(true); // Wrap lines at word boundaries
216+
211217
JScrollPane scrollPane = new JScrollPane(outputTextArea);
218+
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); // Disable horizontal scrolling
219+
220+
executeCommand(outputTextArea);
212221
outputPanel.removeAll();
213222
outputPanel.add(scrollPane, BorderLayout.CENTER);
214-
outputPanel.revalidate();
215-
outputPanel.repaint();
216-
217-
// TODO: Impplement Text area
218223
}
219224

225+
outputPanel.revalidate();
226+
outputPanel.repaint();
220227
}
221228

222229
public void executeCommand(JTextArea outputTextArea) {
223230
List<String> command = new ArrayList<>();
224231
command.add(CBTools.getTool(CBTools.Type.MCTIMINGS).getPath());
232+
command.add("-h");
233+
command.add(ActiveCluster.getInstance().getClusterURL().replaceFirst("^couchbase://", ""));
234+
command.add("-p");
235+
command.add(ActiveCluster.getInstance().isSSLEnabled() ? "11207" : "11210");
236+
command.add("-u");
237+
command.add(ActiveCluster.getInstance().getUsername());
238+
command.add("-P");
239+
command.add(ActiveCluster.getInstance().getPassword());
225240

226241
// Add the selected bucket to the command
227242
String selectedBucket = (String) bucketComboBox.getSelectedItem();
@@ -234,26 +249,25 @@ public void executeCommand(JTextArea outputTextArea) {
234249

235250
// Add the selected output format to the command
236251
String selectedOutputFormat = (String) outputFormatComboBox.getSelectedItem();
237-
if ("Json".equals(selectedOutputFormat)) {
238-
command.add("-o");
239-
command.add("json");
240-
} else if ("Json pretty printed".equals(selectedOutputFormat)) {
241-
command.add("-o");
242-
command.add("jsonpretty");
252+
if (Objects.equals(selectedOutputFormat, "Json")){
253+
command.add("-j");
254+
} else if (Objects.equals(selectedOutputFormat, "Json pretty printed")){
255+
command.add("-j");
256+
command.add("-v");
243257
}
244258

245259
// Add the selected optional parameters to the command
246260
List<String> selectedOptionalParameters = optionalParametersComboCheckBox.getSelectedItems();
247261
for (String parameter : selectedOptionalParameters) {
248-
command.add("--" + parameter.toLowerCase());
262+
command.add(" " + parameter.toLowerCase());
249263
}
250264

251265
ProcessBuilder processBuilder = new ProcessBuilder(command);
252266
try {
253267
Process process = processBuilder.start();
254268
ProcessUtils.printOutput(process, outputTextArea);
255269
} catch (IOException e) {
256-
e.printStackTrace();
270+
Log.error("Exception Occurred: ",e);
257271
}
258272
}
259273

src/main/java/com/couchbase/intellij/tree/TreeRightClickListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
151151
// tools.add(cbimport);
152152
// }
153153

154-
if (CBTools.getTool(CBTools.Type.MCTIMINGS).isAvailable()) {
154+
// if (CBTools.getTool(CBTools.Type.MCTIMINGS).isAvailable()) {
155155
AnAction cbmctimings = new AnAction("Mctimings") {
156156
@Override
157157
public void actionPerformed(@NotNull AnActionEvent e) {
@@ -160,7 +160,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
160160
}
161161
};
162162
tools.add(cbmctimings);
163-
}
163+
// }
164164

165165
DefaultActionGroup settings = new DefaultActionGroup("Settings", true);
166166
DefaultActionGroup colors = new DefaultActionGroup("Connection Colors", true);

0 commit comments

Comments
 (0)