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.proposal.MajorProposalController; |
11 | |
import org.kuali.student.lum.program.client.major.view.MajorViewController; |
12 | |
import org.kuali.student.lum.program.client.variation.edit.VariationEditController; |
13 | |
import org.kuali.student.lum.program.client.variation.view.VariationViewController; |
14 | |
import org.kuali.student.lum.program.client.versions.ProgramVersionsController; |
15 | |
import org.kuali.student.lum.program.client.widgets.ProgramSideBar; |
16 | |
|
17 | |
import com.google.gwt.event.shared.HandlerManager; |
18 | |
import com.google.gwt.user.client.Window; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class MajorManager { |
24 | |
|
25 | |
private MajorProposalController majorProposalController; |
26 | |
|
27 | |
private MajorViewController majorViewController; |
28 | |
|
29 | |
private MajorEditController majorEditController; |
30 | |
|
31 | |
private VariationViewController variationViewController; |
32 | |
|
33 | |
private VariationEditController variationEditController; |
34 | |
|
35 | |
private ProgramVersionsController programVersionsController; |
36 | |
|
37 | |
protected DataModel programModel; |
38 | |
|
39 | 0 | private ViewContext viewContext = new ViewContext(); |
40 | |
|
41 | |
private static HandlerManager eventBus; |
42 | |
|
43 | 0 | public MajorManager() { |
44 | 0 | eventBus = new HandlerManager(null); |
45 | 0 | programModel = new DataModel(); |
46 | 0 | ProgramRegistry.getSpecializationHandlers().clear(); |
47 | 0 | } |
48 | |
|
49 | |
public MajorViewController getProgramViewController() { |
50 | 0 | programModel.resetRoot(); |
51 | 0 | getMajorViewController(); |
52 | 0 | eventBus.fireEvent(new ProgramViewEvent()); |
53 | 0 | return majorViewController; |
54 | |
} |
55 | |
|
56 | |
public VariationViewController getVariationViewController() { |
57 | 0 | DataModel variationModel = new DataModel(); |
58 | |
|
59 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
60 | 0 | definition.setMetadata (programModel.getDefinition ().getMetadata ("variations/*")); |
61 | 0 | variationModel.setDefinition(definition); |
62 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
63 | 0 | variationViewController = new VariationViewController(variationModel, viewContext, eventBus, majorViewController); |
64 | 0 | return variationViewController; |
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 | |
|
92 | |
|
93 | |
public VariationEditController getVariationEditController() { |
94 | 0 | DataModel variationModel = new DataModel(); |
95 | |
|
96 | 0 | DataModelDefinition definition = new DataModelDefinition (); |
97 | |
|
98 | 0 | if(programModel==null||programModel.getDefinition()==null){ |
99 | 0 | Window.alert("Debug: null programModel or definition (MajorManager.getVariationEditController()"); |
100 | |
} |
101 | 0 | definition.setMetadata(programModel.getDefinition().getMetadata("variations/*")); |
102 | |
|
103 | |
|
104 | |
|
105 | 0 | variationModel.setDefinition(definition); |
106 | 0 | variationModel.setRoot(ProgramRegistry.getData()); |
107 | 0 | ProgramUtils.unregisterUnusedHandlers(eventBus); |
108 | 0 | variationEditController = new VariationEditController(variationModel, viewContext, eventBus, majorEditController); |
109 | 0 | return variationEditController; |
110 | |
} |
111 | |
|
112 | |
public MajorEditController getProgramEditController() { |
113 | 0 | programModel.resetRoot(); |
114 | 0 | return getMajorEditController(); |
115 | |
} |
116 | |
|
117 | |
public MajorEditController getProgramSpecEditController() { |
118 | 0 | return getMajorEditController(); |
119 | |
} |
120 | |
|
121 | |
public ProgramVersionsController getProgramVersionsController() { |
122 | 0 | if (programVersionsController == null) { |
123 | 0 | programVersionsController = new ProgramVersionsController(programModel, ProgramSideBar.Type.MAJOR, viewContext, eventBus); |
124 | |
} |
125 | 0 | return programVersionsController; |
126 | |
} |
127 | |
|
128 | |
public static HandlerManager getEventBus() { |
129 | 0 | return eventBus; |
130 | |
} |
131 | |
|
132 | |
public MajorProposalController getMajorProposalController() { |
133 | 0 | if (majorProposalController == null) { |
134 | 0 | majorProposalController = new MajorProposalController(programModel, viewContext, eventBus); |
135 | |
} |
136 | 0 | return majorProposalController; |
137 | |
} |
138 | |
|
139 | |
|
140 | |
public MajorEditController getMajorEditController() { |
141 | 0 | if (majorEditController == null) { |
142 | 0 | majorEditController = new MajorEditController(programModel, viewContext, eventBus); |
143 | |
} |
144 | 0 | return majorEditController; |
145 | |
} |
146 | |
|
147 | |
private MajorViewController getMajorViewController() { |
148 | 0 | if (majorViewController == null) { |
149 | 0 | majorViewController = new MajorViewController(programModel, viewContext, eventBus); |
150 | |
} |
151 | 0 | return majorViewController; |
152 | |
} |
153 | |
|
154 | |
public DataModel getProgramModel() { |
155 | 0 | return programModel; |
156 | |
} |
157 | |
} |