View Javadoc

1   package org.kuali.student.lum.program.client.major.view;
2   
3   import org.kuali.student.r1.common.assembly.data.Metadata;
4   import org.kuali.student.r1.common.assembly.data.QueryPath;
5   import org.kuali.student.common.ui.client.configurable.mvc.Configurer;
6   import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptorReadOnly;
7   import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
8   import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
9   import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
10  import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
11  import org.kuali.student.common.ui.client.mvc.Controller;
12  import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
13  import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldBlock;
14  import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldRow;
15  import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection;
16  import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
17  import org.kuali.student.lum.program.client.ProgramConstants;
18  import org.kuali.student.lum.program.client.ProgramMsgConstants;
19  import org.kuali.student.lum.program.client.ProgramSections;
20  import org.kuali.student.lum.program.client.major.MajorEditableHeader;
21  import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
22  
23  import com.google.gwt.user.client.ui.Widget;
24  
25  /**
26   * @author Igor
27   */
28  public class ProposalChangeImpactViewConfiguration extends AbstractSectionConfiguration {
29      
30      private Controller controller;
31  
32      public static ProposalChangeImpactViewConfiguration create(Configurer configurer) { 
33          return new ProposalChangeImpactViewConfiguration(configurer);
34      }
35  
36      public static ProposalChangeImpactViewConfiguration createSpecial(Configurer configurer, Controller controller) { 
37          return new ProposalChangeImpactViewConfiguration(configurer, controller);
38      }
39  
40      private ProposalChangeImpactViewConfiguration(Configurer configurer) {
41          this.setConfigurer(configurer);
42          String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROPOSALCHANGEIMPACT);
43          rootSection = new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_CHANGE_IMPACT_VIEW, 
44                  title, ProgramConstants.PROGRAM_MODEL_ID);
45      }
46  
47      private ProposalChangeImpactViewConfiguration(Configurer configurer, Controller controller) {
48          this.setConfigurer(configurer);
49          String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROPOSALCHANGEIMPACT);
50          rootSection = new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_CHANGE_IMPACT_VIEW, 
51                  title, ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(title, 
52                          ProgramSections.PROGRAM_PROPOSAL_CHANGE_IMPACT_EDIT));
53          this.controller = controller;
54      }
55  
56      @Override
57      protected void buildLayout() {
58          if (controller instanceof MajorProposalController) {
59          	rootSection.addSection(createEditableSection());
60          } else {
61          	rootSection.addSection(createReadOnlySection());
62          }
63      }  
64      
65      private Section createEditableSection() {
66          SummaryTableSection section = new SummaryTableSection(controller);             
67          section.setEditable(false);
68          section.addSummaryTableFieldBlock(createSummaryTableFieldBlock());
69          return section;
70      }
71      
72      public SummaryTableFieldBlock createSummaryTableFieldBlock() {
73          SummaryTableFieldBlock block = new SummaryTableFieldBlock();
74          block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_RELATED_COURSE_CHANGES_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLURELATEDCOURSECHANGESTYPE)));
75          block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_IMPACTED_UNITS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDUNITSTYPE)));
76          block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_IMPACTED_ARTICULATION_TRANSFER_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDARTICULATIONTRANSFERPROGRAMSTYPE)));
77          block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_STUDENT_TRANSITION_PLANS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUSTUDENTTRANSITIONPLANSTYPE)));
78          return block;
79      }
80      
81      protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
82          return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
83      }
84       
85      protected SummaryTableFieldRow getFieldRow(String fieldKey,
86              MessageKeyInfo messageKey, Widget widget, Widget widget2,
87              String parentPath, ModelWidgetBinding<?> binding, boolean optional) 
88      {
89          QueryPath path = QueryPath.concat(parentPath, fieldKey);
90          Metadata meta = configurer.getModelDefinition().getMetadata(path);
91  
92          FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
93          if (widget != null) {
94              fd.setFieldWidget(widget);
95          }
96          if (binding != null) {
97              fd.setWidgetBinding(binding);
98          }
99          fd.setOptional(optional);
100 
101         FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
102         if (widget2 != null) {
103             fd2.setFieldWidget(widget2);
104         }
105         if (binding != null) {
106             fd2.setWidgetBinding(binding);
107         }
108         fd2.setOptional(optional);
109 
110         SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
111 
112         return fieldRow;
113     }
114     
115     private VerticalSection createReadOnlySection() {
116         VerticalSection section = new VerticalSection(); 
117         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_RELATED_COURSE_CHANGES_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLURELATEDCOURSECHANGESTYPE));        
118         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_IMPACTED_UNITS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDUNITSTYPE));        
119         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_IMPACTED_ARTICULATION_TRANSFER_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDARTICULATIONTRANSFERPROGRAMSTYPE));
120         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_STUDENT_TRANSITION_PLANS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUSTUDENTTRANSITIONPLANSTYPE));
121         return section;
122     }
123 
124 }