This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-23934 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 5536371575d43cd64280fc6982908d5746d3d3b5 Author: Claus Ibsen <[email protected]> AuthorDate: Wed Jul 8 13:17:49 2026 +0200 CAMEL-23934: Disable SQL Query input when no DataSource is available Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../dsl/jbang/core/commands/tui/SqlQueryTab.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java index 6170df79ff84..fe7c138fc03a 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SqlQueryTab.java @@ -103,7 +103,7 @@ class SqlQueryTab extends AbstractTab { } boolean isInputActive() { - return editMode || focusOnInput; + return !dsNames.isEmpty() && (editMode || focusOnInput); } void handlePaste(String text) { @@ -139,8 +139,8 @@ class SqlQueryTab extends AbstractTab { @Override public boolean handleKeyEvent(KeyEvent ke) { - if (executing.get()) { - return true; + if (dsNames.isEmpty() || executing.get()) { + return dsNames.isEmpty() ? false : true; } // edit mode takes priority @@ -396,10 +396,13 @@ class SqlQueryTab extends AbstractTab { title = String.format(" SQL Query (%d updated, %dms) ", updateCount, elapsed); } else if (resultRows != null) { title = String.format(" SQL Query (%d row(s), %dms) ", rowCount, elapsed); + } else if (dsNames.isEmpty()) { + title = " SQL Query "; } else { title = " SQL Query (F5 to execute) "; } - Style borderStyle = focusOnInput ? Style.EMPTY.fg(Theme.accent()) : Theme.muted(); + Style borderStyle = dsNames.isEmpty() ? Theme.muted() + : focusOnInput ? Style.EMPTY.fg(Theme.accent()) : Theme.muted(); Block inputBlock = Block.builder() .title(Title.from(title)) .borders(Borders.ALL) @@ -411,9 +414,13 @@ class SqlQueryTab extends AbstractTab { TextArea textArea = TextArea.builder() .cursorStyle(Style.EMPTY.reversed()) - .placeholder("Type SQL query or file:query.sql ...") + .placeholder(dsNames.isEmpty() + ? "No DataSource available" + : "Type SQL query or file:query.sql ...") .build(); - if (focusOnInput) { + if (dsNames.isEmpty()) { + textArea.render(inner, frame.buffer(), sqlInput); + } else if (focusOnInput) { textArea.renderWithCursor(inner, frame.buffer(), sqlInput, frame); } else { textArea.render(inner, frame.buffer(), sqlInput);
