View Javadoc

1   package org.kuali.student.common.ui.client.widgets.table.scroll;
2   
3   import com.google.gwt.user.client.ui.Label;
4   import com.google.gwt.user.client.ui.Widget;
5   
6   /**
7    * Column definition for table column.
8    * 
9    * 
10   * */
11  public class Column {
12  	/** Ascending order. */
13  	public final static int Ascending = 1;
14  	/** Descending order */
15  	public final static int Descending = 2;
16  	/** Not sorted */
17  	public final static int NotOrdered = 3;
18      
19  	private Widget columnTitleWidget;
20  	private String id;
21  	private String name = "";
22  	private String width;
23  	private int sortDirection = NotOrdered;
24  	private boolean isVisible = true;
25  	private boolean isSortable;
26  
27  	private RowComparator ascendingRowComparator;
28  	private RowComparator descendingRowComparator;
29  
30  	/**
31  	 * Get the row comparator.
32  	 * */
33  	public RowComparator getComparator() {
34  		if (this.sortDirection == Ascending) {
35  			return ascendingRowComparator;
36  		} else if (this.sortDirection == Descending) {
37  			return descendingRowComparator;
38  		} else {
39  			return null;
40  		}
41  	}
42      /** Get comparator for ascending sort*/
43  	public RowComparator getAscendingRowComparator() {
44  		return ascendingRowComparator;
45  	}
46  
47  	public void setAscendingRowComparator(RowComparator ascendingRowComparator) {
48  		this.ascendingRowComparator = ascendingRowComparator;
49  		this.isSortable = true;
50  	}
51  
52  	public RowComparator getDescendingRowComparator() {
53  		return descendingRowComparator;
54  	}
55  
56  	public void setDescendingRowComparator(RowComparator descedingRowcomparator) {
57  		this.descendingRowComparator = descedingRowcomparator;
58  		this.isSortable = true;
59  	}
60  
61  	public boolean isVisible() {
62  		return isVisible;
63  	}
64  
65  	public void setVisible(boolean isVisible) {
66  		this.isVisible = isVisible;
67  	}
68  
69  	public Widget getColumnTitleWidget() {
70  		if (columnTitleWidget == null) {
71  			return new Label(name);
72  		}
73  
74  		return columnTitleWidget;
75  	}
76  
77  	public void setColumnTitleWidget(Widget c) {
78  		columnTitleWidget = c;
79  	}
80  
81  	public String getId() {
82  		return id;
83  	}
84  
85  	public void setId(String id) {
86  		this.id = id;
87  	}
88  
89  	public boolean isSortable() {
90  		return isSortable;
91  	}
92  
93  	public void setSortable(boolean isSortable) {
94  		this.isSortable = isSortable;
95  	}
96  
97  	public String getName() {
98  		return name;
99  	}
100 
101 	public void setName(String name) {
102 		this.name = name;
103 	}
104 
105 	public String getWidth() {
106 		return width;
107 	}
108 
109 	public void setWidth(String width) {
110 		this.width = width;
111 	}
112 
113 	public void changeSortDirection() {
114 		if (this.sortDirection == NotOrdered) {
115 			this.sortDirection = Ascending;
116 		} else if (this.sortDirection == Ascending) {
117 			this.sortDirection = Descending;
118 		} else if (this.sortDirection == Descending) {
119 			this.sortDirection = Ascending;
120 		}
121 	}
122 
123 	public void setSortDirection(int sortDirection) {
124 		this.sortDirection = sortDirection;
125 	}
126 
127 	public int getSortDirection() {
128 		return sortDirection;
129 	}
130 
131 	public void setSortedType(int direction) {
132 		sortDirection = direction;
133 	}
134 }