From 83ee6204026e5eb912fc8f48f9b15aaa5bb88a33 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Sat, 8 Jun 2019 07:45:07 +0100 Subject: [PATCH] sort by columns --- gui/griffon-app/lifecycle/Initialize.groovy | 1 + gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy | 8 ++++---- gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gui/griffon-app/lifecycle/Initialize.groovy b/gui/griffon-app/lifecycle/Initialize.groovy index 72e7bdc2..0b084e04 100644 --- a/gui/griffon-app/lifecycle/Initialize.groovy +++ b/gui/griffon-app/lifecycle/Initialize.groovy @@ -8,6 +8,7 @@ import com.muwire.core.MuWireSettings import javax.annotation.Nonnull import javax.inject.Inject +import javax.swing.JTable import static griffon.util.GriffonApplicationUtils.isMacOSX import static groovy.swing.SwingBuilder.lookAndFeel diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 9db16431..de81d1aa 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -105,7 +105,7 @@ class MainFrameView { panel (constraints : JSplitPane.BOTTOM) { borderLayout() scrollPane (constraints : BorderLayout.CENTER) { - table(id : "downloads-table") { + table(id : "downloads-table", autoCreateRowSorter : true) { tableModel(list: model.downloads) { closureColumn(header: "Name", preferredWidth: 350, type: String, read : {row -> row.downloader.file.getName()}) closureColumn(header: "Status", preferredWidth: 50, type: String, read : {row -> row.downloader.getCurrentState()}) @@ -136,7 +136,7 @@ class MainFrameView { button(text : "Click here to share files", actionPerformed : shareFiles) } scrollPane ( constraints : BorderLayout.CENTER) { - table(id : "shared-files-table") { + table(id : "shared-files-table", autoCreateRowSorter: true) { tableModel(list : model.shared) { closureColumn(header : "Name", preferredWidth : 550, type : String, read : {row -> row.file.getAbsolutePath()}) closureColumn(header : "Size", preferredWidth : 50, type : String, @@ -213,7 +213,7 @@ class MainFrameView { panel (border : etchedBorder()){ borderLayout() scrollPane(constraints : BorderLayout.CENTER) { - table(id : "trusted-table") { + table(id : "trusted-table", autoCreateRowSorter : true) { tableModel(list : model.trusted) { closureColumn(header : "Trusted Users", type : String, read : { it.getHumanReadableName() } ) } @@ -228,7 +228,7 @@ class MainFrameView { panel (border : etchedBorder()){ borderLayout() scrollPane(constraints : BorderLayout.CENTER) { - table(id : "distrusted-table") { + table(id : "distrusted-table", autoCreateRowSorter : true) { tableModel(list : model.distrusted) { closureColumn(header: "Distrusted Users", type : String, read : { it.getHumanReadableName() } ) } diff --git a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy index ee765d1e..e64fd467 100644 --- a/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/SearchTabView.groovy @@ -32,7 +32,7 @@ class SearchTabView { def resultsTable def pane = scrollPane { resultsTable = table(id : "results-table") { - tableModel(list: model.results) { + tableModel(list: model.results, autoCreateRowSorter : true) { closureColumn(header: "Name", preferredWidth: 350, type: String, read : {row -> row.name.replace('<','_')}) closureColumn(header: "Size", preferredWidth: 50, type: String, read : {row -> DataHelper.formatSize2Decimal(row.size, false)+"B"}) closureColumn(header: "Sources", preferredWidth: 10, type : Integer, read : { row -> model.hashBucket[row.infohash].size()})