1 | |
package org.kuali.student.lum.program.client.major; |
2 | |
|
3 | |
import com.google.gwt.event.shared.HandlerManager; |
4 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
5 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
6 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
7 | |
import org.kuali.student.common.ui.client.widgets.KSErrorDialog; |
8 | |
import org.kuali.student.core.assembly.data.Metadata; |
9 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
10 | |
import org.kuali.student.lum.program.client.ProgramUtils; |
11 | |
import org.kuali.student.lum.program.client.events.ProgramViewEvent; |
12 | |
import org.kuali.student.lum.program.client.major.edit.MajorEditController; |
13 | |
import org.kuali.student.lum.program.client.major.view.MajorViewController; |
14 | |
import org.kuali.student.lum.program.client.variation.edit.VariationEditController; |
15 | |
import org.kuali.student.lum.program.client.variation.view.VariationViewController; |
16 | |
import org.kuali.student.lum.program.client.versions.ProgramVersionsController; |
17 | |
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
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 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
95 | |
|
96 | |
|
97 | |
|
98 | 0 | variationModel.setDefinition(definition); |
99 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
100 | 0 | ProgramUtils.unregisterUnusedHandlers(eventBus); |
101 | 0 | variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController); |
102 | 0 | return variationEditController; |
103 | |
} |
104 | |
|
105 | |
public MajorEditController getProgramEditController() { |
106 | 0 | programModel.resetRoot(); |
107 | 0 | return getMajorEditController(); |
108 | |
} |
109 | |
|
110 | |
public MajorEditController getProgramSpecEditController() { |
111 | 0 | return getMajorEditController(); |
112 | |
} |
113 | |
|
114 | |
public ProgramVersionsController getProgramVersionsController() { |
115 | 0 | if (programVersionsController == null) { |
116 | 0 | programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus); |
117 | |
} |
118 | 0 | return programVersionsController; |
119 | |
} |
120 | |
|
121 | |
public static HandlerManager getEventBus() { |
122 | 0 | return eventBus; |
123 | |
} |
124 | |
|
125 | |
private MajorEditController getMajorEditController() { |
126 | 0 | if (majorEditController == null) { |
127 | 0 | majorEditController = new MajorEditController(programModel, viewContext, eventBus); |
128 | |
} |
129 | 0 | return majorEditController; |
130 | |
} |
131 | |
|
132 | |
private MajorViewController getMajorViewController() { |
133 | 0 | if (majorViewController == null) { |
134 | 0 | majorViewController = new MajorViewController(programModel, viewContext, eventBus); |
135 | |
} |
136 | 0 | return majorViewController; |
137 | |
} |
138 | |
} |