2
2
3
3
import com .couchbase .intellij .database .ActiveCluster ;
4
4
import com .couchbase .intellij .tools .CBTools ;
5
+ import com .couchbase .intellij .workbench .Log ;
5
6
import com .intellij .openapi .ui .DialogWrapper ;
6
7
import com .intellij .util .ui .JBUI ;
7
8
import org .jetbrains .annotations .Nullable ;
13
14
import org .jfree .chart .axis .NumberAxis ;
14
15
import org .jfree .chart .plot .PlotOrientation ;
15
16
import org .jfree .data .category .DefaultCategoryDataset ;
16
-
17
17
import utils .ProcessUtils ;
18
18
import utils .TemplateUtil ;
19
19
@@ -76,6 +76,7 @@ protected JComponent createCenterPanel() {
76
76
c .gridx = 1 ;
77
77
c .gridy = 1 ;
78
78
outputFormatComboBox = new JComboBox <>();
79
+ outputFormatComboBox .addItem ("Summary of All Operations" );
79
80
outputFormatComboBox .addItem ("Histogram" );
80
81
outputFormatComboBox .addItem ("Json" );
81
82
outputFormatComboBox .addItem ("Json pretty printed" );
@@ -133,6 +134,7 @@ protected JComponent createSouthPanel() {
133
134
return southPanel ;
134
135
}
135
136
137
+
136
138
public static class ChartGenerator {
137
139
protected JPanel generateBarChart (String [] labels , int [] values ) {
138
140
DefaultCategoryDataset dataset = new DefaultCategoryDataset ();
@@ -151,23 +153,26 @@ protected JPanel generateBarChart(String[] labels, int[] values) {
151
153
152
154
// Set dynamic range for Y-axis
153
155
NumberAxis rangeAxis = (NumberAxis ) barChart .getCategoryPlot ().getRangeAxis ();
154
- rangeAxis .setRange ( 0 , Arrays . stream ( values ). max (). getAsInt ());
156
+ rangeAxis .setStandardTickUnits ( NumberAxis . createIntegerTickUnits ());
155
157
156
158
// Rotate X-axis labels
157
159
CategoryAxis domainAxis = barChart .getCategoryPlot ().getDomainAxis ();
158
160
domainAxis .setCategoryLabelPositions (CategoryLabelPositions .UP_45 );
159
161
160
162
ChartPanel chartPanel = new ChartPanel (barChart );
161
163
chartPanel .setDisplayToolTips (true ); // Enable tooltips
164
+ chartPanel .setMouseWheelEnabled (true ); // Enable zooming using mouse wheel
165
+ chartPanel .setMouseZoomable (true ); // Enable zooming using mouse drag
162
166
163
167
return chartPanel ;
164
168
}
165
169
}
166
170
171
+
167
172
@ Override
168
173
protected void doOKAction () {
169
174
dialogPanel .add (outputPanel , c );
170
- getWindow ().setMinimumSize (new Dimension (1800 , 1000 ));
175
+ getWindow ().setMinimumSize (new Dimension (1600 , 800 ));
171
176
172
177
String selectedOutputFormat = (String ) outputFormatComboBox .getSelectedItem ();
173
178
if (Objects .equals (selectedOutputFormat , "Histogram" )) {
@@ -201,27 +206,37 @@ protected void doOKAction() {
201
206
JPanel chartPanel = chartGenerator .generateBarChart (labels , values );
202
207
outputPanel .removeAll ();
203
208
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 {
208
211
JTextArea outputTextArea = new JTextArea ();
209
212
210
213
outputTextArea .setEditable (false );
214
+ outputTextArea .setLineWrap (true ); // Enable line wrapping
215
+ outputTextArea .setWrapStyleWord (true ); // Wrap lines at word boundaries
216
+
211
217
JScrollPane scrollPane = new JScrollPane (outputTextArea );
218
+ scrollPane .setHorizontalScrollBarPolicy (ScrollPaneConstants .HORIZONTAL_SCROLLBAR_NEVER ); // Disable horizontal scrolling
219
+
220
+ executeCommand (outputTextArea );
212
221
outputPanel .removeAll ();
213
222
outputPanel .add (scrollPane , BorderLayout .CENTER );
214
- outputPanel .revalidate ();
215
- outputPanel .repaint ();
216
-
217
- // TODO: Impplement Text area
218
223
}
219
224
225
+ outputPanel .revalidate ();
226
+ outputPanel .repaint ();
220
227
}
221
228
222
229
public void executeCommand (JTextArea outputTextArea ) {
223
230
List <String > command = new ArrayList <>();
224
231
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 ());
225
240
226
241
// Add the selected bucket to the command
227
242
String selectedBucket = (String ) bucketComboBox .getSelectedItem ();
@@ -234,26 +249,25 @@ public void executeCommand(JTextArea outputTextArea) {
234
249
235
250
// Add the selected output format to the command
236
251
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" );
243
257
}
244
258
245
259
// Add the selected optional parameters to the command
246
260
List <String > selectedOptionalParameters = optionalParametersComboCheckBox .getSelectedItems ();
247
261
for (String parameter : selectedOptionalParameters ) {
248
- command .add ("-- " + parameter .toLowerCase ());
262
+ command .add (" " + parameter .toLowerCase ());
249
263
}
250
264
251
265
ProcessBuilder processBuilder = new ProcessBuilder (command );
252
266
try {
253
267
Process process = processBuilder .start ();
254
268
ProcessUtils .printOutput (process , outputTextArea );
255
269
} catch (IOException e ) {
256
- e . printStackTrace ( );
270
+ Log . error ( "Exception Occurred: " , e );
257
271
}
258
272
}
259
273
0 commit comments