1
2
3
4 package net.sourceforge.jsh3modtool.gui.imagetable.cellsorters;
5
6 /***
7 * A cell sorter that sorts the filenames of the cells.
8 *
9 * @author erma
10 */
11 public class FilenameCellSorter extends AbstractCellSorter
12 {
13 private boolean sortAscending;
14
15 /***
16 * Creates a CellNameSorter that sorts the file list ascended.
17 */
18 public FilenameCellSorter()
19 {
20 this( true );
21 }
22
23 /***
24 * Creates a CellNameSorter that sorts the file list.
25 * @param ascending if the list should be ascending or not.
26 */
27 public FilenameCellSorter(boolean ascending)
28 {
29 sortAscending = ascending;
30 }
31
32 /*** {@inheritDoc} */
33 public int compare(Object o1, Object o2)
34 {
35 String name1 = getFileName(o1);
36 String name2 = getFileName(o2);
37 int value;
38 if ( sortAscending )
39 {
40 value = name1.toLowerCase().compareTo(name2.toLowerCase());
41 }
42 else
43 {
44 value = name2.toLowerCase().compareTo(name1.toLowerCase());
45 }
46 return value;
47 }
48 }
49
50 /***
51 * Revision history
52 *
53 * $Log: P:/scm_db/archives/iWIP/iWIP Client Java/src/com/imbridge/iwip/client/browsegui/browsertable/cellsorters/FilenameCellSorter.java-arc $
54 *
55 * Rev 1.0 Jun 12 2003 10:10:54 Erik Mattsson
56 * Initial revision.
57 */