Sorting of rows implemented

This commit is contained in:
Akarshit Wal
2015-07-13 13:17:59 +05:30
parent 4f588aadcc
commit 2c0ca18ae7
2 changed files with 14 additions and 9 deletions
@@ -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<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
table.setRowSorter(sorter);
sorter.setComparator(1, contribListing.getComparator());
GroupLayout layout = new GroupLayout(this);
layout.setHorizontalGroup(layout.createParallelGroup().addComponent(scrollPane));
@@ -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.*;