1 13 package com.tonbeller.wcf.table; 14 import java.util.Comparator ; 15 16 24 25 public class TableColumn { 26 27 private boolean descending = false; 28 private boolean sortable = true; 29 private Comparator comparator; 30 private CellRenderer renderer; 31 private int columnIndex; 32 private boolean hidden = false; 33 34 public TableColumn(int columnIndex) { 35 this.columnIndex = columnIndex; 36 comparator = new Comparator () { 37 public int compare(Object o1, Object o2) { 38 if (o1 instanceof Boolean ) { 39 boolean b1 = ((Boolean ) o1).booleanValue(); 40 boolean b2 = ((Boolean ) o2).booleanValue(); 41 if (b1 == b2) 42 return 0; 43 if (b1) 44 return 1; 45 return -1; 46 } 47 return ((Comparable ) o1).compareTo(o2); 48 } 49 }; 50 renderer = new DefaultCellRenderer(); 51 } 52 53 public void setDescending(boolean newDescending) { 54 descending = newDescending; 55 } 56 public boolean isDescending() { 57 return descending; 58 } 59 public void setComparator(Comparator newComparator) { 60 comparator = newComparator; 61 } 62 public Comparator getComparator() { 63 return comparator; 64 } 65 public void setCellRenderer(CellRenderer newRenderer) { 66 renderer = newRenderer; 67 } 68 public CellRenderer getCellRenderer() { 69 return renderer; 70 } 71 public void setSortable(boolean newSortable) { 72 sortable = newSortable; 73 } 74 public boolean isSortable() { 75 return sortable; 76 } 77 78 89 public int getColumnIndex() { 90 return columnIndex; 91 } 92 public void setHidden(boolean newHidden) { 93 hidden = newHidden; 94 } 95 public boolean isHidden() { 96 return hidden; 97 } 98 } 99 | Popular Tags |