View Javadoc

1   package org.kuali.student.lum.lu.ui.course.client.configuration;
2   
3   import org.kuali.student.common.dto.DtoConstants;
4   import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
5   import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
6   import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
7   import org.kuali.student.common.ui.client.mvc.View;
8   import org.kuali.student.common.ui.client.widgets.KSLabel;
9   import org.kuali.student.lum.common.client.lu.LUUIConstants;
10  import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminRetireController;
11  import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController;
12  import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsViewController;
13  
14  /**
15   * This is the screen configuration and layout for the admin retire screen
16   * 
17   * @author Will
18   * 
19   */
20  public class CourseAdminRetireConfigurer extends CourseProposalConfigurer {
21  
22      protected CourseRequirementsViewController requisitesSection;
23  
24      /**
25       * Sets up all the views and sections of {@link CourseAdminRetireController}. This
26       * should be called once for initialization and setup per
27       * {@link CourseAdminRetireController} instance.
28       * 
29       * @param layout
30       */
31      @Override
32      public void configure(final CourseProposalController layout) {
33          type = "course";
34          state = DtoConstants.STATE_RETIRED;
35          nextState = DtoConstants.STATE_RETIRED;
36  
37          groupName = LUUIConstants.COURSE_GROUP_NAME;
38  
39          KSLabel courseStatusLabel = new KSLabel("");
40          if (layout.getCourseState() != null)
41              courseStatusLabel.setText(getLabel("courseStatusLabel") + ": " + layout.getCourseState());
42          else
43              courseStatusLabel.setText(getLabel("courseStatusLabel") + ": Unknown");
44          layout.addContentWidget(courseStatusLabel);
45  
46          layout.addView(generateCourseAdminView((CourseAdminRetireController) layout));
47      }
48  
49      /**
50       * Configuration for the course admin screens
51       * 
52       * @return view
53       */
54      protected View generateCourseAdminView(final CourseAdminRetireController layout) {
55          VerticalSectionView view =
56                  new VerticalSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.RETIREMENT_LABEL_KEY),
57                          COURSE_PROPOSAL_MODEL, false);
58          view.addStyleName(LUUIConstants.STYLE_SECTION);
59  
60          // Create course admin sections
61          Section activeDatesSection = generateActiveDatesSection(initSection(LUUIConstants.ACTIVE_DATES_LABEL_KEY));
62          Section retirementSection = generateRetirementSection(initSection(LUUIConstants.RETIREMENT_LABEL_KEY));
63  
64          //Add course admin sections to view
65          view.addSection(activeDatesSection);
66          view.addSection(retirementSection);
67  
68          //Add menu items for sections
69          String sections = getLabel(LUUIConstants.COURSE_SECTIONS);
70          layout.addMenu(sections);
71          layout.addMenuItemSection(sections, getLabel(LUUIConstants.ACTIVE_DATES_LABEL_KEY),
72                  LUUIConstants.ACTIVE_DATES_LABEL_KEY, activeDatesSection.getLayout());
73          layout.addMenuItemSection(sections, getLabel(LUUIConstants.RETIREMENT_LABEL_KEY),
74                  LUUIConstants.RETIREMENT_LABEL_KEY, retirementSection.getLayout());
75  
76          //Add buttons to top and bottom of view
77          layout.addButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton());
78          layout.addButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton());
79          layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getSaveButton());
80          layout.addTopButtonForView(CourseSections.COURSE_INFO, layout.getCancelButton());
81  
82          return view;
83      }
84  
85      protected Section generateActiveDatesSection(Section section) {
86          addReadOnlyField(section, COURSE + "/" + START_TERM, generateMessageInfo(LUUIConstants.START_TERM_LABEL_KEY));
87          addField(section, COURSE + "/" + END_TERM, generateMessageInfo(LUUIConstants.END_TERM_LABEL_KEY));
88  
89          return section;
90      }
91  
92      protected Section generateRetirementSection(Section section) {
93          addField(section, COURSE + "/" + RETIREMENT_RATIONALE,
94                  generateMessageInfo(LUUIConstants.RETIREMENT_RATIONALE_LABEL_KEY));
95          addField(section, COURSE + "/" + LAST_TERM_OFFERED,
96                  generateMessageInfo(LUUIConstants.LAST_TERM_OFFERED_LABEL_KEY));
97          addField(section, COURSE + "/" + LAST_PUBLICATION_YEAR,
98                  generateMessageInfo(LUUIConstants.LAST_PUBLICATION_YEAR_LABEL_KEY));
99          addField(section, COURSE + "/" + SPECIAL_CIRCUMSTANCES,
100                 generateMessageInfo(LUUIConstants.SPECIAL_CIRCUMSTANCES_LABEL_KEY));
101 
102         return section;
103     }
104 
105     protected Section initSection(String labelKey) {
106         return initSection(SectionTitle.generateH2Title(getLabel(labelKey)), NO_DIVIDER);
107     }
108 
109 }