| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.student.lum.common.client.lo; |
| 17 |
|
|
| 18 |
|
import java.util.ArrayList; |
| 19 |
|
import java.util.List; |
| 20 |
|
|
| 21 |
|
import org.kuali.student.common.assembly.data.Metadata; |
| 22 |
|
import org.kuali.student.common.ui.client.application.Application; |
| 23 |
|
import org.kuali.student.common.ui.client.configurable.mvc.CanProcessValidationResults; |
| 24 |
|
import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor; |
| 25 |
|
import org.kuali.student.common.ui.client.configurable.mvc.sections.Section; |
| 26 |
|
import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection; |
| 27 |
|
import org.kuali.student.common.ui.client.widgets.KSButton; |
| 28 |
|
import org.kuali.student.common.ui.client.widgets.KSLabel; |
| 29 |
|
import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle; |
| 30 |
|
import org.kuali.student.common.ui.client.widgets.list.SelectionChangeEvent; |
| 31 |
|
import org.kuali.student.common.ui.client.widgets.list.SelectionChangeHandler; |
| 32 |
|
import org.kuali.student.common.ui.client.widgets.search.KSPicker; |
| 33 |
|
import org.kuali.student.common.validation.dto.ValidationResultInfo; |
| 34 |
|
import org.kuali.student.common.validation.dto.ValidationResultInfo.ErrorLevel; |
| 35 |
|
import org.kuali.student.lum.common.client.lu.LUUIConstants; |
| 36 |
|
|
| 37 |
|
import com.google.gwt.event.dom.client.ChangeEvent; |
| 38 |
|
import com.google.gwt.event.dom.client.ChangeHandler; |
| 39 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
| 40 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
| 41 |
|
import com.google.gwt.event.logical.shared.ValueChangeEvent; |
| 42 |
|
import com.google.gwt.event.logical.shared.ValueChangeHandler; |
| 43 |
|
import com.google.gwt.event.shared.HandlerRegistration; |
| 44 |
|
import com.google.gwt.user.client.ui.HasValue; |
| 45 |
|
import com.google.gwt.user.client.ui.HorizontalPanel; |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
@author |
| 57 |
|
|
| 58 |
|
|
|
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 16 |
Complexity Density: 0.43 |
|
| 59 |
|
public class LOBuilder extends VerticalSection implements HasValue<List<OutlineNode<LOPicker>>>, CanProcessValidationResults { |
| 60 |
|
|
| 61 |
|
private static String type; |
| 62 |
|
private static String state; |
| 63 |
|
private static String repoKey; |
| 64 |
|
private static String messageGroup; |
| 65 |
|
private static String startOfPath; |
| 66 |
|
private static String endOfPath = "loInfo/desc/plain"; |
| 67 |
|
private static String middleOfPath = "loDisplayInfoList"; |
| 68 |
|
HorizontalPanel searchMainPanel = new HorizontalPanel(); |
| 69 |
|
KSPicker searchWindow; |
| 70 |
|
|
| 71 |
|
LearningObjectiveList loList; |
| 72 |
|
KSLabel instructions; |
| 73 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 74 |
0
|
protected LOBuilder() {... |
| 75 |
|
} |
| 76 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 2 |
Complexity Density: 0.11 |
|
| 77 |
0
|
public LOBuilder(String luType, String luState, String luGroup, String loRepoKey, String queryPathStart, final Metadata metadata) {... |
| 78 |
0
|
super(); |
| 79 |
|
|
| 80 |
0
|
type = luType; |
| 81 |
0
|
state = luState; |
| 82 |
0
|
repoKey = loRepoKey; |
| 83 |
0
|
messageGroup = luGroup; |
| 84 |
0
|
startOfPath = queryPathStart; |
| 85 |
|
|
| 86 |
0
|
if(metadata.getInitialLookup() != null) { |
| 87 |
0
|
searchWindow = new KSPicker(metadata.getInitialLookup(), metadata.getAdditionalLookups()); |
| 88 |
0
|
searchWindow.addValuesChangeHandler(new ValueChangeHandler<List<String>>() { |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 89 |
0
|
public void onValueChange(ValueChangeEvent<List<String>> event) {... |
| 90 |
0
|
List<String> selection = event.getValue(); |
| 91 |
0
|
loList.addSelectedLOs(selection); |
| 92 |
|
} |
| 93 |
|
} |
| 94 |
|
); |
| 95 |
0
|
searchMainPanel.add(searchWindow); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
0
|
instructions = new KSLabel(getLabel(LUUIConstants.LO_INSTRUCTIONS_KEY)); |
| 100 |
|
|
| 101 |
0
|
loList = new LearningObjectiveList(); |
| 102 |
|
|
| 103 |
0
|
searchMainPanel.addStyleName("KS-LOBuilder-Search-Panel"); |
| 104 |
|
|
| 105 |
0
|
loList.addStyleName(LUUIConstants.STYLE_SECTION); |
| 106 |
0
|
loList.addStyleName(LUUIConstants.STYLE_SECTION_DIVIDER); |
| 107 |
|
|
| 108 |
0
|
instructions.addStyleName("KS-LOBuilder-Instructions"); |
| 109 |
|
|
| 110 |
0
|
this.addWidget(searchMainPanel); |
| 111 |
0
|
this.addWidget(instructions); |
| 112 |
0
|
this.addSection(loList); |
| 113 |
|
} |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
@see |
| 117 |
|
|
| 118 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 119 |
0
|
@Override... |
| 120 |
|
public void setValue(List<OutlineNode<LOPicker>> value, boolean fireEvents) { |
| 121 |
0
|
setValue(value); |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
@see |
| 126 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 127 |
0
|
@Override... |
| 128 |
|
public void setValue(List<OutlineNode<LOPicker>> data) { |
| 129 |
0
|
loList.setValue(data); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
@see |
| 134 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 135 |
0
|
@Override... |
| 136 |
|
public List<OutlineNode<LOPicker>> getValue() { |
| 137 |
0
|
return loList.getValue(); |
| 138 |
|
} |
| 139 |
|
|
| 140 |
|
|
| 141 |
|
@see |
| 142 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 143 |
0
|
@Override... |
| 144 |
|
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<List<OutlineNode<LOPicker>>> handler) { |
| 145 |
0
|
return loList.addValueChangeHandler(handler); |
| 146 |
|
} |
| 147 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 148 |
0
|
private static String getLabel(String labelKey) {... |
| 149 |
0
|
return Application.getApplicationContext().getUILabel(messageGroup, |
| 150 |
|
type, state, labelKey); |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
|
| 154 |
|
@return |
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
0
|
public static String getType() {... |
| 157 |
0
|
return type; |
| 158 |
|
} |
| 159 |
|
|
| 160 |
|
|
| 161 |
|
@return |
| 162 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 163 |
0
|
public static String getState() {... |
| 164 |
0
|
return state; |
| 165 |
|
} |
| 166 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 167 |
0
|
public static String getRepoKey() {... |
| 168 |
0
|
return repoKey; |
| 169 |
|
} |
| 170 |
|
|
| 171 |
|
|
| 172 |
|
@return |
| 173 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 174 |
0
|
public static String getMessageGroup() {... |
| 175 |
0
|
return messageGroup; |
| 176 |
|
} |
| 177 |
|
|
|
|
|
| 0% |
Uncovered Elements: 84 (84) |
Complexity: 21 |
Complexity Density: 0.36 |
|
| 178 |
|
public static class LearningObjectiveList extends VerticalSection implements HasValue<List<OutlineNode<LOPicker>>> { |
| 179 |
|
OutlineNodeModel<LOPicker> outlineModel = new OutlineNodeModel<LOPicker>(); |
| 180 |
|
KSButton addNew; |
| 181 |
|
OutlineManager outlineComposite; |
| 182 |
|
|
| 183 |
|
SelectionChangeHandler loPickerChangeHandler = new SelectionChangeHandler(){ |
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 184 |
0
|
public void onSelectionChange(SelectionChangeEvent event) {... |
| 185 |
0
|
fireChangeEvent(); |
| 186 |
|
} |
| 187 |
|
}; |
| 188 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 189 |
0
|
public LearningObjectiveList() {... |
| 190 |
0
|
addNew = new KSButton("Add item", ButtonStyle.SECONDARY, new ClickHandler() { |
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 191 |
0
|
public void onClick(ClickEvent event) {... |
| 192 |
0
|
setValue(getValue()); |
| 193 |
0
|
appendLO(""); |
| 194 |
0
|
reDraw(); |
| 195 |
|
} |
| 196 |
|
}); |
| 197 |
|
|
| 198 |
0
|
addNew.addStyleName("KS-LOBuilder-New"); |
| 199 |
|
|
| 200 |
0
|
outlineModel.addChangeHandler(new ChangeHandler() { |
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 201 |
0
|
public void onChange(ChangeEvent event) {... |
| 202 |
0
|
reDraw(); |
| 203 |
0
|
fireChangeEvent(); |
| 204 |
|
} |
| 205 |
|
}); |
| 206 |
|
|
| 207 |
0
|
initEmptyLoList(); |
| 208 |
|
} |
| 209 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 210 |
0
|
protected void initEmptyLoList(){... |
| 211 |
0
|
List<String> list = new ArrayList<String>(); |
| 212 |
0
|
list.add(""); |
| 213 |
0
|
list.add(""); |
| 214 |
0
|
list.add(""); |
| 215 |
0
|
list.add(""); |
| 216 |
0
|
list.add(""); |
| 217 |
0
|
addSelectedLOs(list); |
| 218 |
|
} |
| 219 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 220 |
0
|
protected void fireChangeEvent(){... |
| 221 |
0
|
ValueChangeEvent.fire(this, outlineModel.getOutlineNodes()); |
| 222 |
|
} |
| 223 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 224 |
0
|
public List<OutlineNode<LOPicker>> getValue() {... |
| 225 |
0
|
return outlineModel.getOutlineNodes(); |
| 226 |
|
} |
| 227 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 228 |
0
|
public void setValue(List<OutlineNode<LOPicker>> value) {... |
| 229 |
0
|
outlineModel.clearNodes(); |
| 230 |
0
|
outlineModel.getOutlineNodes().addAll(value); |
| 231 |
|
|
| 232 |
0
|
if (value == null || value.isEmpty()){ |
| 233 |
0
|
initEmptyLoList(); |
| 234 |
|
} else { |
| 235 |
|
|
| 236 |
0
|
for (OutlineNode<LOPicker> node:value){ |
| 237 |
0
|
LOPicker picker = node.getUserObject(); |
| 238 |
0
|
if (!picker.hasChangeHandler()){ |
| 239 |
0
|
picker.addSelectionChangeHandler(loPickerChangeHandler); |
| 240 |
|
} |
| 241 |
|
} |
| 242 |
|
|
| 243 |
0
|
reDraw(); |
| 244 |
|
} |
| 245 |
|
} |
| 246 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 247 |
0
|
private void appendLO(String loValue) {... |
| 248 |
0
|
OutlineNode<LOPicker> aNode = new OutlineNode<LOPicker>(); |
| 249 |
0
|
LOPicker newPicker = new LOPicker(messageGroup, type, state, |
| 250 |
|
repoKey); |
| 251 |
|
|
| 252 |
0
|
newPicker.addSelectionChangeHandler(loPickerChangeHandler); |
| 253 |
0
|
newPicker.setLOText(loValue); |
| 254 |
0
|
aNode.setUserObject(newPicker); |
| 255 |
0
|
aNode.setModel(outlineModel); |
| 256 |
|
|
| 257 |
0
|
outlineModel.addOutlineNode(aNode); |
| 258 |
|
} |
| 259 |
|
|
| 260 |
|
|
| 261 |
|
|
| 262 |
|
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 263 |
0
|
public void addSelectedLOs(List<String> loDescription) {... |
| 264 |
|
|
| 265 |
0
|
List<OutlineNode<LOPicker>> existingLOs = outlineModel.getOutlineNodes(); |
| 266 |
|
|
| 267 |
0
|
int ix = existingLOs.size(); |
| 268 |
0
|
for (String strValue : loDescription) { |
| 269 |
|
|
| 270 |
0
|
boolean foundEmptyBox = false; |
| 271 |
|
|
| 272 |
0
|
for(int i=0;i<ix;i++) |
| 273 |
|
{ |
| 274 |
0
|
if (existingLOs.get(i).getUserObject().getLOText().trim() |
| 275 |
|
.length() == 0) { |
| 276 |
0
|
existingLOs.get(i).getUserObject().setLOText(strValue); |
| 277 |
0
|
foundEmptyBox = true; |
| 278 |
0
|
i=ix; |
| 279 |
|
} |
| 280 |
|
} |
| 281 |
|
|
| 282 |
|
|
| 283 |
0
|
if (foundEmptyBox == false) { |
| 284 |
0
|
appendLO(strValue); |
| 285 |
|
} |
| 286 |
|
} |
| 287 |
0
|
reDraw(); |
| 288 |
|
} |
| 289 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
| 290 |
0
|
private void reDraw() {... |
| 291 |
0
|
if (null != outlineComposite) { |
| 292 |
0
|
this.removeSection(outlineComposite); |
| 293 |
|
} |
| 294 |
0
|
this.removeWidget(addNew); |
| 295 |
0
|
outlineComposite = new OutlineManager(startOfPath, middleOfPath, endOfPath); |
| 296 |
0
|
outlineComposite.setValue(outlineModel); |
| 297 |
0
|
this.addSection(outlineComposite); |
| 298 |
0
|
this.addWidget(addNew); |
| 299 |
0
|
outlineComposite.render(); |
| 300 |
|
} |
| 301 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 302 |
0
|
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<List<OutlineNode<LOPicker>>> handler) {... |
| 303 |
0
|
return addHandler(handler, ValueChangeEvent.getType()); |
| 304 |
|
} |
| 305 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 306 |
0
|
public SelectionChangeHandler getChangeHandlerForLOPicker(){... |
| 307 |
0
|
return loPickerChangeHandler; |
| 308 |
|
} |
| 309 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 310 |
0
|
@Override... |
| 311 |
|
public void setValue(List<OutlineNode<LOPicker>> value, |
| 312 |
|
boolean fireEvents) { |
| 313 |
0
|
setValue(value); |
| 314 |
|
} |
| 315 |
|
} |
| 316 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 317 |
0
|
@Override... |
| 318 |
|
public ErrorLevel processValidationResults(FieldDescriptor fd, List<ValidationResultInfo> results) { |
| 319 |
0
|
return processValidationResults(fd, results, true); |
| 320 |
|
} |
| 321 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 322 |
0
|
@Override... |
| 323 |
|
public ErrorLevel processValidationResults(FieldDescriptor fd, List<ValidationResultInfo> results, boolean clearErrors) { |
| 324 |
|
|
| 325 |
0
|
ErrorLevel status = ErrorLevel.OK; |
| 326 |
|
|
| 327 |
0
|
for (Section section : getSections()) { |
| 328 |
0
|
ErrorLevel level = section.processValidationResults(results, clearErrors); |
| 329 |
0
|
if (level.getLevel() > status.getLevel()) { |
| 330 |
0
|
status = level; |
| 331 |
|
} |
| 332 |
|
} |
| 333 |
0
|
return status; |
| 334 |
|
} |
| 335 |
|
|
| 336 |
|
} |