Coverage Report - org.kuali.student.lum.program.client.major.view.SupportingDocsViewConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
SupportingDocsViewConfiguration
0%
0/42
0%
0/12
1.667
 
 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.VerticalSection;
 8  
 import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 10  
 import org.kuali.student.common.ui.client.mvc.Controller;
 11  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 12  
 import org.kuali.student.common.ui.client.widgets.menus.KSListPanel;
 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.core.document.ui.client.widgets.documenttool.DocumentList;
 17  
 import org.kuali.student.core.document.ui.client.widgets.documenttool.DocumentListBinding;
 18  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 19  
 import org.kuali.student.lum.common.client.lo.TreeStringBinding;
 20  
 import org.kuali.student.lum.common.client.lu.LUUIConstants;
 21  
 import org.kuali.student.lum.program.client.ProgramConstants;
 22  
 import org.kuali.student.lum.program.client.ProgramSections;
 23  
 import org.kuali.student.lum.program.client.major.MajorEditableHeader;
 24  
 import org.kuali.student.lum.program.client.major.edit.MajorEditController;
 25  
 import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
 26  
 import org.kuali.student.lum.program.client.properties.ProgramProperties;
 27  
 import org.kuali.student.lum.program.client.widgets.EditableHeader;
 28  
 
 29  
 import com.google.gwt.user.client.ui.Widget;
 30  
 
 31  
 /**
 32  
  * @author Igor
 33  
  */
 34  
 public class SupportingDocsViewConfiguration extends AbstractSectionConfiguration {
 35  
 
 36  0
         private Controller controller = null;
 37  
 
 38  
     public static SupportingDocsViewConfiguration create(){
 39  0
         return new SupportingDocsViewConfiguration(new VerticalSectionView(ProgramSections.SUPPORTING_DOCUMENTS_VIEW, ProgramProperties.get().program_menu_sections_supportingDocuments(), ProgramConstants.PROGRAM_MODEL_ID));
 40  
     }
 41  
 
 42  
     public static SupportingDocsViewConfiguration createSpecial(Controller controller) {
 43  0
         String title = ProgramProperties.get().program_menu_sections_supportingDocuments();
 44  0
         return new SupportingDocsViewConfiguration(new VerticalSectionView(ProgramSections.SUPPORTING_DOCUMENTS_VIEW, title, ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(title,ProgramSections.SUPPORTING_DOCUMENTS_EDIT)), controller);
 45  
     }
 46  
 
 47  0
     private SupportingDocsViewConfiguration(SectionView sectionView) {
 48  0
         rootSection = sectionView;
 49  0
     }
 50  
 
 51  0
     private SupportingDocsViewConfiguration(SectionView sectionView, Controller controller) {
 52  0
         rootSection = sectionView;
 53  0
         this.controller = controller;
 54  0
     }
 55  
 
 56  
     @Override
 57  
     protected void buildLayout() {
 58  0
             if (controller instanceof MajorProposalController || controller instanceof MajorEditController) 
 59  
               {
 60  0
                     VerticalSection section = new VerticalSection();
 61  0
                        section.addSection(createSupportingDocsSectionEdit());
 62  0
                        rootSection.addSection(section);                       
 63  0
               }
 64  
               else
 65  0
                       configurer.addReadOnlyField(rootSection, ProgramConstants.ID, new MessageKeyInfo(""), new DocumentList(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE, false, false)).setWidgetBinding(new DocumentListBinding("id"));
 66  0
     }
 67  
 
 68  
     // Side-by-side comparison (when controller is not null)  
 69  
     private SummaryTableSection createSupportingDocsSectionEdit() { 
 70  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 71  0
               section.setEditable(false);
 72  0
               section.addSummaryTableFieldBlock(createSupportingDocsSectionEditBlock());
 73  
 
 74  0
         return section;
 75  
     }
 76  
 
 77  
     @SuppressWarnings("unchecked")
 78  
           public SummaryTableFieldBlock createSupportingDocsSectionEditBlock() {
 79  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 80  
 
 81  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.ID, new MessageKeyInfo(""), new DocumentList(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE, false, false),
 82  
                         new DocumentList(LUUIConstants.REF_DOC_RELATION_PROPOSAL_TYPE, false, false), null, new DocumentListBinding("id"), false));        
 83  
 
 84  0
                   return block;
 85  
           }
 86  
 
 87  
           protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
 88  0
                   return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
 89  
           }
 90  
      
 91  
           protected SummaryTableFieldRow getFieldRow(String fieldKey,
 92  
                           MessageKeyInfo messageKey, Widget widget, Widget widget2,
 93  
                           String parentPath, ModelWidgetBinding<?> binding, boolean optional) 
 94  
           {
 95  0
                   QueryPath path = QueryPath.concat(parentPath, fieldKey);
 96  0
                   Metadata meta = configurer.getModelDefinition().getMetadata(path);
 97  
 
 98  0
                   FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 99  0
                   if (widget != null) {
 100  0
                           fd.setFieldWidget(widget);
 101  
                   }
 102  0
                   if (binding != null) {
 103  0
                           fd.setWidgetBinding(binding);
 104  
                   }
 105  0
                   fd.setOptional(optional);
 106  
 
 107  0
                   FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 108  0
                   if (widget2 != null) {
 109  0
                           fd2.setFieldWidget(widget2);
 110  
                   }
 111  0
                   if (binding != null) {
 112  0
                           fd2.setWidgetBinding(binding);
 113  
                   }
 114  0
                   fd2.setOptional(optional);
 115  
 
 116  0
                   SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
 117  
 
 118  0
                   return fieldRow;
 119  
           } 
 120  
 }