From 2c0ca18ae7ade6152f3bce6730795290499194fe Mon Sep 17 00:00:00 2001 From: Akarshit Wal Date: Mon, 13 Jul 2015 13:17:59 +0530 Subject: [PATCH] Sorting of rows implemented --- .../app/contrib/ContributionListPanel.java | 22 ++++++++++++------- .../app/contrib/ContributionTab.java | 1 - 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/src/processing/app/contrib/ContributionListPanel.java b/app/src/processing/app/contrib/ContributionListPanel.java index 56abcd4ee..b8b509230 100644 --- a/app/src/processing/app/contrib/ContributionListPanel.java +++ b/app/src/processing/app/contrib/ContributionListPanel.java @@ -116,15 +116,21 @@ public class ContributionListPanel extends JPanel implements Scrollable, Contrib table.setCellSelectionEnabled(false); table.setAutoCreateColumnsFromModel(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - table.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ - public void valueChanged(ListSelectionEvent event) { - //TODO this executes 2 times when clicked and 1 time when traversed using arrow keys - //Ideally this should always be true but while clearing the table something fishy is going on - if(table.getSelectedRow() != -1){ - setSelectedPanel(panelByContribution.get(table.getValueAt(table.getSelectedRow(), 0))); + table.getSelectionModel() + .addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent event) { + //TODO this executes 2 times when clicked and 1 time when traversed using arrow keys + //Ideally this should always be true but while clearing the table something fishy is going on + if (table.getSelectedRow() != -1) { + setSelectedPanel(panelByContribution.get(table.getValueAt(table + .getSelectedRow(), 0))); + } } - } - }); + }); + + TableRowSorter sorter = new TableRowSorter(table.getModel()); + table.setRowSorter(sorter); + sorter.setComparator(1, contribListing.getComparator()); GroupLayout layout = new GroupLayout(this); layout.setHorizontalGroup(layout.createParallelGroup().addComponent(scrollPane)); diff --git a/app/src/processing/app/contrib/ContributionTab.java b/app/src/processing/app/contrib/ContributionTab.java index 1d3d3f443..7413b1675 100644 --- a/app/src/processing/app/contrib/ContributionTab.java +++ b/app/src/processing/app/contrib/ContributionTab.java @@ -23,7 +23,6 @@ package processing.app.contrib; import java.awt.Color; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.Font; import java.awt.event.*; import java.util.*;