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
18 import java.util.Set;
19
20 import org.kuali.student.common.ui.client.widgets.KSLabel;
21
22 import com.google.gwt.gen2.table.client.FixedWidthGrid;
23 import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
24 import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
25
26
27
28
29
30
31
32
33
34 public class TableSelectionToLabelHandler implements RowSelectionHandler {
35 private FixedWidthGrid dataTable;
36 private KSLabel selection;
37 private String labelPrefix;
38
39 public TableSelectionToLabelHandler(FixedWidthGrid dataTable, KSLabel selection) {
40 this.dataTable = dataTable;
41 this.selection = selection;
42 this.labelPrefix = selection.getText();
43 }
44
45
46
47
48
49 @Override
50 public void onRowSelection(RowSelectionEvent event) {
51 Set<Integer>selectedRows = dataTable.getSelectedRows();
52
53 int colCount = dataTable.getColumnCount();
54 StringBuilder sb = new StringBuilder(labelPrefix);
55 sb.append('\n');
56 for(Integer row:selectedRows){
57 selection.setText(labelPrefix);
58 for(int column = 0; column < colCount; column++) {
59 sb.append(dataTable.getText(row, column)).append(' ');
60 }
61 sb.append('\n');
62 }
63 selection.setText(sb.toString());
64 }
65 }