1 |
|
package org.kuali.student.common.ui.client.widgets.table.summary; |
2 |
|
|
3 |
|
import java.util.HashMap; |
4 |
|
|
5 |
|
import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrPanel; |
6 |
|
|
7 |
|
import com.google.gwt.user.client.Element; |
8 |
|
import com.google.gwt.user.client.ui.Anchor; |
9 |
|
import com.google.gwt.user.client.ui.FlexTable; |
10 |
|
import com.google.gwt.user.client.ui.HasVerticalAlignment; |
11 |
|
import com.google.gwt.user.client.ui.HorizontalPanel; |
12 |
|
import com.google.gwt.user.client.ui.Label; |
13 |
|
|
|
|
| 0% |
Uncovered Elements: 137 (137) |
Complexity: 37 |
Complexity Density: 0.44 |
|
14 |
|
public class SummaryTable extends FlexTable{ |
15 |
|
private SummaryTableModel model = new SummaryTableModel(); |
16 |
|
private int rowIndex = 0; |
17 |
|
private HashMap<String, Integer> rowMap = new HashMap<String, Integer>(); |
18 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
19 |
0
|
public SummaryTable(){... |
20 |
0
|
setStyleName("summaryTable"); |
21 |
|
|
22 |
0
|
getColumnFormatter().setStyleName(0, "rowTitleColunm"); |
23 |
0
|
getColumnFormatter().setStyleName(1, "cell1Colunm"); |
24 |
0
|
getColumnFormatter().setStyleName(2, "cell2Colunm"); |
25 |
|
} |
26 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
27 |
0
|
public SummaryTableModel getModel() {... |
28 |
0
|
return model; |
29 |
|
} |
30 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
31 |
0
|
public void setModel(SummaryTableModel model) {... |
32 |
0
|
this.model = model; |
33 |
0
|
doLayout(); |
34 |
|
} |
35 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
36 |
0
|
public void doLayout(){... |
37 |
0
|
rowIndex = 0; |
38 |
0
|
this.removeAllRows(); |
39 |
0
|
if(model.getContentColumnHeader1() != null && model.getContentColumnHeader2() != null){ |
40 |
0
|
super.setText(rowIndex, 1, model.getContentColumnHeader1()); |
41 |
0
|
super.setText(rowIndex, 2, model.getContentColumnHeader2()); |
42 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,1, "columnTitle"); |
43 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,2, "columnTitle"); |
44 |
|
|
45 |
0
|
rowIndex++; |
46 |
|
} |
47 |
0
|
for(SummaryTableBlock section: model.getSectionList()){ |
48 |
0
|
addSection(section); |
49 |
|
} |
50 |
|
|
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 6 |
Complexity Density: 0.86 |
|
53 |
0
|
public void markDiffs(String style){... |
54 |
|
|
55 |
0
|
for(int i = 1; i < rowIndex; i++){ |
56 |
0
|
if(getFlexCellFormatter().getColSpan(i, 0) == 1 && getFlexCellFormatter().getColSpan(i, 1) == 1 |
57 |
|
&& getFlexCellFormatter().getColSpan(i, 2) == 1){ |
58 |
0
|
Element cell1 = this.getCellFormatter().getElement(i, 1); |
59 |
0
|
Element cell2 = this.getCellFormatter().getElement(i, 2); |
60 |
0
|
if(!cell1.getInnerText().equals(cell2.getInnerText())){ |
61 |
0
|
this.getRowFormatter().addStyleName(i, style); |
62 |
|
} |
63 |
|
else{ |
64 |
0
|
this.getRowFormatter().removeStyleName(i, style); |
65 |
|
} |
66 |
|
} |
67 |
|
} |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0
|
public boolean containsKey(String key){... |
71 |
0
|
return rowMap.containsKey(key); |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
74 |
0
|
public void highlightRow(String rowKey, String style){... |
75 |
0
|
if(rowMap.containsKey(rowKey)){ |
76 |
0
|
this.getRowFormatter().setStyleName(rowMap.get(rowKey).intValue(), style); |
77 |
|
} |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
80 |
0
|
public void clearHighlightRow(String rowKey, String removeThisStyle){... |
81 |
0
|
if(rowMap.containsKey(rowKey)){ |
82 |
0
|
this.getRowFormatter().removeStyleName(rowMap.get(rowKey).intValue(), removeThisStyle); |
83 |
|
} |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
86 |
0
|
public void clearHighlightedRows(String removeThisStyle){... |
87 |
0
|
for(int i = 0; i < rowIndex; i++){ |
88 |
0
|
this.getRowFormatter().removeStyleName(i, removeThisStyle); |
89 |
|
} |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
92 |
0
|
public void highlightCell(String rowKey, int cellIndex, String style){... |
93 |
0
|
if(rowMap.containsKey(rowKey)){ |
94 |
0
|
this.getCellFormatter().setStyleName(rowMap.get(rowKey).intValue(),cellIndex, style); |
95 |
|
} |
96 |
|
} |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
98 |
0
|
public void clearHighlightCell(String rowKey, int cellIndex){... |
99 |
0
|
if(rowMap.containsKey(rowKey)){ |
100 |
0
|
this.getCellFormatter().setStyleName(rowMap.get(rowKey).intValue(),cellIndex,""); |
101 |
|
} |
102 |
|
|
103 |
|
} |
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 6 |
Complexity Density: 0.26 |
|
104 |
0
|
private void addSection(SummaryTableBlock section){... |
105 |
0
|
int topRowIndex = -1; |
106 |
0
|
if(section.getTitle() != null && !section.getTitle().isEmpty()){ |
107 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,0, "sectionTitleRow"); |
108 |
0
|
getFlexCellFormatter().setColSpan(rowIndex, 0, 3); |
109 |
0
|
getFlexCellFormatter().setVerticalAlignment(rowIndex, 0, HasVerticalAlignment.ALIGN_BOTTOM); |
110 |
0
|
HorizontalPanel sectionTitlePanel = new HorizontalPanel(); |
111 |
0
|
Label sectionTitle = new Label(section.getTitle()); |
112 |
0
|
sectionTitlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); |
113 |
0
|
sectionTitle.setStyleName("sectionTitle"); |
114 |
0
|
sectionTitlePanel.add(sectionTitle); |
115 |
|
|
116 |
0
|
if(model.isEditable()){ |
117 |
0
|
Anchor sectionEditLink = new Anchor("Edit"); |
118 |
0
|
sectionEditLink.setStyleName("sectionEditLink"); |
119 |
0
|
if(section.getEditingHandler() != null){ |
120 |
0
|
sectionEditLink.addClickHandler(section.getEditingHandler()); |
121 |
|
} |
122 |
0
|
sectionTitlePanel.add(sectionEditLink); |
123 |
|
|
124 |
|
} |
125 |
0
|
setWidget(rowIndex,0, sectionTitlePanel); |
126 |
0
|
rowIndex++; |
127 |
|
} |
128 |
|
else{ |
129 |
0
|
topRowIndex = rowIndex; |
130 |
|
} |
131 |
|
|
132 |
0
|
for(SummaryTableRow row: section.getSectionRowList()){ |
133 |
0
|
addSectionRow(row); |
134 |
|
} |
135 |
|
|
136 |
0
|
if(topRowIndex != -1){ |
137 |
0
|
this.getRowFormatter().addStyleName(topRowIndex, "firstRowInUnnamedBlock"); |
138 |
|
} |
139 |
|
|
140 |
|
} |
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 8 |
Complexity Density: 0.31 |
|
141 |
0
|
private void addSectionRow(SummaryTableRow row){... |
142 |
0
|
if(row.isShown()){ |
143 |
0
|
if(row.isRequired()){ |
144 |
0
|
AbbrPanel required = new AbbrPanel("Required", "ks-form-module-elements-required", " * "); |
145 |
0
|
setHTML(rowIndex,0, row.getTitle() + required.toString()); |
146 |
|
} |
147 |
|
else{ |
148 |
0
|
setText(rowIndex,0, row.getTitle()); |
149 |
|
} |
150 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,0, "rowTitle"); |
151 |
0
|
if(row.getTitleCellStyleName() != null){ |
152 |
0
|
getFlexCellFormatter().addStyleName(rowIndex,0, row.getTitleCellStyleName()); |
153 |
|
} |
154 |
0
|
if(row.getContentCellCount() == 1){ |
155 |
0
|
setWidget(rowIndex,1, row.getCell1()); |
156 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,1, "cell1"); |
157 |
0
|
getFlexCellFormatter().setColSpan(rowIndex, 1,2); |
158 |
0
|
if(row.getContentCellStyleName() != null){ |
159 |
0
|
getFlexCellFormatter().addStyleName(rowIndex,1, row.getContentCellStyleName()); |
160 |
|
} |
161 |
0
|
}else if(row.getContentCellCount() == 2){ |
162 |
0
|
setWidget(rowIndex,1, row.getCell1()); |
163 |
0
|
setWidget(rowIndex,2,row.getCell2()); |
164 |
0
|
getFlexCellFormatter().setColSpan(rowIndex, 1,1); |
165 |
0
|
getFlexCellFormatter().setColSpan(rowIndex, 2,1); |
166 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,1, "cell1"); |
167 |
0
|
getFlexCellFormatter().setStyleName(rowIndex,2, "cell2"); |
168 |
0
|
if(row.getContentCellStyleName() != null){ |
169 |
0
|
getFlexCellFormatter().addStyleName(rowIndex,1, row.getContentCellStyleName()); |
170 |
0
|
getFlexCellFormatter().addStyleName(rowIndex,2, row.getContentCellStyleName()); |
171 |
|
} |
172 |
|
} |
173 |
0
|
rowMap.put(row.getKey(), rowIndex); |
174 |
0
|
rowIndex++; |
175 |
|
} |
176 |
|
} |
177 |
|
|
178 |
|
} |