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