From 7dd34a50e1540d413d2e55c487493a7ef41dfa8b Mon Sep 17 00:00:00 2001 From: samir Date: Mon, 16 Dec 2024 15:08:51 +0100 Subject: [PATCH] feat(issue-243): changing the ChatResponsePanl layout to GridBagLayout --- .../genie/ui/panel/ChatResponsePanel.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/devoxx/genie/ui/panel/ChatResponsePanel.java b/src/main/java/com/devoxx/genie/ui/panel/ChatResponsePanel.java index 2e82492..f08df12 100644 --- a/src/main/java/com/devoxx/genie/ui/panel/ChatResponsePanel.java +++ b/src/main/java/com/devoxx/genie/ui/panel/ChatResponsePanel.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.*; public class ChatResponsePanel extends BackgroundPanel { @@ -14,15 +15,32 @@ public class ChatResponsePanel extends BackgroundPanel { public ChatResponsePanel(@NotNull ChatMessageContext chatMessageContext) { super(chatMessageContext.getId()); this.chatMessageContext = chatMessageContext; - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + setLayout(new GridBagLayout()); buildResponsePanel(); } private void buildResponsePanel() { - add(new ResponseHeaderPanel(chatMessageContext)); - add(new ResponseContentPanel(chatMessageContext)); - add(new FileListPanel(chatMessageContext, FileListManager.getInstance().getFiles())); - add(new SemanticSearchReferencesPanel(chatMessageContext, chatMessageContext.getSemanticReferences())); - add(new MetricExecutionInfoPanel(chatMessageContext)); + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 1; // full width components + gbc.fill = GridBagConstraints.HORIZONTAL; // Fill horizontally + gbc.anchor = GridBagConstraints.WEST; // Anchor to the west (left) + + add(new ResponseHeaderPanel(chatMessageContext), gbc); + + gbc.gridy++; + add(new ResponseContentPanel(chatMessageContext), gbc); + + gbc.gridy++; + add(new FileListPanel(chatMessageContext, FileListManager.getInstance().getFiles()), gbc); + + gbc.gridy++; + add(new SemanticSearchReferencesPanel(chatMessageContext, chatMessageContext.getSemanticReferences()), gbc); + + gbc.gridy++; + JPanel metricPanelWrapper = new JPanel(new FlowLayout(FlowLayout.LEFT)); + metricPanelWrapper.add(new MetricExecutionInfoPanel(chatMessageContext)); + add(metricPanelWrapper, gbc); } }