View Javadoc

1   package org.kuali.student.lum.program.client.credential.view;
2   
3   import org.kuali.student.common.ui.client.configurable.mvc.Configurer;
4   import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
5   import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
6   import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
7   import org.kuali.student.common.ui.client.configurable.mvc.sections.TableSection;
8   import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
9   import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
10  import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
11  import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
12  import org.kuali.student.lum.program.client.ProgramConstants;
13  import org.kuali.student.lum.program.client.ProgramMsgConstants;
14  import org.kuali.student.lum.program.client.ProgramSections;
15  import org.kuali.student.lum.program.client.credential.CredentialEditableHeader;
16  
17  /**
18   * @author Igor
19   */
20  public class CredentialInformationViewConfiguration extends AbstractSectionConfiguration {
21  
22      public static CredentialInformationViewConfiguration create(Configurer configurer) {
23          return new CredentialInformationViewConfiguration(configurer, false);
24      }
25  
26      public static CredentialInformationViewConfiguration createSpecial(Configurer configurer) {
27          return new CredentialInformationViewConfiguration(configurer, true);
28      }
29  
30      private CredentialInformationViewConfiguration(Configurer configurer, boolean isSpecial) {
31          this.setConfigurer(configurer);
32          String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROGRAMINFORMATION);
33          if (!isSpecial){
34              this.rootSection = new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, 
35                  title, ProgramConstants.PROGRAM_MODEL_ID);
36          } else {
37              this.rootSection = new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, title,
38                      ProgramConstants.PROGRAM_MODEL_ID, new CredentialEditableHeader(title, ProgramSections.PROGRAM_DETAILS_EDIT));
39          }
40          rootSection.addStyleName("programInformationView");
41      }
42  
43      @Override
44      protected void buildLayout() {
45          HorizontalSection section = new HorizontalSection();
46          section.addSection(createIdentifyingDetailsSection());
47          section.addSection(createProgramTitleSection());
48          section.nextRow();
49          section.addSection(createDatesSection());
50          section.addSection(createOtherInformationSection());
51          rootSection.addSection(section);
52      }
53  
54      private TableSection createIdentifyingDetailsSection() {
55          TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_IDENTIFYINGDETAILS)));
56          configurer.addReadOnlyField(section, ProgramConstants.CODE, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_CODE));
57          configurer.addReadOnlyField(section, ProgramConstants.PROGRAM_LEVEL, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_LEVEL));
58          configurer.addReadOnlyField(section, ProgramConstants.DEGREE_TYPE, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_DEGREETYPE));
59          return section;
60      }
61  
62      private TableSection createProgramTitleSection() {
63          TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_PROGRAMTITLE)));
64          configurer.addReadOnlyField(section, ProgramConstants.LONG_TITLE, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLEFULL));
65          configurer.addReadOnlyField(section, ProgramConstants.SHORT_TITLE, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_TITLESHORT));
66          return section;
67      }
68  
69      private TableSection createDatesSection() {
70          TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_DATES)));
71          // Add this field and hide it so it is available for cross field validation
72          FieldDescriptor fd = configurer.addField(section, ProgramConstants.PREV_START_TERM, new MessageKeyInfo(ProgramMsgConstants.MAJORDISCIPLINE_PREVSTARTTERM));
73          fd.getFieldWidget().setVisible(false);
74          fd.hideLabel();
75  
76          configurer.addReadOnlyField(section, ProgramConstants.START_TERM, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_STARTTERM));
77          configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENTRYTERM));
78          configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENROLLTERM));
79          return section;
80      }
81  
82      private TableSection createOtherInformationSection() {
83          TableSection section = new TableSection(SectionTitle.generateH4Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_OTHERINFORMATION)));
84          configurer.addReadOnlyField(section, ProgramConstants.INSTITUTION + "/" + ProgramConstants.ORG_ID, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_INSTITUTION));
85          return section;
86      }
87  
88      public VerticalSection createActivateProgramSection() {
89          final VerticalSection section = new VerticalSection(SectionTitle.generateH2Title(getLabel(ProgramMsgConstants.PROGRAMINFORMATION_ACTIVATEPROGRAM)));
90          section.setInstructions("<br>" + getLabel(ProgramMsgConstants.PROGRAMINFORMATION_ACTIVATEINSTRUCTIONS) + "<br><br>");
91          configurer.addField(section, "proposal/" + ProgramConstants.PREV_END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENTRYTERM));
92          configurer.addField(section, "proposal/" + ProgramConstants.PREV_END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramMsgConstants.PROGRAMINFORMATION_ENROLLTERM));
93          return section;
94      }
95  }