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 | 0 | public abstract class AbstractProgramConfigurer extends Configurer { |
17 | |
|
18 | |
private ProgramController programController; |
19 | |
|
20 | |
protected ConfigurationManager programSectionConfigManager; |
21 | |
|
22 | |
public void configure(ProgramController viewController) { |
23 | 0 | this.programController = viewController; |
24 | 0 | configureProgramSections(); |
25 | 0 | } |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
private void configureProgramSections() { |
31 | 0 | String programSectionLabel = ProgramProperties.get().program_menu_sections(); |
32 | 0 | programController.addMenu(programSectionLabel); |
33 | 0 | ArrayList<Configuration> configurations = programSectionConfigManager.getConfigurations(); |
34 | 0 | for (Configuration configuration : configurations) { |
35 | 0 | if (configuration instanceof AbstractControllerConfiguration) { |
36 | 0 | ((AbstractControllerConfiguration) configuration).setController(programController); |
37 | |
} |
38 | 0 | if (configuration instanceof MajorSummaryConfiguration) { |
39 | 0 | programController.addSpecialMenuItem(configuration.getView(), programSectionLabel); |
40 | |
} else { |
41 | 0 | programController.addMenuItem(programSectionLabel, configuration.getView()); |
42 | |
} |
43 | |
} |
44 | 0 | } |
45 | |
|
46 | |
public ProgramController getProgramController() { |
47 | 0 | return programController; |
48 | |
} |
49 | |
|
50 | |
public void applyPermissions() { |
51 | 0 | DataModel dataModel = programController.getProgramModel(); |
52 | 0 | for (Configuration configuration : programSectionConfigManager.getConfigurations()) { |
53 | 0 | if (configuration.checkPermission(dataModel)) { |
54 | 0 | configuration.applyRestrictions(); |
55 | |
}else{ |
56 | 0 | configuration.removeRestrictions(); |
57 | |
} |
58 | |
} |
59 | 0 | } |
60 | |
|
61 | |
public ConfigurationManager getProgramSectionConfigManager() { |
62 | 0 | return programSectionConfigManager; |
63 | |
} |
64 | |
} |