This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-23862 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 3fc1b5e97736ae49be16ceea3316c3b202cc3ff6 Author: Claus Ibsen <[email protected]> AuthorDate: Tue Jun 30 19:43:40 2026 +0200 CAMEL-23862: SQL Trace - add edit SQL shortcut and rename sort column Add 'e' key to copy selected SQL and open it in the SQL Query tab for editing. Rename sort column from category to type to match the TYPE column header. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../dsl/jbang/core/commands/tui/SqlTraceTab.java | 36 +++++++++++++++++++--- .../dsl/jbang/core/commands/tui/TabRegistry.java | 5 +++ 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlTraceTab.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlTraceTab.java index 8bc6a6cd0cab..1e95ae6107f5 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlTraceTab.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlTraceTab.java @@ -22,6 +22,7 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import java.util.function.Consumer; import dev.tamboui.layout.Constraint; import dev.tamboui.layout.Layout; @@ -49,7 +50,7 @@ import static org.apache.camel.dsl.jbang.core.commands.tui.MonitorContext.*; class SqlTraceTab implements MonitorTab { - private static final String[] SORT_COLUMNS = { "time", "category", "sql", "route", "duration", "rows" }; + private static final String[] SORT_COLUMNS = { "time", "type", "sql", "route", "duration", "rows" }; private static final DateTimeFormatter TIME_FMT = DateTimeFormatter.ofPattern("HH:mm:ss.SSS"); private final MonitorContext ctx; @@ -61,11 +62,16 @@ class SqlTraceTab implements MonitorTab { private int detailScroll; private boolean wordWrap = true; private String selectedKey; + private Consumer<String> editSqlAction; SqlTraceTab(MonitorContext ctx) { this.ctx = ctx; } + void setEditSqlAction(Consumer<String> editSqlAction) { + this.editSqlAction = editSqlAction; + } + @Override public void onTabSelected() { IntegrationInfo info = ctx.findSelectedIntegration(); @@ -90,6 +96,13 @@ class SqlTraceTab implements MonitorTab { wordWrap = !wordWrap; return true; } + if (ke.isCharIgnoreCase('e') && editSqlAction != null) { + String sql = getSelectedQuery(); + if (sql != null) { + editSqlAction.accept(sql); + return true; + } + } if (ke.isHome()) { detailScroll = 0; selectedKey = null; @@ -183,6 +196,20 @@ class SqlTraceTab implements MonitorTab { frame.renderWidget(kpi, area); } + private String getSelectedQuery() { + IntegrationInfo info = ctx.findSelectedIntegration(); + if (info == null) { + return null; + } + List<SqlTraceInfo> sorted = new ArrayList<>(info.sqlTraceStatements); + sorted.sort(this::sortTrace); + Integer sel = tableState.selected(); + if (sel != null && sel >= 0 && sel < sorted.size()) { + return sorted.get(sel).query; + } + return null; + } + private static String traceKey(SqlTraceInfo si) { return si.exchangeId + "@" + si.timestamp; } @@ -268,7 +295,7 @@ class SqlTraceTab implements MonitorTab { .rows(rows) .header(Row.from( Cell.from(Span.styled(sortLabel("TIME", "time"), sortStyle("time"))), - Cell.from(Span.styled(sortLabel("TYPE", "category"), sortStyle("category"))), + Cell.from(Span.styled(sortLabel("TYPE", "type"), sortStyle("type"))), Cell.from(Span.styled(sortLabel("SQL", "sql"), sortStyle("sql"))), Cell.from(Span.styled(sortLabel("ROUTE", "route"), sortStyle("route"))), rightCell(sortLabel("DURATION", "duration"), 10, sortStyle("duration")), @@ -362,6 +389,7 @@ class SqlTraceTab implements MonitorTab { hint(spans, "↑↓", "navigate"); hint(spans, "Home/End", "top/end"); hint(spans, "PgUp/Dn", "scroll detail"); + hint(spans, "e", "edit SQL"); hint(spans, "s", "sort"); hint(spans, "w", "wrap [" + (wordWrap ? "on" : "off") + "]"); } @@ -376,7 +404,7 @@ class SqlTraceTab implements MonitorTab { private int sortTrace(SqlTraceInfo a, SqlTraceInfo b) { int result = switch (sort) { - case "category" -> { + case "type" -> { String ca = a.category != null ? a.category : ""; String cb = b.category != null ? b.category : ""; yield ca.compareToIgnoreCase(cb); @@ -476,7 +504,7 @@ class SqlTraceTab implements MonitorTab { row.put("exchangeId", si.exchangeId); row.put("routeId", si.routeId); row.put("query", si.query); - row.put("category", si.category); + row.put("type", si.category); row.put("endpoint", si.endpoint); row.put("duration", si.duration); row.put("rowCount", si.rowCount); diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java index c0a9051f2125..4fb2bf453383 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java @@ -127,6 +127,11 @@ class TabRegistry { overviewTab = new OverviewTab( ctx, dataService.metrics(), dataService.stoppingPids(), resetIntegrationTabState); + + sqlTraceTab.setEditSqlAction(sql -> { + selectMoreTab(10); // switch to SQL Query tab + sqlQueryTab.setInputValue("sql", sql); + }); } // ---- Tab access ----
