1 |
|
package org.kuali.student.lum.program.client.credential.view; |
2 |
|
|
3 |
|
import com.google.gwt.core.client.GWT; |
4 |
|
import com.google.gwt.event.dom.client.ChangeEvent; |
5 |
|
import com.google.gwt.event.dom.client.ChangeHandler; |
6 |
|
import com.google.gwt.event.shared.HandlerManager; |
7 |
|
import org.kuali.student.common.ui.client.application.KSAsyncCallback; |
8 |
|
import org.kuali.student.common.ui.client.application.ViewContext; |
9 |
|
import org.kuali.student.common.ui.client.mvc.DataModel; |
10 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
11 |
|
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
12 |
|
import org.kuali.student.lum.common.client.widgets.AppLocations; |
13 |
|
import org.kuali.student.lum.common.client.widgets.DropdownList; |
14 |
|
import org.kuali.student.lum.program.client.ProgramConstants; |
15 |
|
import org.kuali.student.lum.program.client.ProgramRegistry; |
16 |
|
import org.kuali.student.lum.program.client.ProgramSections; |
17 |
|
import org.kuali.student.lum.program.client.ProgramStatus; |
18 |
|
import org.kuali.student.lum.program.client.credential.CredentialController; |
19 |
|
import org.kuali.student.lum.program.client.events.ModelLoadedEvent; |
20 |
|
import org.kuali.student.lum.program.client.events.ProgramViewEvent; |
21 |
|
import org.kuali.student.lum.program.client.major.ActionType; |
22 |
|
|
23 |
|
|
24 |
|
@author |
25 |
|
|
|
|
| 0% |
Uncovered Elements: 43 (43) |
Complexity: 11 |
Complexity Density: 0.38 |
|
26 |
|
public class CredentialViewController extends CredentialController { |
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
private final DropdownList actionBox = new DropdownList(ActionType.getValuesForCredentialProgram(false)); |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@param |
38 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
39 |
0
|
public CredentialViewController(DataModel programModel, ViewContext viewContext, HandlerManager eventBus) {... |
40 |
0
|
super(programModel, viewContext, eventBus); |
41 |
0
|
configurer = GWT.create(CredentialViewConfigurer.class); |
42 |
0
|
bind(); |
43 |
|
} |
44 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
45 |
0
|
private void bind() {... |
46 |
0
|
actionBox.addChangeHandler(new ChangeHandler() { |
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
47 |
0
|
@Override... |
48 |
|
public void onChange(ChangeEvent event) { |
49 |
0
|
ActionType actionType = ActionType.of(actionBox.getSelectedValue()); |
50 |
0
|
ViewContext viewContext = getViewContext(); |
51 |
0
|
if (actionType == ActionType.MODIFY) { |
52 |
0
|
ProgramRegistry.setSection(ProgramSections.getEditSection(getCurrentViewEnum())); |
53 |
0
|
HistoryManager.navigate(AppLocations.Locations.EDIT_BACC_PROGRAM.getLocation(), getViewContext()); |
54 |
0
|
} else if (actionType == ActionType.MODIFY_VERSION) { |
55 |
0
|
String versionIndId = getStringProperty(ProgramConstants.VERSION_IND_ID); |
56 |
0
|
viewContext.setId(versionIndId); |
57 |
0
|
viewContext.setIdType(IdType.COPY_OF_OBJECT_ID); |
58 |
0
|
HistoryManager.navigate(AppLocations.Locations.EDIT_BACC_PROGRAM.getLocation(), viewContext); |
59 |
|
} |
60 |
|
} |
61 |
|
}); |
62 |
0
|
eventBus.addHandler(ProgramViewEvent.TYPE, new ProgramViewEvent.Handler() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
63 |
0
|
@Override... |
64 |
|
public void onEvent(ProgramViewEvent event) { |
65 |
0
|
actionBox.setSelectedIndex(0); |
66 |
|
} |
67 |
|
}); |
68 |
0
|
eventBus.addHandler(ModelLoadedEvent.TYPE, new ModelLoadedEvent.Handler() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0
|
@Override... |
70 |
|
public void onEvent(ModelLoadedEvent event) { |
71 |
0
|
resetActionList(); |
72 |
|
} |
73 |
|
}); |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
76 |
0
|
@Override... |
77 |
|
protected void configureView() { |
78 |
0
|
super.configureView(); |
79 |
0
|
addContentWidget(actionBox); |
80 |
0
|
initialized = true; |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
83 |
0
|
protected void resetActionList() {... |
84 |
|
|
85 |
0
|
ProgramStatus status = ProgramStatus.of(programModel); |
86 |
0
|
String versionIndId = getStringProperty(ProgramConstants.VERSION_IND_ID); |
87 |
0
|
Long sequenceNumber = programModel.get(ProgramConstants.VERSION_SEQUENCE_NUMBER); |
88 |
|
|
89 |
0
|
actionBox.clear(); |
90 |
0
|
if (status == ProgramStatus.ACTIVE) { |
91 |
0
|
programRemoteService.isLatestVersion(versionIndId, sequenceNumber, new KSAsyncCallback<Boolean>() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0
|
public void onSuccess(Boolean isLatest) {... |
93 |
0
|
actionBox.setList(ActionType.getValuesForCredentialProgram(isLatest)); |
94 |
|
} |
95 |
|
}); |
96 |
|
} else { |
97 |
0
|
actionBox.setList(ActionType.getValuesForCredentialProgram(false)); |
98 |
|
} |
99 |
|
} |
100 |
|
} |