View Javadoc

1   package org.kuali.student.lum.lu.ui.course.client.configuration;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
7   import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
8   import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
9   import org.kuali.student.common.ui.client.mvc.Controller;
10  import org.kuali.student.common.ui.client.mvc.DataModelDefinition;
11  import org.kuali.student.common.ui.client.widgets.KSButton;
12  import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
13  import org.kuali.student.common.ui.client.widgets.KSCharCount;
14  import org.kuali.student.core.comments.ui.client.widgets.commenttool.CommentTool;
15  import org.kuali.student.core.comments.ui.client.widgets.decisiontool.DecisionPanel;
16  import org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentTool;
17  import org.kuali.student.core.workflow.ui.client.views.CollaboratorSectionView;
18  import org.kuali.student.lum.common.client.lu.LUUIConstants;
19  import org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminRetireController;
20  import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController;
21  import org.kuali.student.r1.common.assembly.data.QueryPath;
22  import org.kuali.student.r2.common.dto.DtoConstants;
23  
24  import com.google.gwt.core.client.GWT;
25  import com.google.gwt.event.dom.client.ClickEvent;
26  import com.google.gwt.event.dom.client.ClickHandler;
27  import org.kuali.student.lum.lu.assembly.data.client.constants.base.RichTextInfoConstants;
28  
29  
30  /**
31   * Shell of Configurer for Retire by Proposal
32   * 
33   * @author mike
34   *
35   */
36  public class CourseRetireByProposalConfigurer extends CourseProposalConfigurer {
37  
38      /**
39       * Sets up all the views and sections of {@link CourseAdminRetireController}. This
40       * should be called once for initialization and setup per
41       * {@link CourseAdminRetireController} instance.
42       * 
43       * @param layout
44       */
45      @Override
46      public void configure(final CourseProposalController layout) {
47          type = "course";
48          state = DtoConstants.STATE_DRAFT;
49          nextState = DtoConstants.STATE_RETIRED;
50  
51          groupName = LUUIConstants.COURSE_GROUP_NAME;
52  
53          if (modelDefinition.getMetadata().isCanEdit()) {
54              addCluStartSection(layout);
55              String sections = getLabel(LUUIConstants.COURSE_SECTIONS);
56  
57              layout.addMenu(sections);
58                  
59              //Retirement Info
60              layout.addMenuItem(sections, (SectionView)generateRetirementInfoSection(initSectionView(CourseSections.COURSE_INFO, getLabel(LUUIConstants.RETIREMENT_LABEL_KEY))));
61  
62              //Collaborators
63              layout.addMenuItem(sections, new CollaboratorSectionView(CourseSections.PEOPLE_PERMISSONS, getLabel(LUUIConstants.SECTION_AUTHORS_AND_COLLABORATORS), COURSE_PROPOSAL_MODEL));
64  
65              //Documents
66              documentTool = new DocumentTool(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE,CourseSections.DOCUMENTS, getLabel(LUUIConstants.TOOL_DOCUMENTS_LABEL_KEY));
67              documentTool.setModelDefinition((DataModelDefinition)modelDefinition);
68              layout.addMenuItem(sections, documentTool);
69          
70              //Add common buttons to sections except for sections with specific button behavior
71              List<Enum<?>> excludedViews = new ArrayList<Enum<?>>();
72              excludedViews.add(CourseSections.DOCUMENTS);
73              excludedViews.add(CourseSections.COURSE_REQUISITES);
74              layout.addCommonButton(LUUIConstants.COURSE_SECTIONS, layout.getSaveButton(), excludedViews);
75              layout.addCommonButton(LUUIConstants.COURSE_SECTIONS, layout.getCancelButton(CourseSections.SUMMARY), excludedViews);
76  
77              //Summary
78              summaryConfigurer = GWT.create(CourseRetireSummaryConfigurer.class);
79              summaryConfigurer.init(type, state, groupName,(DataModelDefinition)modelDefinition, stmtTypes, (Controller)layout, COURSE_PROPOSAL_MODEL);
80              layout.addSpecialMenuItem(summaryConfigurer.generateProposalSummarySection(true), "Review and Submit");
81          
82              //Specific buttons for certain views
83              //TODO people and permissions will use a different button than continue
84              layout.addButtonForView(CourseSections.DOCUMENTS, getContinueButton(layout));
85          } else {
86              summaryConfigurer = GWT.create(CourseRetireSummaryConfigurer.class);
87              summaryConfigurer.init(type, state, groupName,(DataModelDefinition)modelDefinition, stmtTypes, (Controller)layout, COURSE_PROPOSAL_MODEL);
88              layout.removeMenuNavigation();
89              layout.addView(summaryConfigurer.generateProposalSummarySection(false));
90          }       
91          
92          // Proposal Status
93          layout.addContentWidget(layout.getWfUtilities().getProposalStatusLabel());
94          
95          // Comment Tool
96          final CommentTool commentTool = new CommentTool(CourseSections.COMMENTS, getLabel(LUUIConstants.TOOL_COMMENTS_LABEL_KEY), "kuali.comment.type.generalRemarks", "Proposal Comments");
97          commentTool.setController(layout);
98          
99          layout.addContentWidget(new KSButton("Comments", ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() {
100             
101             @Override
102             public void onClick(ClickEvent event) {
103                 commentTool.show();
104             }
105         }));
106        
107         // Decision Tool
108         final DecisionPanel decisionPanel = new DecisionPanel(CourseSections.DECISIONS, getLabel(LUUIConstants.TOOL_DECISION_LABEL_KEY), "kuali.comment.type.generalRemarks");
109         layout.addView(decisionPanel);
110         layout.addContentWidget(new KSButton("Decisions", ButtonStyle.DEFAULT_ANCHOR, new ClickHandler() {
111 
112             @Override
113             public void onClick(ClickEvent event) {
114                 decisionPanel.show();
115             }
116         }));
117     }
118     
119     protected Section generateRetirementInfoSection(Section section) {
120         FieldDescriptor fd = addField(section, PROPOSAL_PATH + "/" + PREV_START_TERM, generateMessageInfo(LUUIConstants.PROPOSAL_PREV_START_TERM));
121         fd.getFieldWidget().setVisible(false);
122         fd.hideLabel();
123         
124         addField(section, PROPOSAL_TITLE_PATH, generateMessageInfo(LUUIConstants.PROPOSED_PROPOSAL_TITLE_LABEL_KEY));
125         addField(section, PROPOSAL_PATH + "/" + PROPOSED_RATIONALE + "/" + RichTextInfoConstants.PLAIN, generateMessageInfo(LUUIConstants.RETIREMENT_RATIONALE_LABEL_KEY),
126         new KSCharCount(modelDefinition.getMetadata(QueryPath.parse(PROPOSAL_PATH + "/" + PROPOSED_RATIONALE+ "/" + RichTextInfoConstants.PLAIN))));        
127         addReadOnlyField(section, COURSE + "/" + START_TERM, generateMessageInfo(LUUIConstants.START_TERM_LABEL_KEY));
128         addField(section, PROPOSAL_PATH + "/" + PROPOSED_END_TERM, generateMessageInfo(LUUIConstants.PROPOSED_END_TERM_LABEL_KEY));
129         addField(section, PROPOSAL_PATH + "/" + PROPOSED_LAST_TERM_OFFERED, generateMessageInfo(LUUIConstants.PROPOSED_LAST_TERM_OFFERED_LABEL_KEY));
130         addField(section, PROPOSAL_PATH + "/" + PROPOSED_LAST_COURSE_CATALOG_YEAR, generateMessageInfo(LUUIConstants.PROPOSED_LAST_COURSE_CATALOG_YEAR_LABEL_KEY));
131         addField(section, PROPOSAL_PATH + "/" + OTHER_COMMENTS, generateMessageInfo(LUUIConstants.OTHER_COMMENTS_LABEL_KEY));
132         
133         return section;
134     }
135 
136 }