1 | |
package org.kuali.student.lum.program.client.major; |
2 | |
|
3 | |
import com.google.gwt.event.shared.HandlerManager; |
4 | |
|
5 | |
import org.kuali.student.common.assembly.data.Metadata; |
6 | |
import org.kuali.student.common.ui.client.application.ViewContext; |
7 | |
import org.kuali.student.common.ui.client.mvc.DataModel; |
8 | |
import org.kuali.student.common.ui.client.mvc.DataModelDefinition; |
9 | |
import org.kuali.student.common.ui.client.widgets.KSErrorDialog; |
10 | |
import org.kuali.student.lum.program.client.ProgramRegistry; |
11 | |
import org.kuali.student.lum.program.client.ProgramUtils; |
12 | |
import org.kuali.student.lum.program.client.events.ProgramViewEvent; |
13 | |
import org.kuali.student.lum.program.client.major.edit.MajorEditController; |
14 | |
import org.kuali.student.lum.program.client.major.view.MajorViewController; |
15 | |
import org.kuali.student.lum.program.client.variation.edit.VariationEditController; |
16 | |
import org.kuali.student.lum.program.client.variation.view.VariationViewController; |
17 | |
import org.kuali.student.lum.program.client.versions.ProgramVersionsController; |
18 | |
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class MajorManager { |
24 | |
|
25 | |
private MajorViewController majorViewController; |
26 | |
|
27 | |
private MajorEditController majorEditController; |
28 | |
|
29 | |
private VariationViewController variationViewController; |
30 | |
|
31 | |
private VariationEditController variationEditController; |
32 | |
|
33 | |
private ProgramVersionsController programVersionsController; |
34 | |
|
35 | |
protected DataModel programModel; |
36 | |
|
37 | 0 | private ViewContext viewContext = new ViewContext(); |
38 | |
|
39 | |
private static HandlerManager eventBus; |
40 | |
|
41 | 0 | public MajorManager() { |
42 | 0 | eventBus = new HandlerManager(null); |
43 | 0 | programModel = new DataModel(); |
44 | 0 | ProgramRegistry.getSpecializationHandlers().clear(); |
45 | 0 | } |
46 | |
|
47 | |
public MajorViewController getProgramViewController() { |
48 | 0 | programModel.resetRoot(); |
49 | 0 | getMajorViewController(); |
50 | 0 | eventBus.fireEvent(new ProgramViewEvent()); |
51 | 0 | return majorViewController; |
52 | |
} |
53 | |
|
54 | |
public VariationViewController getVariationViewController() { |
55 | 0 | DataModel variationModel = new DataModel(); |
56 | |
|
57 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
58 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
59 | 0 | variationModel.setDefinition(definition); |
60 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
61 | 0 | variationViewController = new VariationViewController(variationModel, viewContext, eventBus, majorViewController); |
62 | 0 | return variationViewController; |
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 | |
|
91 | |
public VariationEditController getVariationEditController() { |
92 | 0 | DataModel variationModel = new DataModel(); |
93 | |
|
94 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
95 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
96 | |
|
97 | |
|
98 | |
|
99 | 0 | variationModel.setDefinition(definition); |
100 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
101 | 0 | ProgramUtils.unregisterUnusedHandlers(eventBus); |
102 | 0 | variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController); |
103 | 0 | return variationEditController; |
104 | |
} |
105 | |
|
106 | |
public MajorEditController getProgramEditController() { |
107 | 0 | programModel.resetRoot(); |
108 | 0 | return getMajorEditController(); |
109 | |
} |
110 | |
|
111 | |
public MajorEditController getProgramSpecEditController() { |
112 | 0 | return getMajorEditController(); |
113 | |
} |
114 | |
|
115 | |
public ProgramVersionsController getProgramVersionsController() { |
116 | 0 | if (programVersionsController == null) { |
117 | 0 | programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus); |
118 | |
} |
119 | 0 | return programVersionsController; |
120 | |
} |
121 | |
|
122 | |
public static HandlerManager getEventBus() { |
123 | 0 | return eventBus; |
124 | |
} |
125 | |
|
126 | |
private MajorEditController getMajorEditController() { |
127 | 0 | if (majorEditController == null) { |
128 | 0 | majorEditController = new MajorEditController(programModel, viewContext, eventBus); |
129 | |
} |
130 | 0 | return majorEditController; |
131 | |
} |
132 | |
|
133 | |
private MajorViewController getMajorViewController() { |
134 | 0 | if (majorViewController == null) { |
135 | 0 | majorViewController = new MajorViewController(programModel, viewContext, eventBus); |
136 | |
} |
137 | 0 | return majorViewController; |
138 | |
} |
139 | |
} |