Coverage Report - org.kuali.student.lum.program.client.major.view.ProposalInformationViewConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
ProposalInformationViewConfiguration
0%
0/48
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.FieldDescriptorReadOnly;
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBinding;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.Section;
 8  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
 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.ProgramSections;
 19  
 import org.kuali.student.lum.program.client.major.MajorEditableHeader;
 20  
 import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
 21  
 import org.kuali.student.lum.program.client.properties.ProgramProperties;
 22  
 
 23  
 import com.google.gwt.user.client.ui.Widget;
 24  
 
 25  
 /**
 26  
  * @author Igor
 27  
  */
 28  
 public class ProposalInformationViewConfiguration extends AbstractSectionConfiguration {
 29  
 
 30  
     private Controller controller;
 31  
 
 32  
         public static ProposalInformationViewConfiguration create() {
 33  0
         return new ProposalInformationViewConfiguration(new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_VIEW,
 34  
                 ProgramProperties.get().program_menu_sections_proposalInformation(), ProgramConstants.PROGRAM_MODEL_ID));
 35  
         }
 36  
 
 37  
     public static ProposalInformationViewConfiguration createSpecial(Controller controller) {
 38  0
         return new ProposalInformationViewConfiguration(new VerticalSectionView(ProgramSections.PROGRAM_PROPOSAL_VIEW,
 39  
                 ProgramProperties.get().program_menu_sections_proposalInformation(), ProgramConstants.PROGRAM_MODEL_ID,
 40  
                 new MajorEditableHeader(ProgramProperties.get().program_menu_sections_proposalInformation(),
 41  
                         ProgramSections.PROGRAM_PROPOSAL_EDIT)), controller);
 42  
     }
 43  
     
 44  
 
 45  0
     private ProposalInformationViewConfiguration(SectionView sectionView, Controller controller) {
 46  0
         rootSection = sectionView;
 47  0
         this.controller = controller;
 48  0
     }
 49  
 
 50  0
     private ProposalInformationViewConfiguration(SectionView sectionView) {
 51  0
         rootSection = sectionView;
 52  0
     }
 53  
 
 54  
     @Override
 55  
     protected void buildLayout() {
 56  0
         Section section = null;
 57  0
         if (controller instanceof MajorProposalController) {
 58  0
             section = createEditableSection();
 59  
         } else {
 60  0
             section = createReadOnlySection();
 61  
         }
 62  0
         rootSection.addSection(section);
 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_TITLE_PATH, new MessageKeyInfo(ProgramProperties
 75  
                 .get().proposalInformation_cluProgramTitle())));
 76  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_TYPE_OF_MODIFICATON_PATH, new MessageKeyInfo(ProgramProperties.get().proposalInformation_cluModificationType())));
 77  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_ABSTRACT_PATH, new MessageKeyInfo(ProgramProperties.get().proposalInformation_cluAbstractType())));
 78  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.PROPOSAL_RATIONALE_PATH, new MessageKeyInfo(ProgramProperties.get().proposalInformation_cluProposalRationale())));
 79  0
         return block;
 80  
     }
 81  
     
 82  
     protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
 83  0
         return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
 84  
     }
 85  
      
 86  
     protected SummaryTableFieldRow getFieldRow(String fieldKey,
 87  
             MessageKeyInfo messageKey, Widget widget, Widget widget2,
 88  
             String parentPath, ModelWidgetBinding<?> binding, boolean optional) 
 89  
     {
 90  0
         QueryPath path = QueryPath.concat(parentPath, fieldKey);
 91  0
         Metadata meta = configurer.getModelDefinition().getMetadata(path);
 92  
 
 93  0
         FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 94  0
         if (widget != null) {
 95  0
             fd.setFieldWidget(widget);
 96  
         }
 97  0
         if (binding != null) {
 98  0
             fd.setWidgetBinding(binding);
 99  
         }
 100  0
         fd.setOptional(optional);
 101  
 
 102  0
         FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 103  0
         if (widget2 != null) {
 104  0
             fd2.setFieldWidget(widget2);
 105  
         }
 106  0
         if (binding != null) {
 107  0
             fd2.setWidgetBinding(binding);
 108  
         }
 109  0
         fd2.setOptional(optional);
 110  
 
 111  0
         SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
 112  
 
 113  0
         return fieldRow;
 114  
     }    
 115  
 
 116  
     private VerticalSection createReadOnlySection() {
 117  0
         VerticalSection section = new VerticalSection();
 118  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_TITLE_PATH, new MessageKeyInfo(ProgramProperties
 119  
                 .get().proposalInformation_cluProgramTitle()));
 120  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_TYPE_OF_MODIFICATON_PATH, new MessageKeyInfo(
 121  
                 ProgramProperties.get().proposalInformation_cluModificationType()));
 122  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_ABSTRACT_PATH, new MessageKeyInfo(
 123  
                 ProgramProperties.get().proposalInformation_cluAbstractType()));
 124  0
         configurer.addReadOnlyField(section, ProgramConstants.PROPOSAL_RATIONALE_PATH, new MessageKeyInfo(
 125  
                 ProgramProperties.get().proposalInformation_cluProposalRationale()));
 126  0
         return section;
 127  
     }
 128  
 
 129  
 }