1 | |
package org.kuali.student.lum.lu.ui.course.client.controllers; |
2 | |
|
3 | |
import com.google.gwt.core.client.GWT; |
4 | |
import com.google.gwt.core.client.RunAsyncCallback; |
5 | |
import com.google.gwt.user.client.Window; |
6 | |
import org.kuali.student.common.ui.client.configurable.mvc.LayoutController; |
7 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
8 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
9 | |
import org.kuali.student.common.ui.client.mvc.View; |
10 | |
import org.kuali.student.common.ui.client.util.WindowTitleUtils; |
11 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
12 | |
import org.kuali.student.lum.lu.ui.course.client.views.CategoryManagementView; |
13 | |
import org.kuali.student.lum.lu.ui.course.client.views.CurriculumHomeView; |
14 | |
import org.kuali.student.lum.lu.ui.main.client.controllers.ApplicationController; |
15 | |
import org.kuali.student.lum.lu.ui.tools.client.configuration.CatalogBrowserController; |
16 | |
import org.kuali.student.lum.lu.ui.tools.client.configuration.CluSetsManagementController; |
17 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
18 | |
import org.kuali.student.lum.program.client.core.CoreManager; |
19 | |
import org.kuali.student.lum.program.client.credential.CredentialManager; |
20 | |
import org.kuali.student.lum.program.client.major.MajorManager; |
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | 0 | public class CurriculumHomeController extends LayoutController { |
49 | |
|
50 | |
private CurriculumHomeView home; |
51 | 0 | private final SpanPanel panel = new SpanPanel(); |
52 | |
|
53 | |
private CourseProposalController courseProposalController; |
54 | |
private LayoutController viewCourseController; |
55 | |
private LayoutController manageCluSetsController; |
56 | |
private LayoutController browseCatalogController; |
57 | 0 | private MajorManager majorManager = new MajorManager(); |
58 | 0 | private CredentialManager credentialManager = new CredentialManager(); |
59 | 0 | private CoreManager coreManager = new CoreManager(); |
60 | |
|
61 | 0 | private abstract class RunAsyncGetView implements RunAsyncCallback { |
62 | |
public void onFailure(Throwable reason) { |
63 | 0 | Window.alert("Download failed. Please try again."); |
64 | 0 | } |
65 | |
} |
66 | |
|
67 | 0 | public enum LUMViews { |
68 | 0 | DEFAULT, |
69 | 0 | COURSE_PROPOSAL, |
70 | 0 | VIEW_COURSE, |
71 | 0 | PROGRAM_VIEW, |
72 | 0 | PROGRAM_EDIT, |
73 | 0 | PROGRAM_SPEC_EDIT, |
74 | 0 | PROGRAM_CREATE, |
75 | 0 | PROGRAM_VERSIONS, |
76 | 0 | CLU_SETS, |
77 | 0 | VARIATION_VIEW, |
78 | 0 | VARIATION_EDIT, |
79 | 0 | COURSE_CATALOG, |
80 | 0 | LO_CATEGORIES, |
81 | 0 | BACC_PROGRAM_VIEW, |
82 | 0 | BACC_PROGRAM_EDIT, |
83 | 0 | BACC_PROGRAM_VERSIONS, |
84 | 0 | CORE_PROGRAM_VIEW, |
85 | 0 | CORE_PROGRAM_EDIT, |
86 | 0 | CORE_PROGRAM_VERSIONS |
87 | |
} |
88 | |
|
89 | |
public CurriculumHomeController(Controller controller, String name, Enum<?> viewType) { |
90 | 0 | super(CurriculumHomeController.class.getName()); |
91 | 0 | super.setController(controller); |
92 | 0 | super.setName(name); |
93 | 0 | super.setViewEnum(viewType); |
94 | 0 | this.setDefaultView(LUMViews.DEFAULT); |
95 | 0 | this.initWidget(panel); |
96 | 0 | setupDefaultView(); |
97 | 0 | } |
98 | |
|
99 | |
private void setupDefaultView() { |
100 | 0 | home = new CurriculumHomeView(this, LUMViews.DEFAULT); |
101 | 0 | } |
102 | |
|
103 | |
@Override |
104 | |
public <V extends Enum<?>> void getView(V viewType, final Callback<View> callback) { |
105 | |
|
106 | |
|
107 | 0 | switch ((LUMViews) viewType) { |
108 | |
case DEFAULT: |
109 | 0 | callback.exec(home); |
110 | 0 | break; |
111 | |
case COURSE_PROPOSAL: |
112 | 0 | GWT.runAsync(new RunAsyncGetView() { |
113 | |
@Override |
114 | |
public void onSuccess() { |
115 | 0 | callback.exec(getCourseProposalController()); |
116 | 0 | } |
117 | |
}); |
118 | 0 | break; |
119 | |
case VIEW_COURSE: |
120 | 0 | GWT.runAsync(new RunAsyncGetView() { |
121 | |
@Override |
122 | |
public void onSuccess() { |
123 | 0 | callback.exec(getViewCourseController()); |
124 | 0 | } |
125 | |
}); |
126 | 0 | break; |
127 | |
case PROGRAM_VIEW: |
128 | 0 | GWT.runAsync(new RunAsyncGetView() { |
129 | |
@Override |
130 | |
public void onSuccess() { |
131 | 0 | if (ProgramRegistry.isCreateNew()) { |
132 | 0 | ProgramRegistry.setCreateNew(false); |
133 | 0 | majorManager = new MajorManager(); |
134 | |
} |
135 | 0 | callback.exec(majorManager.getProgramViewController()); |
136 | 0 | } |
137 | |
}); |
138 | 0 | break; |
139 | |
case PROGRAM_EDIT: |
140 | 0 | GWT.runAsync(new RunAsyncGetView() { |
141 | |
@Override |
142 | |
public void onSuccess() { |
143 | 0 | if (ProgramRegistry.isCreateNew()) { |
144 | 0 | ProgramRegistry.setCreateNew(false); |
145 | 0 | majorManager = new MajorManager(); |
146 | |
} |
147 | 0 | callback.exec(majorManager.getProgramEditController()); |
148 | 0 | } |
149 | |
}); |
150 | 0 | break; |
151 | |
case PROGRAM_SPEC_EDIT: |
152 | 0 | GWT.runAsync(new RunAsyncGetView() { |
153 | |
@Override |
154 | |
public void onSuccess() { |
155 | 0 | if (ProgramRegistry.isCreateNew()) { |
156 | 0 | ProgramRegistry.setCreateNew(false); |
157 | 0 | majorManager = new MajorManager(); |
158 | |
} |
159 | 0 | callback.exec(majorManager.getProgramSpecEditController()); |
160 | 0 | } |
161 | |
}); |
162 | 0 | break; |
163 | |
case PROGRAM_CREATE: |
164 | 0 | GWT.runAsync(new RunAsyncGetView() { |
165 | |
@Override |
166 | |
public void onSuccess() { |
167 | 0 | majorManager = new MajorManager(); |
168 | 0 | callback.exec(majorManager.getProgramEditController()); |
169 | 0 | } |
170 | |
}); |
171 | 0 | break; |
172 | |
case PROGRAM_VERSIONS: |
173 | 0 | GWT.runAsync(new RunAsyncGetView() { |
174 | |
@Override |
175 | |
public void onSuccess() { |
176 | 0 | callback.exec(majorManager.getProgramVersionsController()); |
177 | 0 | } |
178 | |
}); |
179 | 0 | break; |
180 | |
case CLU_SETS: |
181 | 0 | GWT.runAsync(new RunAsyncGetView() { |
182 | |
@Override |
183 | |
public void onSuccess() { |
184 | 0 | callback.exec(getCluSetsController()); |
185 | 0 | } |
186 | |
}); |
187 | 0 | break; |
188 | |
case COURSE_CATALOG: |
189 | 0 | GWT.runAsync(new RunAsyncGetView() { |
190 | |
@Override |
191 | |
public void onSuccess() { |
192 | 0 | callback.exec(getBrowseCatalogController()); |
193 | 0 | } |
194 | |
}); |
195 | 0 | break; |
196 | |
case VARIATION_VIEW: |
197 | 0 | GWT.runAsync(new RunAsyncGetView() { |
198 | |
@Override |
199 | |
public void onSuccess() { |
200 | 0 | callback.exec(majorManager.getVariationViewController()); |
201 | 0 | } |
202 | |
}); |
203 | 0 | break; |
204 | |
case VARIATION_EDIT: |
205 | 0 | GWT.runAsync(new RunAsyncGetView() { |
206 | |
@Override |
207 | |
public void onSuccess() { |
208 | 0 | callback.exec(majorManager.getVariationEditController()); |
209 | 0 | } |
210 | |
}); |
211 | 0 | break; |
212 | |
case CORE_PROGRAM_VIEW: |
213 | 0 | GWT.runAsync(new RunAsyncGetView() { |
214 | |
@Override |
215 | |
public void onSuccess() { |
216 | 0 | if (ProgramRegistry.isCreateNew()) { |
217 | 0 | ProgramRegistry.setCreateNew(false); |
218 | 0 | coreManager = new CoreManager(); |
219 | |
} |
220 | 0 | callback.exec(coreManager.getViewController()); |
221 | 0 | } |
222 | |
}); |
223 | 0 | break; |
224 | |
case CORE_PROGRAM_EDIT: |
225 | 0 | GWT.runAsync(new RunAsyncGetView() { |
226 | |
@Override |
227 | |
public void onSuccess() { |
228 | 0 | callback.exec(coreManager.getEditController()); |
229 | 0 | } |
230 | |
}); |
231 | 0 | break; |
232 | |
case CORE_PROGRAM_VERSIONS: |
233 | 0 | GWT.runAsync(new RunAsyncGetView() { |
234 | |
@Override |
235 | |
public void onSuccess() { |
236 | 0 | callback.exec(coreManager.getProgramVersionsController()); |
237 | 0 | } |
238 | |
}); |
239 | 0 | break; |
240 | |
case BACC_PROGRAM_VIEW: |
241 | 0 | GWT.runAsync(new RunAsyncGetView() { |
242 | |
@Override |
243 | |
public void onSuccess() { |
244 | 0 | if (ProgramRegistry.isCreateNew()) { |
245 | 0 | ProgramRegistry.setCreateNew(false); |
246 | 0 | credentialManager = new CredentialManager(); |
247 | |
} |
248 | 0 | callback.exec(credentialManager.getBaccViewController()); |
249 | 0 | } |
250 | |
}); |
251 | 0 | break; |
252 | |
case BACC_PROGRAM_EDIT: |
253 | 0 | GWT.runAsync(new RunAsyncGetView() { |
254 | |
@Override |
255 | |
public void onSuccess() { |
256 | 0 | callback.exec(credentialManager.getBaccEditController()); |
257 | 0 | } |
258 | |
}); |
259 | 0 | break; |
260 | |
case BACC_PROGRAM_VERSIONS: |
261 | 0 | GWT.runAsync(new RunAsyncGetView() { |
262 | |
@Override |
263 | |
public void onSuccess() { |
264 | 0 | callback.exec(credentialManager.getProgramVersionsController()); |
265 | 0 | } |
266 | |
}); |
267 | 0 | break; |
268 | |
case LO_CATEGORIES: |
269 | 0 | GWT.runAsync(new RunAsyncGetView() { |
270 | |
@Override |
271 | |
public void onSuccess() { |
272 | 0 | callback.exec(getCategoryManagementController()); |
273 | 0 | } |
274 | |
}); |
275 | 0 | break; |
276 | |
default: |
277 | 0 | callback.exec(home); |
278 | |
} |
279 | 0 | } |
280 | |
|
281 | |
|
282 | |
private View getCategoryManagementController() { |
283 | 0 | return new CategoryManagementView(this, "Learning Objective Categories", LUMViews.LO_CATEGORIES); |
284 | |
} |
285 | |
|
286 | |
private CourseProposalController getCourseProposalController() { |
287 | 0 | courseProposalController = new CourseProposalController(); |
288 | 0 | return courseProposalController; |
289 | |
} |
290 | |
|
291 | |
private LayoutController getViewCourseController() { |
292 | 0 | if (viewCourseController == null) { |
293 | 0 | viewCourseController = new ViewCourseParentController(); |
294 | |
} |
295 | 0 | return this.viewCourseController; |
296 | |
} |
297 | |
|
298 | |
private LayoutController getCluSetsController() { |
299 | 0 | manageCluSetsController = new CluSetsManagementController(); |
300 | 0 | return manageCluSetsController; |
301 | |
} |
302 | |
|
303 | |
private LayoutController getBrowseCatalogController() { |
304 | 0 | browseCatalogController = new CatalogBrowserController(this); |
305 | 0 | return browseCatalogController; |
306 | |
} |
307 | |
|
308 | |
@Override |
309 | |
protected void hideView(View view) { |
310 | 0 | ApplicationController.getApplicationViewContainer().clear(); |
311 | 0 | } |
312 | |
|
313 | |
@Override |
314 | |
protected void renderView(View view) { |
315 | 0 | ApplicationController.getApplicationViewContainer().add(view.asWidget()); |
316 | 0 | } |
317 | |
|
318 | |
@Override |
319 | |
public Enum<?> getViewEnumValue(String enumValue) { |
320 | 0 | return LUMViews.valueOf(enumValue); |
321 | |
} |
322 | |
|
323 | |
@Override |
324 | |
public void updateModel() { |
325 | |
|
326 | 0 | } |
327 | |
|
328 | |
public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) { |
329 | 0 | if (viewType == LUMViews.DEFAULT) { |
330 | 0 | WindowTitleUtils.setContextTitle(name); |
331 | |
} |
332 | 0 | super.showView(viewType, onReadyCallback); |
333 | 0 | } |
334 | |
} |