1 package org.kuali.student.lum.program.client;
2
3 import java.util.ArrayList;
4
5 import org.kuali.student.common.ui.client.configurable.mvc.Configurer;
6 import org.kuali.student.common.ui.client.mvc.DataModel;
7 import org.kuali.student.lum.common.client.configuration.AbstractControllerConfiguration;
8 import org.kuali.student.lum.common.client.configuration.Configuration;
9 import org.kuali.student.lum.common.client.configuration.ConfigurationManager;
10 import org.kuali.student.lum.program.client.major.edit.MajorSummaryConfiguration;
11 import org.kuali.student.lum.program.client.properties.ProgramProperties;
12
13
14
15
16 public abstract class AbstractProgramConfigurer extends Configurer {
17
18 protected ProgramController programController;
19
20 protected ConfigurationManager programSectionConfigManager;
21
22 public static final String PROPOSAL_PATH = "proposal";
23
24 public void configure(ProgramController viewController) {
25 this.programController = viewController;
26 configureProgramSections();
27 }
28
29 public String getProposalPath() {
30 return PROPOSAL_PATH;
31 }
32
33
34
35 private void configureProgramSections() {
36 String programSectionLabel = ProgramProperties.get().program_menu_sections();
37 programController.addMenu(programSectionLabel);
38 ArrayList<Configuration> configurations = getProgramSectionConfigManager().getConfigurations();
39 for (Configuration configuration : configurations) {
40 if (configuration instanceof AbstractControllerConfiguration) {
41 ((AbstractControllerConfiguration) configuration).setController(programController);
42 }
43 if (configuration instanceof MajorSummaryConfiguration) {
44 programController.addSpecialMenuItem(configuration.getView(), programSectionLabel);
45 } else {
46 programController.addMenuItem(programSectionLabel, configuration.getView());
47 }
48 }
49 }
50
51 public ProgramController getProgramController() {
52 return programController;
53 }
54
55 public void applyPermissions() {
56 DataModel dataModel = programController.getProgramModel();
57 for (Configuration configuration : programSectionConfigManager.getConfigurations()) {
58 if (configuration.checkPermission(dataModel)) {
59 configuration.applyRestrictions();
60 }else{
61 configuration.removeRestrictions();
62 }
63 }
64 }
65
66 public ConfigurationManager getProgramSectionConfigManager() {
67 return programSectionConfigManager;
68 }
69 }