Coverage Report - org.kuali.student.lum.program.client.major.view.LearningObjectivesViewConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
LearningObjectivesViewConfiguration
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.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.views.VerticalSectionView;
 9  
 import org.kuali.student.common.ui.client.mvc.Controller;
 10  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 11  
 import org.kuali.student.common.ui.client.widgets.menus.KSListPanel;
 12  
 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldBlock;
 13  
 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableFieldRow;
 14  
 import org.kuali.student.common.ui.client.widgets.table.summary.SummaryTableSection;
 15  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 16  
 import org.kuali.student.lum.common.client.lo.TreeStringBinding;
 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.edit.MajorEditController;
 22  
 import org.kuali.student.lum.program.client.major.proposal.MajorProposalController;
 23  
 
 24  
 import com.google.gwt.user.client.ui.Widget;
 25  
 
 26  
 /**
 27  
  * @author Igor
 28  
  */
 29  
 public class LearningObjectivesViewConfiguration extends AbstractSectionConfiguration {
 30  
 
 31  0
         private Controller controller = null;
 32  
 
 33  
     public static LearningObjectivesViewConfiguration create(Configurer configurer) {
 34  0
         return new LearningObjectivesViewConfiguration(configurer);
 35  
     }
 36  
 
 37  
     public static LearningObjectivesViewConfiguration createSpecial(Configurer configurer, Controller controller) {
 38  0
         return new LearningObjectivesViewConfiguration(configurer, controller);
 39  
     }
 40  
 
 41  0
     private LearningObjectivesViewConfiguration(Configurer configurer) {
 42  0
         this.setConfigurer(configurer);
 43  0
         String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_LEARNINGOBJECTIVES);
 44  0
         rootSection = new VerticalSectionView(ProgramSections.LEARNING_OBJECTIVES_VIEW, title, ProgramConstants.PROGRAM_MODEL_ID);
 45  0
     }
 46  
 
 47  0
     private LearningObjectivesViewConfiguration(Configurer configurer, Controller controller) {
 48  0
         this.setConfigurer(configurer);
 49  0
         String title = getLabel(ProgramMsgConstants.PROGRAM_MENU_SECTIONS_LEARNINGOBJECTIVES);
 50  0
         rootSection = new VerticalSectionView(ProgramSections.LEARNING_OBJECTIVES_VIEW, title, ProgramConstants.PROGRAM_MODEL_ID, new MajorEditableHeader(title, ProgramSections.LEARNING_OBJECTIVES_EDIT));
 51  0
                this.controller = controller;        
 52  0
     }
 53  
 
 54  
     protected void buildLayout() {
 55  0
             if (controller instanceof MajorProposalController || controller instanceof MajorEditController) 
 56  0
                        rootSection.addSection(createLearningObjectivesSectionEdit());                       
 57  
             else        
 58  0
                     configurer.addReadOnlyField(rootSection, ProgramConstants.LEARNING_OBJECTIVES, new MessageKeyInfo(""), new KSListPanel()).setWidgetBinding(new TreeStringBinding());               
 59  0
     }
 60  
     
 61  
     // Side-by-side comparison (when controller is not null)  
 62  
     private SummaryTableSection createLearningObjectivesSectionEdit() { 
 63  0
               SummaryTableSection section = new SummaryTableSection((Controller) controller);                     
 64  0
               section.setEditable(false);
 65  0
               section.addSummaryTableFieldBlock(createLearningObjectivesSectionEditBlock());
 66  
 
 67  0
         return section;
 68  
     }
 69  
 
 70  
     public SummaryTableFieldBlock createLearningObjectivesSectionEditBlock() {
 71  0
                   SummaryTableFieldBlock block = new SummaryTableFieldBlock();
 72  
 
 73  0
         block.addSummaryTableFieldRow(getFieldRow(ProgramConstants.LEARNING_OBJECTIVES, new MessageKeyInfo(""), new KSListPanel(),
 74  
                         new KSListPanel(), null, new TreeStringBinding(), false));        
 75  
 
 76  0
                   return block;
 77  
           }
 78  
 
 79  
           protected SummaryTableFieldRow getFieldRow(String fieldKey, MessageKeyInfo messageKey) {
 80  0
                   return getFieldRow(fieldKey, messageKey, null, null, null, null, false);
 81  
           }
 82  
      
 83  
           protected SummaryTableFieldRow getFieldRow(String fieldKey,
 84  
                           MessageKeyInfo messageKey, Widget widget, Widget widget2,
 85  
                           String parentPath, ModelWidgetBinding<?> binding, boolean optional) 
 86  
           {
 87  0
                   QueryPath path = QueryPath.concat(parentPath, fieldKey);
 88  0
                   Metadata meta = configurer.getModelDefinition().getMetadata(path);
 89  
 
 90  0
                   FieldDescriptorReadOnly fd = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 91  0
                   if (widget != null) {
 92  0
                           fd.setFieldWidget(widget);
 93  
                   }
 94  0
                   if (binding != null) {
 95  0
                           fd.setWidgetBinding(binding);
 96  
                   }
 97  0
                   fd.setOptional(optional);
 98  
 
 99  0
                   FieldDescriptorReadOnly fd2 = new FieldDescriptorReadOnly(path.toString(), messageKey, meta);
 100  0
                   if (widget2 != null) {
 101  0
                           fd2.setFieldWidget(widget2);
 102  
                   }
 103  0
                   if (binding != null) {
 104  0
                           fd2.setWidgetBinding(binding);
 105  
                   }
 106  0
                   fd2.setOptional(optional);
 107  
 
 108  0
                   SummaryTableFieldRow fieldRow = new SummaryTableFieldRow(fd, fd2);
 109  
 
 110  0
                   return fieldRow;
 111  
           } 
 112  
 }