1 |
|
package org.kuali.student.lum.program.client.variation; |
2 |
|
|
3 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
4 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
5 |
|
import com.google.gwt.event.shared.HandlerManager; |
6 |
|
import com.google.gwt.user.client.ui.Anchor; |
7 |
|
import com.google.gwt.user.client.ui.HorizontalPanel; |
8 |
|
import com.google.gwt.user.client.ui.Label; |
9 |
|
import com.google.gwt.user.client.ui.Widget; |
10 |
|
|
11 |
|
import org.kuali.student.common.assembly.data.Data; |
12 |
|
import org.kuali.student.common.ui.client.application.ViewContext; |
13 |
|
import org.kuali.student.common.ui.client.mvc.DataModel; |
14 |
|
import org.kuali.student.common.ui.client.mvc.ModelRequestCallback; |
15 |
|
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
16 |
|
import org.kuali.student.lum.common.client.widgets.AppLocations; |
17 |
|
import org.kuali.student.lum.program.client.ProgramConstants; |
18 |
|
import org.kuali.student.lum.program.client.ProgramController; |
19 |
|
import org.kuali.student.lum.program.client.events.ModelLoadedEvent; |
20 |
|
import org.kuali.student.lum.program.client.major.MajorController; |
21 |
|
import org.kuali.student.lum.program.client.properties.ProgramProperties; |
22 |
|
import org.kuali.student.lum.program.client.rpc.AbstractCallback; |
23 |
|
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
24 |
|
|
25 |
|
import java.util.List; |
26 |
|
|
27 |
|
|
28 |
|
@author |
29 |
|
|
|
|
| 0% |
Uncovered Elements: 44 (44) |
Complexity: 10 |
Complexity Density: 0.3 |
|
30 |
|
public abstract class VariationController extends ProgramController { |
31 |
|
|
32 |
|
private String parentName; |
33 |
|
|
34 |
|
protected MajorController majorController; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@param |
40 |
|
@param |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
42 |
0
|
public VariationController(DataModel programModel, ViewContext viewContext, HandlerManager eventBus, MajorController majorController) {... |
43 |
0
|
super("", programModel, viewContext, eventBus); |
44 |
0
|
this.parentName = majorController.getName(); |
45 |
0
|
this.majorController = majorController; |
46 |
0
|
setName(getProgramName()); |
47 |
0
|
sideBar = new ProgramSideBar(eventBus, ProgramSideBar.Type.MAJOR); |
48 |
0
|
sideBar.initialize(majorController); |
49 |
|
} |
50 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
51 |
0
|
@Override... |
52 |
|
protected void configureView() { |
53 |
0
|
setStatus(); |
54 |
0
|
super.configureView(); |
55 |
0
|
setContentTitle(getProgramName()); |
56 |
0
|
addContentWidget(createParentAnchor()); |
57 |
0
|
addContentWidget(createCommentPanel()); |
58 |
|
} |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
60 |
0
|
private Widget createParentAnchor() {... |
61 |
0
|
HorizontalPanel anchorPanel = new HorizontalPanel(); |
62 |
0
|
Anchor anchor = new Anchor(parentName); |
63 |
0
|
anchor.addClickHandler(new ClickHandler() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0
|
@Override... |
65 |
|
public void onClick(ClickEvent event) { |
66 |
0
|
navigateToParent(); |
67 |
|
} |
68 |
|
}); |
69 |
0
|
Label parentProgram = new Label(ProgramProperties.get().variation_parentProgram()); |
70 |
0
|
parentProgram.addStyleName("parentProgram"); |
71 |
0
|
anchorPanel.add(parentProgram); |
72 |
0
|
anchorPanel.add(anchor); |
73 |
0
|
return anchorPanel; |
74 |
|
} |
75 |
|
|
76 |
|
protected abstract void navigateToParent(); |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
78 |
0
|
@Override... |
79 |
|
public String getProgramName() { |
80 |
0
|
String name = getStringProperty(ProgramConstants.LONG_TITLE); |
81 |
0
|
if (name == null) { |
82 |
0
|
return ProgramProperties.get().variation_new(); |
83 |
|
} |
84 |
0
|
return ProgramProperties.get().variation_title(name); |
85 |
|
} |
86 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
87 |
0
|
@Override... |
88 |
|
public void collectBreadcrumbNames(List<String> names) { |
89 |
0
|
names.add(parentName + "@" + HistoryManager.appendContext(AppLocations.Locations.VIEW_PROGRAM.getLocation(), getViewContext())); |
90 |
0
|
super.collectBreadcrumbNames(names); |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
@param |
97 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
98 |
0
|
@Override... |
99 |
|
protected void loadModel(final ModelRequestCallback<DataModel> callback) { |
100 |
0
|
programRemoteService.getData(getViewContext().getId(), new AbstractCallback<Data>(ProgramProperties.get().common_retrievingData()) { |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
102 |
0
|
@Override... |
103 |
|
public void onFailure(Throwable caught) { |
104 |
0
|
super.onFailure(caught); |
105 |
0
|
callback.onRequestFail(caught); |
106 |
|
} |
107 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
108 |
0
|
@Override... |
109 |
|
public void onSuccess(Data result) { |
110 |
0
|
super.onSuccess(result); |
111 |
0
|
programModel.setRoot(result); |
112 |
0
|
callback.onModelReady(programModel); |
113 |
0
|
eventBus.fireEvent(new ModelLoadedEvent(programModel)); |
114 |
|
} |
115 |
|
}); |
116 |
|
} |
117 |
|
} |