1 /*********************************************************************
5 * Purpose : Sorting JTable model.
7 * Copyright : Written by and Copyright (C) 2003 the SourceForge
8 * Privoxy team. http://www.privoxy.org/
10 * Based on the Internet Junkbuster originally written
11 * by and Copyright (C) 1997 Anonymous Coders and
12 * Junkbusters Corporation. http://www.junkbusters.com
14 * This program is free software; you can redistribute it
15 * and/or modify it under the terms of the GNU General
16 * Public License as published by the Free Software
17 * Foundation; either version 2 of the License, or (at
18 * your option) any later version.
20 * This program is distributed in the hope that it will
21 * be useful, but WITHOUT ANY WARRANTY; without even the
22 * implied warranty of MERCHANTABILITY or FITNESS FOR A
23 * PARTICULAR PURPOSE. See the GNU General Public
24 * License for more details.
26 * The GNU General Public License should be included with
27 * this file. If not, you can view it at
28 * http://www.gnu.org/copyleft/gpl.html
29 * or write to the Free Software Foundation, Inc., 59
30 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 *********************************************************************/
36 package org.privoxy.activityconsole;
41 import javax.swing.table.*;
44 * Sorting JTable table model.
45 * @author Last Modified By: $Author$
46 * @version $Rev$-$Date$$State$
48 public class SortableTableModel extends DefaultTableModel
51 private static final String
52 COPYRIGHT = org.privoxy.activityconsole.Copyright.COPYRIGHT;
57 public SortableTableModel()
61 public SortableTableModel(Vector data, Vector columnNames)
63 super(data, columnNames);
65 public Object getValueAt(int row, int col)
70 rowIndex = indexes[row];
72 return super.getValueAt(rowIndex, col);
75 public void setValueAt(Object value, int row, int col)
80 rowIndex = indexes[row];
82 super.setValueAt(value, rowIndex, col);
85 public void sortByColumn(int column, boolean isAscent)
89 sorter = new TableSorter(this);
91 sorter.sort(column, isAscent);
92 fireTableDataChanged();
95 public int[] getIndexes()
97 int n = getRowCount();
100 if (indexes.length == n)
105 indexes = new int[n];
106 for (int i=0; i<n; i++)