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