1 | |
package org.kuali.student.lum.lu.ui.main.client.controllers; |
2 | |
|
3 | |
import java.util.Map; |
4 | |
|
5 | |
import org.kuali.student.common.ui.client.application.Application; |
6 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
7 | |
import org.kuali.student.common.ui.client.configurable.mvc.LayoutController; |
8 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
9 | |
import org.kuali.student.common.ui.client.mvc.Controller; |
10 | |
import org.kuali.student.common.ui.client.mvc.View; |
11 | |
import org.kuali.student.common.ui.client.util.WindowTitleUtils; |
12 | |
import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel; |
13 | |
import org.kuali.student.common.ui.shared.IdAttributes.IdType; |
14 | |
import org.kuali.student.lum.common.client.configuration.LUMViews; |
15 | |
import org.kuali.student.lum.common.client.widgets.AppLocations; |
16 | |
import org.kuali.student.lum.lu.ui.browseprogram.client.controllers.BrowseProgramController; |
17 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminController; |
18 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminRetireController; |
19 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminWithoutVersionController; |
20 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController; |
21 | |
import org.kuali.student.lum.lu.ui.course.client.controllers.ViewCourseParentController; |
22 | |
import org.kuali.student.lum.lu.ui.course.client.views.CategoryManagementView; |
23 | |
import org.kuali.student.lum.lu.ui.course.client.views.CurriculumHomeView; |
24 | |
import org.kuali.student.lum.lu.ui.dependency.client.controllers.DependencyAnalysisController; |
25 | |
import org.kuali.student.lum.lu.ui.tools.client.configuration.CatalogBrowserController; |
26 | |
import org.kuali.student.lum.lu.ui.tools.client.configuration.CluSetsManagementController; |
27 | |
import org.kuali.student.lum.program.client.ProgramConstants; |
28 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
29 | |
import org.kuali.student.lum.program.client.core.CoreManager; |
30 | |
import org.kuali.student.lum.program.client.credential.CredentialManager; |
31 | |
import org.kuali.student.lum.program.client.major.MajorManager; |
32 | |
|
33 | |
import com.google.gwt.core.client.GWT; |
34 | |
import com.google.gwt.core.client.RunAsyncCallback; |
35 | |
import com.google.gwt.user.client.Window; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public class CurriculumHomeController extends LayoutController { |
64 | |
|
65 | |
private CurriculumHomeView home; |
66 | 0 | private final SpanPanel panel = new SpanPanel(); |
67 | |
|
68 | |
private CourseProposalController courseProposalController; |
69 | |
private CourseAdminController courseAdminController; |
70 | |
private CourseAdminWithoutVersionController courseAdminWithoutVersionController; |
71 | |
private CourseAdminRetireController courseAdminRetireController; |
72 | |
private LayoutController viewCourseController; |
73 | |
private LayoutController manageCluSetsController; |
74 | |
private LayoutController browseCatalogController; |
75 | |
private LayoutController dependencyAnalysisController; |
76 | |
private LayoutController browseProgramController; |
77 | 0 | private MajorManager majorManager = new MajorManager(); |
78 | 0 | private CredentialManager credentialManager = new CredentialManager(); |
79 | 0 | private CoreManager coreManager = new CoreManager(); |
80 | |
|
81 | 0 | private abstract class RunAsyncGetView implements RunAsyncCallback { |
82 | |
public void onFailure(Throwable reason) { |
83 | 0 | Window.alert("Download failed. Please try again."); |
84 | 0 | } |
85 | |
} |
86 | |
|
87 | |
public CurriculumHomeController() { |
88 | 0 | super(); |
89 | 0 | this.setDefaultView(LUMViews.DEFAULT); |
90 | 0 | this.initWidget(panel); |
91 | 0 | setupDefaultView(); |
92 | 0 | } |
93 | |
|
94 | |
public CurriculumHomeController(Controller controller, String name, Enum<?> viewType) { |
95 | 0 | super(); |
96 | 0 | super.setController(controller); |
97 | 0 | super.setName(name); |
98 | 0 | super.setViewEnum(viewType); |
99 | 0 | this.setDefaultView(LUMViews.DEFAULT); |
100 | 0 | this.initWidget(panel); |
101 | 0 | setupDefaultView(); |
102 | 0 | } |
103 | |
|
104 | |
private void setupDefaultView() { |
105 | 0 | home = new CurriculumHomeView(this, LUMViews.DEFAULT); |
106 | 0 | } |
107 | |
|
108 | |
@Override |
109 | |
public <V extends Enum<?>> void getView(V viewType, final Callback<View> callback, Map<String, String> tokenMap) { |
110 | |
|
111 | |
|
112 | 0 | switch ((LUMViews) viewType) { |
113 | |
case DEFAULT: |
114 | 0 | callback.exec(home); |
115 | 0 | break; |
116 | |
case COURSE_PROPOSAL: |
117 | |
|
118 | |
|
119 | |
|
120 | 0 | callback.exec(getCourseProposalController()); |
121 | |
|
122 | |
|
123 | 0 | break; |
124 | |
case COURSE_ADMIN: |
125 | |
|
126 | |
|
127 | |
|
128 | 0 | callback.exec(getCourseAdminController()); |
129 | |
|
130 | |
|
131 | 0 | break; |
132 | |
case COURSE_ADMIN_NO_VERSION: |
133 | |
|
134 | |
|
135 | |
|
136 | 0 | callback.exec(getCourseAdminWithoutVersionController()); |
137 | |
|
138 | |
|
139 | 0 | break; |
140 | |
case COURSE_ADMIN_RETIRE: |
141 | |
|
142 | |
|
143 | |
|
144 | 0 | callback.exec(getCourseAdminRetireController()); |
145 | |
|
146 | |
|
147 | 0 | break; |
148 | |
|
149 | |
case VIEW_COURSE: |
150 | |
|
151 | |
|
152 | |
|
153 | 0 | callback.exec(getViewCourseController()); |
154 | |
|
155 | |
|
156 | 0 | break; |
157 | |
case PROGRAM_PROPOSAL: |
158 | |
|
159 | |
|
160 | |
|
161 | 0 | if (ProgramRegistry.isCreateNew()) { |
162 | 0 | ProgramRegistry.setCreateNew(false); |
163 | 0 | majorManager = new MajorManager(); |
164 | |
} |
165 | 0 | callback.exec(majorManager.getMajorProposalController()); |
166 | |
|
167 | |
|
168 | 0 | break; |
169 | |
case PROGRAM_VIEW: |
170 | |
|
171 | |
|
172 | |
|
173 | 0 | if (ProgramRegistry.isCreateNew()) { |
174 | 0 | ProgramRegistry.setCreateNew(false); |
175 | 0 | majorManager = new MajorManager(); |
176 | |
} |
177 | 0 | callback.exec(majorManager.getProgramViewController()); |
178 | |
|
179 | |
|
180 | 0 | break; |
181 | |
case PROGRAM_EDIT: |
182 | |
|
183 | |
|
184 | |
|
185 | 0 | Application.getApplicationContext().setParentPath(""); |
186 | 0 | if (ProgramRegistry.isCreateNew()) { |
187 | 0 | ProgramRegistry.setCreateNew(false); |
188 | 0 | majorManager = new MajorManager(); |
189 | |
} |
190 | 0 | callback.exec(majorManager.getProgramEditController()); |
191 | |
|
192 | |
|
193 | 0 | break; |
194 | |
case PROGRAM_SPEC_EDIT: |
195 | |
|
196 | |
|
197 | |
|
198 | 0 | if (ProgramRegistry.isCreateNew()) { |
199 | 0 | ProgramRegistry.setCreateNew(false); |
200 | 0 | majorManager = new MajorManager(); |
201 | |
} |
202 | 0 | callback.exec(majorManager.getProgramSpecEditController()); |
203 | |
|
204 | |
|
205 | 0 | break; |
206 | |
case PROGRAM_CREATE: |
207 | |
|
208 | |
|
209 | |
|
210 | 0 | majorManager = new MajorManager(); |
211 | 0 | callback.exec(majorManager.getProgramEditController()); |
212 | |
|
213 | |
|
214 | 0 | break; |
215 | |
case PROGRAM_VERSIONS: |
216 | |
|
217 | |
|
218 | |
|
219 | 0 | callback.exec(majorManager.getProgramVersionsController()); |
220 | |
|
221 | |
|
222 | 0 | break; |
223 | |
case CLU_SETS: |
224 | |
|
225 | |
|
226 | |
|
227 | 0 | callback.exec(getCluSetsController()); |
228 | |
|
229 | |
|
230 | 0 | break; |
231 | |
case COURSE_CATALOG: |
232 | |
|
233 | |
|
234 | |
|
235 | 0 | callback.exec(getBrowseCatalogController()); |
236 | |
|
237 | |
|
238 | 0 | break; |
239 | |
case VARIATION_VIEW: |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | 0 | if(majorManager.getProgramModel()!=null && majorManager.getProgramModel().getDefinition()!=null){ |
245 | 0 | callback.exec(majorManager.getVariationViewController()); |
246 | |
}else{ |
247 | |
|
248 | |
|
249 | |
|
250 | 0 | ViewContext viewContext = new ViewContext(); |
251 | 0 | viewContext.setId(tokenMap.get("docId")); |
252 | 0 | viewContext.setAttribute(ProgramConstants.VARIATION_ID, tokenMap.get(ProgramConstants.VARIATION_ID)); |
253 | 0 | viewContext.setAttribute(ProgramConstants.TYPE, ProgramConstants.VARIATION_TYPE_KEY); |
254 | 0 | viewContext.setIdType(IdType.OBJECT_ID); |
255 | 0 | ProgramRegistry.setCreateNew(true); |
256 | 0 | Application.navigate(AppLocations.Locations.VIEW_PROGRAM.getLocation(), viewContext); |
257 | |
} |
258 | |
|
259 | |
|
260 | 0 | break; |
261 | |
case VARIATION_EDIT: |
262 | |
|
263 | |
|
264 | |
|
265 | 0 | if(majorManager.getProgramModel()!=null && majorManager.getProgramModel().getDefinition()!=null){ |
266 | 0 | callback.exec(majorManager.getVariationEditController()); |
267 | |
}else{ |
268 | |
|
269 | 0 | Application.getApplicationContext().setParentPath(""); |
270 | 0 | if (ProgramRegistry.isCreateNew()) { |
271 | 0 | ProgramRegistry.setCreateNew(false); |
272 | 0 | majorManager = new MajorManager(); |
273 | |
} |
274 | 0 | callback.exec(majorManager.getProgramEditController()); |
275 | |
} |
276 | |
|
277 | |
|
278 | 0 | break; |
279 | |
case CORE_PROGRAM_VIEW: |
280 | |
|
281 | |
|
282 | |
|
283 | 0 | if (ProgramRegistry.isCreateNew()) { |
284 | 0 | ProgramRegistry.setCreateNew(false); |
285 | 0 | coreManager = new CoreManager(); |
286 | |
} |
287 | 0 | callback.exec(coreManager.getViewController()); |
288 | |
|
289 | |
|
290 | 0 | break; |
291 | |
case CORE_PROGRAM_EDIT: |
292 | |
|
293 | |
|
294 | |
|
295 | 0 | callback.exec(coreManager.getEditController()); |
296 | |
|
297 | |
|
298 | 0 | break; |
299 | |
case CORE_PROGRAM_VERSIONS: |
300 | |
|
301 | |
|
302 | |
|
303 | 0 | callback.exec(coreManager.getProgramVersionsController()); |
304 | |
|
305 | |
|
306 | 0 | break; |
307 | |
case BACC_PROGRAM_VIEW: |
308 | |
|
309 | |
|
310 | |
|
311 | 0 | if (ProgramRegistry.isCreateNew()) { |
312 | 0 | ProgramRegistry.setCreateNew(false); |
313 | 0 | credentialManager = new CredentialManager(); |
314 | |
} |
315 | 0 | callback.exec(credentialManager.getBaccViewController()); |
316 | |
|
317 | |
|
318 | 0 | break; |
319 | |
case BACC_PROGRAM_EDIT: |
320 | |
|
321 | |
|
322 | |
|
323 | 0 | callback.exec(credentialManager.getBaccEditController()); |
324 | |
|
325 | |
|
326 | 0 | break; |
327 | |
case BACC_PROGRAM_VERSIONS: |
328 | |
|
329 | |
|
330 | |
|
331 | 0 | callback.exec(credentialManager.getProgramVersionsController()); |
332 | |
|
333 | |
|
334 | 0 | break; |
335 | |
case LO_CATEGORIES: |
336 | |
|
337 | |
|
338 | |
|
339 | 0 | callback.exec(getCategoryManagementController()); |
340 | |
|
341 | |
|
342 | 0 | break; |
343 | |
case DEPENDENCY_ANALYSIS: |
344 | |
|
345 | |
|
346 | |
|
347 | 0 | callback.exec(getDependencyAnalysisController()); |
348 | |
|
349 | |
|
350 | 0 | break; |
351 | |
case BROWSE_PROGRAM: |
352 | |
|
353 | |
|
354 | |
|
355 | 0 | callback.exec(getBrowseProgramController()); |
356 | |
|
357 | |
|
358 | 0 | break; |
359 | |
default: |
360 | 0 | callback.exec(home); |
361 | |
} |
362 | 0 | } |
363 | |
|
364 | |
|
365 | |
protected View getCategoryManagementController() { |
366 | 0 | return new CategoryManagementView(this, "Learning Objective Categories", LUMViews.LO_CATEGORIES); |
367 | |
} |
368 | |
|
369 | |
private CourseProposalController getCourseProposalController() { |
370 | 0 | courseProposalController = GWT.create(CourseProposalController.class); |
371 | 0 | return courseProposalController; |
372 | |
} |
373 | |
|
374 | |
private CourseAdminController getCourseAdminController() { |
375 | 0 | courseAdminController = GWT.create(CourseAdminController.class); |
376 | 0 | return courseAdminController; |
377 | |
} |
378 | |
|
379 | |
private CourseAdminWithoutVersionController getCourseAdminRetireController(){ |
380 | 0 | courseAdminRetireController = GWT.create(CourseAdminRetireController.class); |
381 | 0 | return courseAdminRetireController; |
382 | |
} |
383 | |
|
384 | |
private CourseAdminWithoutVersionController getCourseAdminWithoutVersionController(){ |
385 | 0 | courseAdminWithoutVersionController = GWT.create(CourseAdminWithoutVersionController.class); |
386 | 0 | return courseAdminWithoutVersionController; |
387 | |
} |
388 | |
|
389 | |
private LayoutController getViewCourseController() { |
390 | 0 | if (viewCourseController == null) { |
391 | 0 | viewCourseController = GWT.create(ViewCourseParentController.class); |
392 | |
} |
393 | 0 | return this.viewCourseController; |
394 | |
} |
395 | |
|
396 | |
private LayoutController getCluSetsController() { |
397 | 0 | manageCluSetsController = GWT.create(CluSetsManagementController.class); |
398 | 0 | return manageCluSetsController; |
399 | |
} |
400 | |
|
401 | |
private LayoutController getBrowseCatalogController() { |
402 | 0 | browseCatalogController = new CatalogBrowserController(this); |
403 | 0 | return browseCatalogController; |
404 | |
} |
405 | |
|
406 | |
private LayoutController getDependencyAnalysisController() { |
407 | 0 | dependencyAnalysisController = new DependencyAnalysisController("DependencyAnalaysis"); |
408 | 0 | return dependencyAnalysisController; |
409 | |
} |
410 | |
|
411 | |
private LayoutController getBrowseProgramController() { |
412 | 0 | browseProgramController = new BrowseProgramController("BrowseProgram"); |
413 | 0 | return browseProgramController; |
414 | |
} |
415 | |
|
416 | |
@Override |
417 | |
protected void hideView(View view) { |
418 | 0 | ApplicationController.getApplicationViewContainer().clear(); |
419 | 0 | } |
420 | |
|
421 | |
@Override |
422 | |
protected void renderView(View view) { |
423 | 0 | ApplicationController.getApplicationViewContainer().add(view.asWidget()); |
424 | 0 | } |
425 | |
|
426 | |
@Override |
427 | |
public Enum<?> getViewEnumValue(String enumValue) { |
428 | 0 | return LUMViews.valueOf(enumValue); |
429 | |
} |
430 | |
|
431 | |
@Override |
432 | |
public void updateModel() { |
433 | |
|
434 | 0 | } |
435 | |
|
436 | |
public <V extends Enum<?>> void showView(V viewType, Callback<Boolean> onReadyCallback) { |
437 | 0 | if (viewType == LUMViews.DEFAULT) { |
438 | 0 | WindowTitleUtils.setContextTitle(name); |
439 | |
} |
440 | 0 | super.showView(viewType, onReadyCallback); |
441 | 0 | } |
442 | |
} |