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 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
public class MajorManager { |
22 | |
|
23 | |
private MajorViewController majorViewController; |
24 | |
|
25 | |
private MajorEditController majorEditController; |
26 | |
|
27 | |
private VariationViewController variationViewController; |
28 | |
|
29 | |
private VariationEditController variationEditController; |
30 | |
|
31 | |
private ProgramVersionsController programVersionsController; |
32 | |
|
33 | |
protected DataModel programModel; |
34 | |
|
35 | 0 | private ViewContext viewContext = new ViewContext(); |
36 | |
|
37 | |
private static HandlerManager eventBus; |
38 | |
|
39 | 0 | public MajorManager() { |
40 | 0 | eventBus = new HandlerManager(null); |
41 | 0 | programModel = new DataModel(); |
42 | 0 | ProgramRegistry.getSpecializationHandlers().clear(); |
43 | 0 | } |
44 | |
|
45 | |
public MajorViewController getProgramViewController() { |
46 | 0 | programModel.resetRoot(); |
47 | 0 | getMajorViewController(); |
48 | 0 | eventBus.fireEvent(new ProgramViewEvent()); |
49 | 0 | return majorViewController; |
50 | |
} |
51 | |
|
52 | |
public VariationViewController getVariationViewController() { |
53 | 0 | DataModel variationModel = new DataModel(); |
54 | |
|
55 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
56 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
57 | 0 | variationModel.setDefinition(definition); |
58 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
59 | 0 | variationViewController = new VariationViewController(variationModel, viewContext, eventBus, majorViewController); |
60 | 0 | return variationViewController; |
61 | |
} |
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 | |
public VariationEditController getVariationEditController() { |
90 | 0 | DataModel variationModel = new DataModel(); |
91 | |
|
92 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
93 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
94 | |
|
95 | |
|
96 | |
|
97 | 0 | variationModel.setDefinition(definition); |
98 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
99 | 0 | ProgramUtils.unregisterUnusedHandlers(eventBus); |
100 | 0 | variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController); |
101 | 0 | return variationEditController; |
102 | |
} |
103 | |
|
104 | |
public MajorEditController getProgramEditController() { |
105 | 0 | programModel.resetRoot(); |
106 | 0 | return getMajorEditController(); |
107 | |
} |
108 | |
|
109 | |
public MajorEditController getProgramSpecEditController() { |
110 | 0 | return getMajorEditController(); |
111 | |
} |
112 | |
|
113 | |
public ProgramVersionsController getProgramVersionsController() { |
114 | 0 | if (programVersionsController == null) { |
115 | 0 | programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus); |
116 | |
} |
117 | 0 | return programVersionsController; |
118 | |
} |
119 | |
|
120 | |
public static HandlerManager getEventBus() { |
121 | 0 | return eventBus; |
122 | |
} |
123 | |
|
124 | |
private MajorEditController getMajorEditController() { |
125 | 0 | if (majorEditController == null) { |
126 | 0 | majorEditController = new MajorEditController(programModel, viewContext, eventBus); |
127 | |
} |
128 | 0 | return majorEditController; |
129 | |
} |
130 | |
|
131 | |
private MajorViewController getMajorViewController() { |
132 | 0 | if (majorViewController == null) { |
133 | 0 | majorViewController = new MajorViewController(programModel, viewContext, eventBus); |
134 | |
} |
135 | 0 | return majorViewController; |
136 | |
} |
137 | |
} |