This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch worktree-tui in repository https://gitbox.apache.org/repos/asf/camel.git
commit 4973d823c58aa4b63d30363b35fc1ee82ab2de99 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jul 6 20:34:09 2026 +0200 CAMEL-22616: camel-jbang - Move HTTP server info into table title Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../camel/dsl/jbang/core/commands/tui/HttpTab.java | 63 ++++++++++++---------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/HttpTab.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/HttpTab.java index 69e2a35e6f21..23d65ebbb0e6 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/HttpTab.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/HttpTab.java @@ -277,13 +277,12 @@ class HttpTab extends AbstractTableTab { detailPanelHeight = Math.max(3, Math.min(detailPanelHeight, area.height() - 5)); List<Rect> chunks = Layout.vertical() - .constraints(Constraint.length(1), Constraint.fill(), Constraint.length(detailPanelHeight)) + .constraints(Constraint.fill(), Constraint.length(detailPanelHeight)) .split(area); - renderServerInfo(frame, chunks.get(0), info, visible); - renderTable(frame, chunks.get(1), visible); - vSplit.setBorderPos(chunks.get(2).y()); - renderDetail(frame, chunks.get(2), visible); + renderTable(frame, chunks.get(0), visible, info); + vSplit.setBorderPos(chunks.get(1).y()); + renderDetail(frame, chunks.get(1), visible); } @Override @@ -1208,52 +1207,58 @@ class HttpTab extends AbstractTableTab { return result; } - private void renderServerInfo(Frame frame, Rect area, IntegrationInfo info, List<HttpEndpointInfo> visible) { + static Style methodStyle(String method) { + if (method == null) { + return Style.EMPTY; + } + String m = method.split(",")[0].trim().toUpperCase(Locale.ENGLISH); + return switch (m) { + case "GET" -> Style.EMPTY.fg(Color.GREEN); + case "POST" -> Style.EMPTY.fg(Color.YELLOW); + case "PUT" -> Style.EMPTY.fg(Color.CYAN); + case "DELETE" -> Style.EMPTY.fg(Color.LIGHT_RED); + case "PATCH" -> Style.EMPTY.fg(Color.rgb(0xFF, 0x80, 0x00)); + default -> Style.EMPTY.dim(); + }; + } + + private Title buildTableTitle(IntegrationInfo info, List<HttpEndpointInfo> visible) { List<Span> spans = new ArrayList<>(); + spans.add(Span.raw(" HTTP Services [" + visible.size() + "]")); if (info.httpServer != null) { - spans.add(Span.styled(" Server: ", Style.EMPTY.fg(Color.YELLOW).bold())); + spans.add(Span.raw(" ")); + spans.add(Span.styled("Server: ", Style.EMPTY.fg(Color.YELLOW).bold())); spans.add(Span.styled(info.httpServer, Style.EMPTY.fg(Color.CYAN))); - spans.add(Span.raw(" ")); } long restCount = info.httpEndpoints.stream().filter(e -> e.fromRest && !e.specification).count(); long specCount = info.httpEndpoints.stream().filter(e -> e.specification).count(); long httpCount = info.httpEndpoints.stream().filter(e -> !e.fromRest && !e.management).count(); long mgmtCount = info.httpEndpoints.stream().filter(e -> e.management).count(); if (restCount > 0) { + spans.add(Span.raw(" ")); spans.add(Span.styled("REST: ", Style.EMPTY.fg(Color.GREEN))); - spans.add(Span.raw(restCount + " ")); + spans.add(Span.raw(restCount + "")); } if (specCount > 0) { + spans.add(Span.raw(" ")); spans.add(Span.styled("Spec: ", Style.EMPTY.fg(Color.MAGENTA))); - spans.add(Span.raw(specCount + " ")); + spans.add(Span.raw(specCount + "")); } if (httpCount > 0) { + spans.add(Span.raw(" ")); spans.add(Span.styled("HTTP: ", Style.EMPTY.fg(Color.CYAN))); - spans.add(Span.raw(httpCount + " ")); + spans.add(Span.raw(httpCount + "")); } if (mgmtCount > 0) { + spans.add(Span.raw(" ")); spans.add(Span.styled("Mgmt: ", Style.EMPTY.fg(Color.YELLOW).dim())); spans.add(Span.raw(mgmtCount + "")); } - frame.renderWidget(Paragraph.from(Line.from(spans)), area); - } - - static Style methodStyle(String method) { - if (method == null) { - return Style.EMPTY; - } - String m = method.split(",")[0].trim().toUpperCase(Locale.ENGLISH); - return switch (m) { - case "GET" -> Style.EMPTY.fg(Color.GREEN); - case "POST" -> Style.EMPTY.fg(Color.YELLOW); - case "PUT" -> Style.EMPTY.fg(Color.CYAN); - case "DELETE" -> Style.EMPTY.fg(Color.LIGHT_RED); - case "PATCH" -> Style.EMPTY.fg(Color.rgb(0xFF, 0x80, 0x00)); - default -> Style.EMPTY.dim(); - }; + spans.add(Span.raw(" ")); + return Title.from(Line.from(spans)); } - private void renderTable(Frame frame, Rect area, List<HttpEndpointInfo> visible) { + private void renderTable(Frame frame, Rect area, List<HttpEndpointInfo> visible, IntegrationInfo info) { List<Row> rows = new ArrayList<>(); for (HttpEndpointInfo ep : visible) { String method = ep.method != null ? ep.method : ""; @@ -1286,7 +1291,7 @@ class HttpTab extends AbstractTableTab { "Stopped".equals(state) ? Style.EMPTY.fg(Color.LIGHT_RED) : Style.EMPTY)))); } - String title = String.format(" HTTP Services [%d] ", visible.size()); + Title title = buildTableTitle(info, visible); Row header = Row.from( Cell.from(Span.styled(sortLabel("METHOD", "method"), sortStyle("method"))),
