| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.common.ui.client.widgets.pagetable; |
| 17 |
|
import java.util.ArrayList; |
| 18 |
|
import java.util.List; |
| 19 |
|
|
| 20 |
|
import org.kuali.student.common.dto.Idable; |
| 21 |
|
import org.kuali.student.common.ui.client.widgets.searchtable.ResultRow; |
| 22 |
|
|
| 23 |
|
import com.google.gwt.gen2.table.client.AbstractColumnDefinition; |
| 24 |
|
import com.google.gwt.gen2.table.client.CellRenderer; |
| 25 |
|
import com.google.gwt.gen2.table.client.ColumnDefinition; |
| 26 |
|
import com.google.gwt.gen2.table.client.DefaultTableDefinition; |
| 27 |
|
import com.google.gwt.gen2.table.client.PagingScrollTable; |
| 28 |
|
import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy; |
| 29 |
|
import com.google.gwt.gen2.table.client.TableDefinition.AbstractCellView; |
| 30 |
|
import com.google.gwt.user.client.ui.HTML; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@see |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
@see |
| 51 |
|
@see |
| 52 |
|
@see |
| 53 |
|
@author |
| 54 |
|
|
| 55 |
|
|
|
|
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 11 |
Complexity Density: 0.37 |
|
| 56 |
|
public class PagingScrollTableBuilder<RowType extends Idable> { |
| 57 |
|
private PagingScrollTable<RowType> pagingScrollTable; |
| 58 |
|
private int tablePixelWidth = 0; |
| 59 |
|
private int tablePixelHeight = 0; |
| 60 |
|
private boolean isPagable = false; |
| 61 |
|
private int numPageRows = 0; |
| 62 |
|
private int numPages = 0; |
| 63 |
|
private SelectionPolicy selectionPolicy = SelectionPolicy.MULTI_ROW; |
| 64 |
|
private List<AbstractColumnDefinition<RowType, ?>> columnDefs; |
| 65 |
|
private List<Integer> columnPixelWidths = new ArrayList<Integer>(); |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 72 |
0
|
public PagingScrollTableBuilder() {... |
| 73 |
0
|
super(); |
| 74 |
|
} |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
@param |
| 82 |
|
@param |
| 83 |
|
@return |
| 84 |
|
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 85 |
0
|
public PagingScrollTableBuilder<RowType> tablePixelSize(int tablePixelWidth,int tablePixelHeight) {... |
| 86 |
0
|
this.tablePixelWidth = tablePixelWidth; |
| 87 |
0
|
this.tablePixelHeight = tablePixelHeight; |
| 88 |
0
|
return this; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
@param |
| 96 |
|
@param |
| 97 |
|
@return |
| 98 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 99 |
0
|
public PagingScrollTableBuilder<RowType> cacheTable(int numPageRows,int numPages) {... |
| 100 |
0
|
this.numPageRows = numPageRows; |
| 101 |
0
|
this.numPages = numPages; |
| 102 |
0
|
this.isPagable = true; |
| 103 |
0
|
return this; |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
@see |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
@param |
| 120 |
|
@return |
| 121 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 122 |
0
|
public PagingScrollTableBuilder<RowType> columnDefinitions(List<AbstractColumnDefinition<RowType, ?>> columnDefs) {... |
| 123 |
0
|
this.columnDefs = columnDefs; |
| 124 |
0
|
return this; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
@since |
| 132 |
|
@param |
| 133 |
|
@return |
| 134 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 135 |
0
|
public PagingScrollTableBuilder<RowType> setSelectionPolicy(SelectionPolicy selectionPolicy){... |
| 136 |
0
|
this.selectionPolicy = selectionPolicy; |
| 137 |
0
|
return this; |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
@return |
| 145 |
|
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 3 |
Complexity Density: 0.19 |
|
| 146 |
0
|
@SuppressWarnings("unchecked")... |
| 147 |
|
public PagingScrollTable<RowType> build(GenericTableModel tableModel) { |
| 148 |
0
|
DefaultTableDefinition<RowType> tableDefinition = new DefaultTableDefinition<RowType>(); |
| 149 |
0
|
if(columnDefs!=null){ |
| 150 |
0
|
for (AbstractColumnDefinition columnDef: columnDefs) { |
| 151 |
0
|
columnPixelWidths.add(columnDef.getPreferredColumnWidth()); |
| 152 |
0
|
CellRenderer renderer = new CellRenderer(){ |
| 153 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 3 |
Complexity Density: 1.5 |
|
| 154 |
0
|
@Override... |
| 155 |
|
public void renderRowValue(Object rowValue, |
| 156 |
|
ColumnDefinition columnDef, AbstractCellView view) { |
| 157 |
0
|
if(rowValue!=null&& rowValue instanceof ResultRow){ |
| 158 |
0
|
view.setHTML((String)columnDef.getCellValue(rowValue)); |
| 159 |
|
} |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
}; |
| 163 |
0
|
columnDef.setCellRenderer(renderer); |
| 164 |
0
|
tableDefinition.addColumnDefinition(columnDef); |
| 165 |
|
} |
| 166 |
|
} |
| 167 |
|
|
| 168 |
0
|
if(isPagable){ |
| 169 |
0
|
pagingScrollTable = new PagingScrollTable<RowType>(tableModel.createCachedTableModel(numPageRows,numPages),tableDefinition); |
| 170 |
0
|
pagingScrollTable.setPageSize(numPageRows); |
| 171 |
|
|
| 172 |
|
}else { |
| 173 |
0
|
pagingScrollTable = new PagingScrollTable<RowType>(tableModel,tableDefinition); |
| 174 |
0
|
pagingScrollTable.setPageSize(tableModel.getRowCount()); |
| 175 |
|
} |
| 176 |
0
|
pagingScrollTable.setPixelSize(tablePixelWidth,tablePixelHeight); |
| 177 |
0
|
pagingScrollTable.setEmptyTableWidget(new HTML("There is no data to display")); |
| 178 |
|
|
| 179 |
0
|
pagingScrollTable.getDataTable().setSelectionPolicy(selectionPolicy); |
| 180 |
|
|
| 181 |
0
|
return this.pagingScrollTable; |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
} |