From 2128d3eac7940289b20e5eae27079f51c62c7174 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 25 Dec 2021 18:20:47 +0000 Subject: [PATCH] add a Close button to result details frame --- .../ResultDetailsFrameController.groovy | 12 +++ .../ResultDetailsFrameView.groovy | 94 ++++++++++--------- 2 files changed, 63 insertions(+), 43 deletions(-) diff --git a/gui/griffon-app/controllers/com/muwire/gui/resultdetails/ResultDetailsFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/resultdetails/ResultDetailsFrameController.groovy index 83137a9f..ca5735a9 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/resultdetails/ResultDetailsFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/resultdetails/ResultDetailsFrameController.groovy @@ -1,8 +1,20 @@ package com.muwire.gui.resultdetails import griffon.core.artifact.GriffonController +import griffon.core.controller.ControllerAction +import griffon.inject.MVCMember import griffon.metadata.ArtifactProviderFor +import javax.annotation.Nonnull + @ArtifactProviderFor(GriffonController) class ResultDetailsFrameController { + @MVCMember @Nonnull + ResultDetailsFrameView view + + @ControllerAction + void close() { + view.window.setVisible(false) + mvcGroup.destroy() + } } 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 3b241c69..7b79b9c8 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,8 @@ package com.muwire.gui.resultdetails import net.i2p.data.Destination import javax.swing.JPanel +import javax.swing.border.Border +import java.awt.BorderLayout import java.awt.Dimension import java.awt.event.WindowAdapter import java.awt.event.WindowEvent @@ -35,62 +37,68 @@ class ResultDetailsFrameView { void initUI() { int rowHeight = application.context.get("row-height") - int frameHeight = 100 + int frameHeight = 200 window = builder.frame(visible : false, locationRelativeTo: application.windowManager.findWindow("main-frame"), defaultCloseOperation: JFrame.DISPOSE_ON_CLOSE, iconImage: builder.imageIcon("/MuWire-48x48.png").image, title: trans("DETAILS_FOR", model.resultEvent.name)) { - gridBagLayout() - int gridy = 0 - panel(border: titledBorder(title : trans("BASIC_DETAILS"), border: etchedBorder(), titlePosition: TitledBorder.TOP), - constraints: gbc(gridx: 0, gridy: gridy++, fill: GridBagConstraints.BOTH, weightx: 100)) { + borderLayout() + panel(constraints: BorderLayout.CENTER) { gridBagLayout() - label(text : trans("SIZE"), constraints: gbc(gridx: 0, gridy: 0)) - label(text : String.valueOf(model.resultEvent.size), constraints: gbc(gridx: 1, gridy: 0)) - label(text : trans("PIECE_SIZE"), constraints: gbc(gridx: 0, gridy : 1)) - 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) - scrollPane { - textArea(text: model.resultEvent.comment, editable: false, lineWrap: true, wrapStyleWord: true) + int gridy = 0 + panel(border: titledBorder(title: trans("BASIC_DETAILS"), border: etchedBorder(), titlePosition: TitledBorder.TOP), + constraints: gbc(gridx: 0, gridy: gridy++, fill: GridBagConstraints.BOTH, weightx: 100)) { + gridBagLayout() + label(text: trans("SIZE"), constraints: gbc(gridx: 0, gridy: 0)) + label(text: String.valueOf(model.resultEvent.size), constraints: gbc(gridx: 1, gridy: 0)) + label(text: trans("PIECE_SIZE"), constraints: gbc(gridx: 0, gridy: 1)) + 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) + scrollPane { + textArea(text: model.resultEvent.comment, editable: false, lineWrap: true, wrapStyleWord: true) + } } } - } - 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) - scrollPane { - table(autoCreateRowSorter : true, rowHeight: rowHeight) { - tableModel(list : model.senders.toList()) { - closureColumn(header : trans("SENDER"), read : {it.getHumanReadableName()}) - closureColumn(header : trans("TRUST_NOUN"), read :{ - Destination destination = it.destination - trans(model.core.trustService.getLevel(destination).name()) - }) + 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) + scrollPane { + table(autoCreateRowSorter: true, rowHeight: rowHeight) { + tableModel(list: model.senders.toList()) { + closureColumn(header: trans("SENDER"), read: { it.getHumanReadableName() }) + closureColumn(header: trans("TRUST_NOUN"), read: { + Destination destination = it.destination + trans(model.core.trustService.getLevel(destination).name()) + }) + } } } } } - } - 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.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) + } } } - 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) - } + panel(constraints: BorderLayout.SOUTH) { + button(text : trans("CLOSE"), closeAction) } }