1 | |
package org.kuali.student.lum.program.client.major; |
2 | |
|
3 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
4 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
5 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
6 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
7 | |
import org.kuali.student.lum.program.client.ProgramUtils; |
8 | |
import org.kuali.student.lum.program.client.events.ProgramViewEvent; |
9 | |
import org.kuali.student.lum.program.client.major.edit.MajorEditController; |
10 | |
import org.kuali.student.lum.program.client.major.view.MajorViewController; |
11 | |
import org.kuali.student.lum.program.client.variation.edit.VariationEditController; |
12 | |
import org.kuali.student.lum.program.client.variation.view.VariationViewController; |
13 | |
import org.kuali.student.lum.program.client.versions.ProgramVersionsController; |
14 | |
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
15 | |
|
16 | |
import com.google.gwt.event.shared.HandlerManager; |
17 | |
import com.google.gwt.user.client.Window; |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
public class MajorManager { |
23 | |
|
24 | |
private MajorViewController majorViewController; |
25 | |
|
26 | |
private MajorEditController majorEditController; |
27 | |
|
28 | |
private VariationViewController variationViewController; |
29 | |
|
30 | |
private VariationEditController variationEditController; |
31 | |
|
32 | |
private ProgramVersionsController programVersionsController; |
33 | |
|
34 | |
protected DataModel programModel; |
35 | |
|
36 | 0 | private ViewContext viewContext = new ViewContext(); |
37 | |
|
38 | |
private static HandlerManager eventBus; |
39 | |
|
40 | 0 | public MajorManager() { |
41 | 0 | eventBus = new HandlerManager(null); |
42 | 0 | programModel = new DataModel(); |
43 | 0 | ProgramRegistry.getSpecializationHandlers().clear(); |
44 | 0 | } |
45 | |
|
46 | |
public MajorViewController getProgramViewController() { |
47 | 0 | programModel.resetRoot(); |
48 | 0 | getMajorViewController(); |
49 | 0 | eventBus.fireEvent(new ProgramViewEvent()); |
50 | 0 | return majorViewController; |
51 | |
} |
52 | |
|
53 | |
public VariationViewController getVariationViewController() { |
54 | 0 | DataModel variationModel = new DataModel(); |
55 | |
|
56 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
57 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
58 | 0 | variationModel.setDefinition(definition); |
59 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
60 | 0 | variationViewController = new VariationViewController(variationModel, viewContext, eventBus, majorViewController); |
61 | 0 | return variationViewController; |
62 | |
} |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public VariationEditController getVariationEditController() { |
91 | 0 | DataModel variationModel = new DataModel(); |
92 | |
|
93 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
94 | |
|
95 | 0 | if(programModel==null||programModel.getDefinition()==null){ |
96 | 0 | Window.alert("Debug: null programModel or definition (MajorManager.getVariationEditController()"); |
97 | |
} |
98 | 0 | definition.setMetadata(programModel.getDefinition().getMetadata("variations/*")); |
99 | |
|
100 | |
|
101 | |
|
102 | 0 | variationModel.setDefinition(definition); |
103 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
104 | 0 | ProgramUtils.unregisterUnusedHandlers(eventBus); |
105 | 0 | variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController); |
106 | 0 | return variationEditController; |
107 | |
} |
108 | |
|
109 | |
public MajorEditController getProgramEditController() { |
110 | 0 | programModel.resetRoot(); |
111 | 0 | return getMajorEditController(); |
112 | |
} |
113 | |
|
114 | |
public MajorEditController getProgramSpecEditController() { |
115 | 0 | return getMajorEditController(); |
116 | |
} |
117 | |
|
118 | |
public ProgramVersionsController getProgramVersionsController() { |
119 | 0 | if (programVersionsController == null) { |
120 | 0 | programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus); |
121 | |
} |
122 | 0 | return programVersionsController; |
123 | |
} |
124 | |
|
125 | |
public static HandlerManager getEventBus() { |
126 | 0 | return eventBus; |
127 | |
} |
128 | |
|
129 | |
private MajorEditController getMajorEditController() { |
130 | 0 | if (majorEditController == null) { |
131 | 0 | majorEditController = new MajorEditController(programModel, viewContext, eventBus); |
132 | |
} |
133 | 0 | return majorEditController; |
134 | |
} |
135 | |
|
136 | |
private MajorViewController getMajorViewController() { |
137 | 0 | if (majorViewController == null) { |
138 | 0 | majorViewController = new MajorViewController(programModel, viewContext, eventBus); |
139 | |
} |
140 | 0 | return majorViewController; |
141 | |
} |
142 | |
|
143 | |
public DataModel getProgramModel() { |
144 | 0 | return programModel; |
145 | |
} |
146 | |
} |