View Javadoc

1   package org.kuali.student.lum.program.client.credential.view;
2   
3   import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
4   import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
5   import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
6   import org.kuali.student.common.ui.client.configurable.mvc.sections.TableSection;
7   import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
8   import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
9   import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
10  import org.kuali.student.common.ui.client.mvc.Controller;
11  import org.kuali.student.common.ui.client.mvc.DataModel;
12  import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
13  import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
14  import org.kuali.student.core.workflow.ui.client.widgets.WorkflowUtilities;
15  import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
16  import org.kuali.student.lum.program.client.ProgramConstants;
17  import org.kuali.student.lum.program.client.ProgramSections;
18  import org.kuali.student.lum.program.client.credential.CredentialEditableHeader;
19  import org.kuali.student.lum.program.client.properties.ProgramProperties;
20  
21  /**
22   * @author Igor
23   */
24  public class CredentialInformationViewConfiguration extends AbstractSectionConfiguration {
25  
26      public static CredentialInformationViewConfiguration create() {
27          CredentialInformationViewConfiguration instance = new CredentialInformationViewConfiguration(new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, ProgramProperties.get().program_menu_sections_programInformation(), ProgramConstants.PROGRAM_MODEL_ID));
28          return instance;
29      }
30  
31      public static CredentialInformationViewConfiguration createSpecial() {
32          CredentialInformationViewConfiguration instance = new CredentialInformationViewConfiguration(new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_VIEW, ProgramProperties.get().program_menu_sections_programInformation(), ProgramConstants.PROGRAM_MODEL_ID, new CredentialEditableHeader(ProgramProperties.get().program_menu_sections_programInformation(), ProgramSections.PROGRAM_DETAILS_EDIT)));
33          return instance;
34      }
35  
36      private CredentialInformationViewConfiguration(SectionView sectionView) {
37          rootSection = sectionView;
38          rootSection.addStyleName("programInformationView");
39      }
40  
41      @Override
42      protected void buildLayout() {
43          HorizontalSection section = new HorizontalSection();
44          section.addSection(createIdentifyingDetailsSection());
45          section.addSection(createProgramTitleSection());
46          section.nextRow();
47          section.addSection(createDatesSection());
48          section.addSection(createOtherInformationSection());
49          rootSection.addSection(section);
50      }
51  
52      private TableSection createIdentifyingDetailsSection() {
53          TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_identifyingDetails()));
54          configurer.addReadOnlyField(section, ProgramConstants.CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_code()));
55          configurer.addReadOnlyField(section, ProgramConstants.PROGRAM_LEVEL, new MessageKeyInfo(ProgramProperties.get().programInformation_level()));
56          configurer.addReadOnlyField(section, ProgramConstants.DEGREE_TYPE, new MessageKeyInfo(ProgramProperties.get().programInformation_degreeType()));
57          return section;
58      }
59  
60      private TableSection createProgramTitleSection() {
61          TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_programTitle()));
62          configurer.addReadOnlyField(section, ProgramConstants.LONG_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleFull()));
63          configurer.addReadOnlyField(section, ProgramConstants.SHORT_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleShort()));
64          return section;
65      }
66  
67      private TableSection createDatesSection() {
68          TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_dates()));
69          //Add this field and hide it so it is available for cross field validation 
70          FieldDescriptor fd = configurer.addField(section,ProgramConstants.PREV_START_TERM, new MessageKeyInfo(ProgramProperties.get().majorDiscipline_prevStartTerm()));
71          fd.getFieldWidget().setVisible(false);
72          fd.hideLabel();
73  
74          
75          configurer.addReadOnlyField(section, ProgramConstants.START_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_startTerm()));
76          configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm()));
77          configurer.addReadOnlyField(section, ProgramConstants.END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_enrollTerm()));
78          return section;
79      }
80  
81      private TableSection createOtherInformationSection() {
82          TableSection section = new TableSection(SectionTitle.generateH4Title(ProgramProperties.get().programInformation_otherInformation()));
83          configurer.addReadOnlyField(section, ProgramConstants.INSTITUTION + "/" + ProgramConstants.ORG_ID, new MessageKeyInfo(ProgramProperties.get().programInformation_institution()));
84          return section;
85      }
86  
87      public VerticalSection createActivateProgramSection(){
88          final VerticalSection section = new VerticalSection(SectionTitle.generateH2Title(ProgramProperties.get().programInformation_activateProgram()));
89          section.setInstructions("<br>" + ProgramProperties.get().programInformation_activateInstructions() + "<br><br>");
90          configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm()));
91          configurer.addField(section, "proposal/"+ProgramConstants.PREV_END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_enrollTerm()));
92          return section;
93      }    
94  }