/hg/icedtea-web: Fix sorting in itw-settings' cache viewer
asu at icedtea.classpath.org
asu at icedtea.classpath.org
Tue May 10 08:14:08 PDT 2011
changeset 2b1a69f4c54b in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=2b1a69f4c54b
author: Andrew Su <asu at redhat.com>
date: Tue May 10 11:16:17 2011 -0400
Fix sorting in itw-settings' cache viewer
diffstat:
ChangeLog | 6 ++++
netx/net/sourceforge/jnlp/controlpanel/CachePane.java | 27 ++++++++++++++++++-
2 files changed, 32 insertions(+), 1 deletions(-)
diffs (73 lines):
diff -r 114a981d3552 -r 2b1a69f4c54b ChangeLog
--- a/ChangeLog Tue May 10 11:58:19 2011 +0200
+++ b/ChangeLog Tue May 10 11:16:17 2011 -0400
@@ -1,3 +1,9 @@
+2011-05-10 Andrew Su <asu at redhat.com>
+
+ * netx/net/sourceforge/jnlp/controlpanel/CachePane.java:
+ (addComponents):Created a new comparator for sorting by file size and
+ date.
+
2011-05-10 Jiri Vanek <jvanek at redhat.com>
* tests/junit-runner/JunitLikeXmlOutputListener: This listener exports
diff -r 114a981d3552 -r 2b1a69f4c54b netx/net/sourceforge/jnlp/controlpanel/CachePane.java
--- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java Tue May 10 11:58:19 2011 +0200
+++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java Tue May 10 11:16:17 2011 -0400
@@ -30,8 +30,11 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileLock;
+import java.text.DateFormat;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.Enumeration;
import java.util.List;
@@ -43,6 +46,7 @@
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
+import javax.swing.table.TableRowSorter;
import net.sourceforge.jnlp.cache.CacheDirectory;
import net.sourceforge.jnlp.cache.DirectoryNode;
@@ -96,7 +100,6 @@
};
cacheTable = new JTable(model);
- cacheTable.setAutoCreateRowSorter(true);
cacheTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
cacheTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
cacheTable.setPreferredScrollableViewportSize(new Dimension(600, 200));
@@ -105,6 +108,28 @@
populateTable();
+ TableRowSorter<DefaultTableModel> tableSorter = new TableRowSorter<DefaultTableModel>(model);
+ tableSorter.setComparator(4, new Comparator<Long>() { // Comparator for size column.
+ @Override
+ public int compare(Long o1, Long o2) {
+ return o1.compareTo(o2);
+ }
+ });
+ tableSorter.setComparator(5, new Comparator<String>() { // Comparator for date column.
+ @Override
+ public int compare(String o1, String o2) {
+ DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
+ try {
+ Long time1 = format.parse(o1).getTime();
+ Long time2 = format.parse(o2).getTime();
+ return time1.compareTo(time2);
+ } catch (ParseException e) {
+ return 0;
+ }
+ }
+ });
+ cacheTable.setRowSorter(tableSorter);
+
c.weightx = 1;
c.weighty = 1;
c.gridx = 0;
More information about the distro-pkg-dev
mailing list