From 2e5f17a89679e41c29e08ab3545866a64144ffec Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Thu, 23 Dec 2021 15:17:44 +0000 Subject: [PATCH] adapt the height of the result details frame based on content --- .../gui/resultdetails/ResultDetailsFrameView.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gui/griffon-app/views/com/muwire/gui/resultdetails/ResultDetailsFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/resultdetails/ResultDetailsFrameView.groovy index f331f765..3b241c69 100644 --- a/gui/griffon-app/views/com/muwire/gui/resultdetails/ResultDetailsFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/resultdetails/ResultDetailsFrameView.groovy @@ -3,6 +3,7 @@ package com.muwire.gui.resultdetails import net.i2p.data.Destination import javax.swing.JPanel +import java.awt.Dimension import java.awt.event.WindowAdapter import java.awt.event.WindowEvent @@ -24,7 +25,7 @@ class ResultDetailsFrameView { @MVCMember @Nonnull ResultDetailsFrameModel model - def window + JFrame window JPanel certificatesPanel JPanel collectionsPanel @@ -34,10 +35,10 @@ class ResultDetailsFrameView { void initUI() { int rowHeight = application.context.get("row-height") + int frameHeight = 100 window = builder.frame(visible : false, locationRelativeTo: application.windowManager.findWindow("main-frame"), defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE, iconImage: builder.imageIcon("/MuWire-48x48.png").image, - preferredSize: [800,800], title: trans("DETAILS_FOR", model.resultEvent.name)) { gridBagLayout() int gridy = 0 @@ -50,6 +51,7 @@ class ResultDetailsFrameView { label(text : String.valueOf(0x1 << model.resultEvent.pieceSize), constraints: gbc(gridx: 1, gridy: 1)) } if (model.resultEvent.comment != null) { + frameHeight += 200 panel(border: titledBorder(title: trans("COMMENT"), border: etchedBorder(), titlePosition: TitledBorder.TOP), constraints: gbc(gridx: 0, gridy: gridy++, fill: GridBagConstraints.BOTH, weightx: 100, weighty: 100)) { gridLayout(rows: 1, cols: 1) @@ -59,6 +61,7 @@ class ResultDetailsFrameView { } } if (model.senders.size() > 1) { + frameHeight += 200 panel(border: titledBorder(title : trans("SENDERS"), border: etchedBorder(), titlePosition: TitledBorder.TOP), constraints: gbc(gridx: 0, gridy: gridy++, fill: GridBagConstraints.BOTH, weightx: 100, weighty: 100)) { gridLayout(rows: 1, cols: 1) @@ -76,18 +79,22 @@ class ResultDetailsFrameView { } } if (model.resultEvent.certificates > 0) { + frameHeight += 300 certificatesPanel = panel(border: titledBorder(title : trans("CERTIFICATES"), border: etchedBorder(), titlePosition: TitledBorder.TOP), constraints: gbc(gridx: 0, gridy: gridy++, fill: GridBagConstraints.BOTH, weightx: 100, weighty: 100)) { gridLayout(rows: 1, cols: 1) } } if (model.resultEvent.collections.size() > 0) { + frameHeight += 300 collectionsPanel = panel(border: titledBorder(title : trans("COLLECTIONS"), border: etchedBorder(), titlePosition: TitledBorder.TOP), constraints: gbc(gridx: 0, gridy: gridy++, fill: GridBagConstraints.BOTH, weightx: 100, weighty: 100)) { gridLayout(rows: 1, cols: 1) } } } + + window.setPreferredSize([800, frameHeight] as Dimension) } void mvcGroupInit(Map args) {