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