adapt the height of the result details frame based on content

auto-update
Zlatin Balevsky 2021-12-23 15:17:44 +00:00
parent 33292f773c
commit 2e5f17a896
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 9 additions and 2 deletions

View File

@ -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<String, String> args) {