View Javadoc

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  
12  /**
13   * @author Igor
14   */
15  public abstract class AbstractProgramConfigurer extends Configurer {
16  
17      protected ProgramController programController;
18  
19      protected ConfigurationManager programSectionConfigManager;
20  
21      public static final String PROPOSAL_PATH = "proposal";
22      
23      {
24          groupName = ProgramMsgConstants.PROGRAM_MSG_GROUP;
25      }
26      
27      public void configure(ProgramController viewController) {
28          this.programController = viewController;
29          configureProgramSections();
30      }
31   
32      public String getProposalPath() {
33          return PROPOSAL_PATH;
34      }
35      /**
36       * Configures menu for Program Sections
37       */
38      private void configureProgramSections() {
39          String programSectionLabel = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS);
40          programController.addMenu(programSectionLabel);
41          ArrayList<Configuration> configurations = getProgramSectionConfigManager().getConfigurations();
42          for (Configuration configuration : configurations) {
43              if (configuration instanceof AbstractControllerConfiguration) {
44                  ((AbstractControllerConfiguration) configuration).setController(programController);
45              }
46              if (configuration instanceof MajorSummaryConfiguration) {
47                  programController.addSpecialMenuItem(configuration.getView(), programSectionLabel);
48              } else {
49                  programController.addMenuItem(programSectionLabel, configuration.getView());
50              }
51          }
52      }
53  
54      public ProgramController getProgramController() {
55          return programController;
56      }
57  
58      public void applyPermissions() {
59          DataModel dataModel = programController.getProgramModel();
60          for (Configuration configuration : programSectionConfigManager.getConfigurations()) {
61              if (configuration.checkPermission(dataModel)) {
62                  configuration.applyRestrictions();
63              }else{
64                  configuration.removeRestrictions();
65              }
66          }
67      }
68  
69      public ConfigurationManager getProgramSectionConfigManager() {
70          return programSectionConfigManager;
71      }
72  }