View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.gui.table;
21  
22  /***
23   * Defines the requirements for tables that can be sorted.
24   *
25   * @see TableHeaderHandler
26   */
27  public interface SortableModel
28  {
29  
30      /***
31       * Returns the class of the data objects in column at
32       * <code>index</code>.
33       *
34       * @see TableHeaderHandler#sortByColumn(int)
35       */
36      Class getColumnClass(int index);
37  
38      /***
39       * Returns the index of the column that was sorted last.
40       */
41      int getSortedColumn();
42  
43      /***
44       * Returns true, if the table is sorted in ascending order.
45       */
46      boolean isSortedAscending();
47  
48      /***
49       * Sets the maintain sort order flag.
50       */
51      void setMaintainSortOrder(boolean maintainSortOrder);
52  
53      /***
54       * Sort the table by <code>column</code>.
55       *
56       * @param column the column to sort
57       * @param ascending true, if table needs to be sorted in ascending order; 
58       *                  false, if in descending order
59       * @param revert automatically revert sort order 
60       * @return true, if table was sorted ascending; false, if descending
61       */
62      boolean sortByColumn(int column, boolean ascending, boolean revert);
63          
64  }