Clover Coverage Report - Kuali Student 1.3.0-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Apr 28 2011 05:03:32 EDT
../../../../../../../../../img/srcFileCovDistChart0.png 2% of files have more coverage
68   177   36   3.24
28   149   0.53   21
21     1.71  
1    
 
  DefaultTableModel       Line # 12 68 0% 36 117 0% 0.0
 
No Tests
 
1    package org.kuali.student.common.ui.client.widgets.table.scroll;
2   
3    import com.google.gwt.event.dom.client.ClickEvent;
4    import com.google.gwt.event.dom.client.ClickHandler;
5    import com.google.gwt.user.client.DOM;
6    import com.google.gwt.user.client.ui.CheckBox;
7   
8    import java.util.ArrayList;
9    import java.util.Collections;
10    import java.util.List;
11   
 
12    public class DefaultTableModel extends AbstractTableModel {
13    private ArrayList<Column> columnList = new ArrayList<Column>();
14    private ArrayList<Row> rowList = new ArrayList<Row>();
15    private ArrayList<Column> sortedColumnList = new ArrayList<Column>();
16    private int sortableColumnCount = 1;
17    private boolean moreData = true;
18    private boolean multipleSelectable = true;
19    private int currentRowIndex;
20   
21   
22    Column rowHeader = new Column();
23   
 
24  0 toggle public void installCheckBoxRowHeaderColumn() {
25  0 columnList.remove(rowHeader);
26  0 rowHeader.setId("RowHeader");
27  0 rowHeader.setName("RowHeader");
28  0 final CheckBox checkBox = new CheckBox();
29  0 checkBox.setTabIndex(-1);
30  0 checkBox.addClickHandler(new ClickHandler() {
 
31  0 toggle @Override
32    public void onClick(ClickEvent event) {
33  0 int count = getRowCount();
34  0 for (int i = 0; i < count; i++) {
35  0 getRow(i).setSelected(checkBox.getValue());
36    }
37  0 fireTableDataChanged();
38    }
39    });
40  0 DOM.setStyleAttribute(checkBox.getElement(), "style", "padding-right: 0.8em");
41  0 rowHeader.setColumnTitleWidget(checkBox);
42  0 rowHeader.setWidth("40px");
43  0 rowHeader.setVisible(true);
44   
45  0 columnList.add(0, rowHeader);
46    }
47   
 
48  0 toggle public void addRow(Row row) {
49  0 rowList.add(row);
50    }
51   
 
52  0 toggle public void insertRow(int index, Row row) {
53  0 rowList.add(index, row);
54    }
55   
 
56  0 toggle public void addColumn(Column col) {
57  0 columnList.add(col);
58    }
59   
 
60  0 toggle public void insertColumn(int index, Column col) {
61  0 columnList.add(index, col);
62    }
63   
 
64  0 toggle public boolean isMultipleSelectable() {
65  0 return multipleSelectable;
66    }
67   
 
68  0 toggle @Override
69    public void setCurrentIndex(int index) {
70  0 if (index != currentRowIndex && currentRowIndex != -1){
71  0 if(currentRowIndex < rowList.size()){
72  0 rowList.get(currentRowIndex).setHighlighted(false);
73    }
74    }
75  0 currentRowIndex = index;
76    }
77   
 
78  0 toggle @Override
79    public int getCurrentIndex() {
80  0 return currentRowIndex;
81    }
82   
 
83  0 toggle @Override
84    public void setSelectedRow(int index) {
85  0 for (int rowIndex = 0; rowIndex < getRowCount(); rowIndex++) {
86  0 Row currentRow = rowList.get(rowIndex);
87  0 if (rowIndex == index) {
88  0 currentRow.setSelected(true);
89  0 } else if (!isMultipleSelectable()) {
90  0 currentRow.setSelected(false);
91    }
92    }
93    }
94   
 
95  0 toggle public void setMultipleSelectable(boolean value) {
96  0 multipleSelectable = value;
97    }
98   
 
99  0 toggle public void setMoreData(boolean hasMoreData) {
100  0 moreData = hasMoreData;
101    }
102   
 
103  0 toggle public boolean getMoreData() {
104  0 return moreData;
105    }
106   
 
107  0 toggle public int getRowCount() {
108  0 return rowList.size();
109    }
110   
 
111  0 toggle public void sort(Column column) {
112  0 if (column.isSortable() == false) {
113  0 return;
114    }
115  0 if (sortedColumnList.contains(column) == false) {
116  0 if (sortedColumnList.size() >= sortableColumnCount) {
117  0 Column removed = sortedColumnList.remove(0);
118  0 removed.setSortDirection(Column.NotOrdered);
119    }
120  0 sortedColumnList.add(column);
121   
122    }
123   
124  0 column.changeSortDirection();
125  0 RowComparator comparator = column.getComparator();
126  0 if (comparator != null) {
127  0 Collections.sort(rowList, comparator);
128    }
129  0 super.fireTableStructureChanged();
130    }
131   
 
132  0 toggle public Row getRow(int rowIndex) {
133  0 return rowList.get(rowIndex);
134    }
135   
 
136  0 toggle public List<Row> getSelectedRows() {
137  0 ArrayList<Row> selectedRows = new ArrayList<Row>();
138  0 for (Row row : rowList) {
139  0 if (row.isSelected()) {
140  0 selectedRows.add(row);
141    }
142    }
143  0 return selectedRows;
144    }
145   
 
146  0 toggle public Column getColumn(int columnIndex) {
147  0 ArrayList<Column> list = new ArrayList<Column>();
148  0 for (Column col : columnList) {
149  0 if (col.isVisible()) {
150  0 list.add(col);
151    }
152    }
153  0 return list.get(columnIndex);
154    }
155   
 
156  0 toggle public int getColumnCount() {
157  0 int count = 0;
158  0 for (Column col : columnList) {
159  0 if (col.isVisible()) {
160  0 count++;
161    }
162    }
163  0 return count;
164    }
165   
 
166  0 toggle public void clearRows() {
167  0 rowList = new ArrayList<Row>();
168  0 super.fireTableDataChanged();
169    }
170   
 
171  0 toggle public void selectFirstRow() {
172  0 if (!rowList.isEmpty()) {
173  0 currentRowIndex = 0;
174  0 rowList.get(0).setHighlighted(true);
175    }
176    }
177    }