add a Close button to result details frame

auto-update
Zlatin Balevsky 2021-12-25 18:20:47 +00:00
parent 38948034a1
commit 2128d3eac7
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 63 additions and 43 deletions

View File

@ -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()
}
}

View File

@ -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)
}
}