Coverage Report - org.kuali.student.lum.program.client.major.view.ProposalChangeImpactViewConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
ProposalChangeImpactViewConfiguration
0%
0/50
0%
0/10
1.5
 
 1  
 package org.kuali.student.lum.program.client.major.view;
 2  
 
 3  
 import org.kuali.student.common.assembly.data.Metadata;
 4  
 import org.kuali.student.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  0
         return new ProposalChangeImpactViewConfiguration(configurer);
 34  
     }
 35  
 
 36  
     public static ProposalChangeImpactViewConfiguration createSpecial(Configurer configurer, Controller controller) { 
 37  0
         return new ProposalChangeImpactViewConfiguration(configurer, controller);
 38  
     }
 39  
 
 40  0
     private ProposalChangeImpactViewConfiguration(Configurer configurer) {
 41  0
         this.setConfigurer(configurer);
 42  0
         String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROPOSALCHANGEIMPACT);
 43  0
         rootSection = new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_CHANGE_IMPACT_VIEW, 
 44  
                 title, ProgramConstants.PROGRAM_MODEL_ID);
 45  0
     }
 46  
 
 47  0
     private ProposalChangeImpactViewConfiguration(Configurer configurer, Controller controller) {
 48  0
         this.setConfigurer(configurer);
 49  0
         String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_PROPOSALCHANGEIMPACT);
 50  0
         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  0
         this.controller = controller;
 54  0
     }
 55  
 
 56  
     @Override
 57  
     protected void buildLayout() {
 58  0
         if (controller instanceof MajorProposalController) {
 59  0
                 rootSection.addSection(createEditableSection());
 60  
         } else {
 61  0
                 rootSection.addSection(createReadOnlySection());
 62  
         }
 63  0
     }  
 64  
     
 65  
     private Section createEditableSection() {
 66  0
         SummaryTableSection section = new SummaryTableSection(controller);             
 67  0
         section.setEditable(false);
 68  0
         section.addSummaryTableFieldBlock(createSummaryTableFieldBlock());
 69  0
         return section;
 70  
     }
 71  
     
 72  
     public SummaryTableFieldBlock createSummaryTableFieldBlock() {
 73  0
         SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 74  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_RELATED_COURSE_CHANGES_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLURELATEDCOURSECHANGESTYPE)));
 75  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_IMPACTED_UNITS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDUNITSTYPE)));
 76  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_IMPACTED_ARTICULATION_TRANSFER_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDARTICULATIONTRANSFERPROGRAMSTYPE)));
 77  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_STUDENT_TRANSITION_PLANS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUSTUDENTTRANSITIONPLANSTYPE)));
 78  0
         return block;
 79  
     }
 80  
     
 81  
     protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
 82  0
         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  0
         QueryPath path = QueryPath.concat(parentPath, fieldKey);
 90  0
         Metadata meta = configurer.getModelDefinition().getMetadata(path);
 91  
 
 92  0
         FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 93  0
         if (widget != null) {
 94  0
             fd.setFieldWidget(widget);
 95  
         }
 96  0
         if (binding != null) {
 97  0
             fd.setWidgetBinding(binding);
 98  
         }
 99  0
         fd.setOptional(optional);
 100  
 
 101  0
         FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 102  0
         if (widget2 != null) {
 103  0
             fd2.setFieldWidget(widget2);
 104  
         }
 105  0
         if (binding != null) {
 106  0
             fd2.setWidgetBinding(binding);
 107  
         }
 108  0
         fd2.setOptional(optional);
 109  
 
 110  0
         SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
 111  
 
 112  0
         return fieldRow;
 113  
     }
 114  
     
 115  
     private VerticalSection createReadOnlySection() {
 116  0
         VerticalSection section = new VerticalSection(); 
 117  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_RELATED_COURSE_CHANGES_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLURELATEDCOURSECHANGESTYPE));        
 118  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_IMPACTED_UNITS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDUNITSTYPE));        
 119  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_IMPACTED_ARTICULATION_TRANSFER_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUIMPACTEDARTICULATIONTRANSFERPROGRAMSTYPE));
 120  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_STUDENT_TRANSITION_PLANS_PATH, generateMessageInfo(ProgramMsgConstants.PROPOSALINFORMATION_CLUSTUDENTTRANSITIONPLANSTYPE));
 121  0
         return section;
 122  
     }
 123  
 
 124  
 }