show collection comment

pull/53/head
Zlatin Balevsky 2020-11-01 07:40:14 +00:00
parent 6c7be05a12
commit 9bbace00bb
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 35 additions and 2 deletions

View File

@ -545,3 +545,4 @@ DELETE=Delete
## Collection tab ## Collection tab
COLLECTION_SELECT=Select a collection to view it's description COLLECTION_SELECT=Select a collection to view it's description
DESCRIPTION=Description

View File

@ -7,9 +7,13 @@ import griffon.metadata.ArtifactProviderFor
import javax.swing.JLabel import javax.swing.JLabel
import javax.swing.JTable import javax.swing.JTable
import javax.swing.JTextArea
import javax.swing.ListSelectionModel
import javax.swing.SwingConstants import javax.swing.SwingConstants
import javax.swing.table.DefaultTableCellRenderer import javax.swing.table.DefaultTableCellRenderer
import com.muwire.core.collections.FileCollection
import java.awt.BorderLayout import java.awt.BorderLayout
import javax.annotation.Nonnull import javax.annotation.Nonnull
@ -26,6 +30,7 @@ class CollectionTabView {
JTable collectionsTable JTable collectionsTable
def lastCollectionsTableSortEvent def lastCollectionsTableSortEvent
JTextArea commentArea
void initUI() { void initUI() {
int rowHeight = application.context.get("row-height") int rowHeight = application.context.get("row-height")
@ -39,7 +44,7 @@ class CollectionTabView {
label(text : trans("STATUS") + ":") label(text : trans("STATUS") + ":")
label(text : bind {trans(model.status.name())}) label(text : bind {trans(model.status.name())})
} }
scrollPane(constraints : BorderLayout.CENTER) { scrollPane(constraints : BorderLayout.CENTER, border : etchedBorder()) {
collectionsTable = table(autoCreateRowSorter : true, rowHeight : rowHeight) { collectionsTable = table(autoCreateRowSorter : true, rowHeight : rowHeight) {
tableModel(list : model.collections) { tableModel(list : model.collections) {
closureColumn(header: trans("NAME"), preferredWidth: 200, type : String, read : {it.name}) closureColumn(header: trans("NAME"), preferredWidth: 200, type : String, read : {it.name})
@ -53,7 +58,14 @@ class CollectionTabView {
} }
} }
} }
panel {} panel {
borderLayout()
panel(constraints: BorderLayout.NORTH) {
label(text : trans("DESCRIPTION"))
}
commentArea = textArea(text : bind {model.comment}, editable : false, lineWrap : true, wrapStyleWord : true, constraints : BorderLayout.CENTER,
border : etchedBorder())
}
panel {} panel {}
} }
} }
@ -91,6 +103,26 @@ class CollectionTabView {
collectionsTable.rowSorter.addRowSorterListener({evt -> lastCollectionsTableSortEvent = evt}) collectionsTable.rowSorter.addRowSorterListener({evt -> lastCollectionsTableSortEvent = evt})
collectionsTable.rowSorter.setSortsOnUpdates(true) collectionsTable.rowSorter.setSortsOnUpdates(true)
def selectionModel = collectionsTable.getSelectionModel()
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
selectionModel.addListSelectionListener({
int row = selectedCollection()
if (row < 0)
return
FileCollection selected = model.collections.get(row)
model.comment = selected.comment
})
}
int selectedCollection() {
int row = collectionsTable.getSelectedRow()
if (row < 0)
return row
if (lastCollectionsTableSortEvent != null)
row = collectionsTable.rowSorter.convertRowIndexToModel(row)
return row
} }
def closeTab = { def closeTab = {