1 | |
package org.kuali.student.lum.lu.ui.course.client.controllers; |
2 | |
|
3 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
4 | |
import org.kuali.student.common.ui.client.configurable.mvc.layouts.BasicLayout; |
5 | |
import org.kuali.student.common.ui.client.mvc.Callback; |
6 | |
import org.kuali.student.common.ui.client.mvc.breadcrumb.BreadcrumbManager; |
7 | |
import org.kuali.student.common.ui.client.mvc.history.HistoryManager; |
8 | |
|
9 | |
import com.google.gwt.core.client.GWT; |
10 | |
|
11 | |
public class ViewCourseParentController extends BasicLayout{ |
12 | |
|
13 | 0 | public static enum Views{VIEW, VERSIONS} |
14 | |
|
15 | |
private ViewCourseController view; |
16 | |
private VersionsController versions; |
17 | |
|
18 | |
public ViewCourseParentController() { |
19 | 0 | super(ViewCourseParentController.class.toString()); |
20 | 0 | this.setDefaultView(Views.VIEW); |
21 | 0 | setupDefaultView(); |
22 | 0 | } |
23 | |
|
24 | |
|
25 | |
private void setupDefaultView() { |
26 | 0 | view = GWT.create(ViewCourseController.class); |
27 | 0 | view.initialize(Views.VIEW); |
28 | 0 | view.setParentController(this); |
29 | 0 | versions = new VersionsController(Views.VERSIONS); |
30 | 0 | view.setParentController(this); |
31 | 0 | this.addView(view); |
32 | 0 | this.addView(versions); |
33 | 0 | } |
34 | |
|
35 | |
@Override |
36 | |
public void setViewContext(ViewContext viewContext) { |
37 | |
|
38 | 0 | view.setViewContext(viewContext); |
39 | 0 | } |
40 | |
|
41 | |
@Override |
42 | |
public <V extends Enum<?>> void showView(final V viewType, final Callback<Boolean> onReadyCallback) { |
43 | 0 | if(viewType == Views.VERSIONS){ |
44 | 0 | view.setName(""); |
45 | 0 | this.setName(view.getCourseTitle()); |
46 | 0 | versions.setVersionIndId(view.getVersionIndId()); |
47 | 0 | versions.setCurrentVersionId(view.getCurrentId()); |
48 | 0 | versions.setCurrentTitle(view.getCourseTitle()); |
49 | |
} |
50 | 0 | else if(viewType == Views.VIEW){ |
51 | 0 | view.setName(view.getCourseTitle()); |
52 | 0 | this.setName(""); |
53 | |
} |
54 | 0 | super.showView(viewType, onReadyCallback); |
55 | 0 | } |
56 | |
|
57 | |
@Override |
58 | |
public Enum<?> getViewEnumValue(String enumValue) { |
59 | 0 | return Views.valueOf(enumValue); |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
public void beforeShow(Callback<Boolean> onReadyCallback) { |
64 | 0 | if(this.getName() != null && !this.getName().equals("")){ |
65 | 0 | this.setName(""); |
66 | |
} |
67 | 0 | super.beforeShow(onReadyCallback); |
68 | 0 | } |
69 | |
|
70 | |
} |