Coverage Report - org.kuali.student.lum.program.client.variation.edit.VariationInformationEditConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
VariationInformationEditConfiguration
0%
0/55
0%
0/2
1.462
VariationInformationEditConfiguration$DiplomaBinding
0%
0/14
0%
0/12
1.462
 
 1  
 package org.kuali.student.lum.program.client.variation.edit;
 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.SectionTitle;
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.binding.ModelWidgetBindingSupport;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
 8  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 9  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 10  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 11  
 import org.kuali.student.common.ui.client.widgets.KSTextBox;
 12  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 13  
 import org.kuali.student.common.ui.client.widgets.search.KSPicker;
 14  
 import org.kuali.student.common.ui.client.widgets.search.SearchPanel;
 15  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 16  
 import org.kuali.student.lum.program.client.ProgramConstants;
 17  
 import org.kuali.student.lum.program.client.ProgramSections;
 18  
 import org.kuali.student.lum.program.client.properties.ProgramProperties;
 19  
 
 20  
 import com.google.gwt.user.client.ui.Widget;
 21  
 
 22  
 /**
 23  
  * @author Igor
 24  
  */
 25  
 public class VariationInformationEditConfiguration extends AbstractSectionConfiguration {
 26  
 
 27  0
     public VariationInformationEditConfiguration() {
 28  0
         rootSection = new VerticalSectionView(ProgramSections.PROGRAM_DETAILS_EDIT, ProgramProperties.get().program_menu_sections_programInformation(), ProgramConstants.PROGRAM_MODEL_ID);
 29  0
     }
 30  
 
 31  
     @Override
 32  
     protected void buildLayout() {
 33  0
         HorizontalSection horizontalSection = new HorizontalSection();
 34  0
         horizontalSection.addSection(createLeftSection());
 35  0
         horizontalSection.addSection(createRightSection());
 36  0
         rootSection.addSection(horizontalSection);
 37  0
     }
 38  
 
 39  
     private VerticalSection createLeftSection() {
 40  0
         VerticalSection section = new VerticalSection();
 41  0
         section.addSection(createKeyProgramInformationSection());
 42  0
         section.addSection(createProgramTitleSection());
 43  0
         section.addSection(createDatesSection());
 44  0
         section.addSection(createOtherInformationSection());
 45  0
         return section;
 46  
     }
 47  
 
 48  
     private VerticalSection createRightSection() {
 49  0
         VerticalSection section = new VerticalSection();
 50  0
         section.addStyleName("readOnlySection");
 51  0
         section.addSection(createReadOnlySection());
 52  0
         return section;
 53  
     }
 54  
 
 55  
     private VerticalSection createKeyProgramInformationSection() {
 56  0
         VerticalSection section = new VerticalSection(SectionTitle.generateH3Title(ProgramProperties.get().programInformation_identifyingDetails()));
 57  0
         configurer.addField(section, ProgramConstants.CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_code()));
 58  0
         configurer.addField(section, ProgramConstants.PROGRAM_CLASSIFICATION, new MessageKeyInfo(ProgramProperties.get().programInformation_classification()));
 59  0
         configurer.addField(section, ProgramConstants.DEGREE_TYPE, new MessageKeyInfo(ProgramProperties.get().programInformation_degreeType()));
 60  0
         return section;
 61  
     }
 62  
 
 63  
     private VerticalSection createProgramTitleSection() {
 64  0
         VerticalSection section = new VerticalSection(SectionTitle.generateH3Title(ProgramProperties.get().programInformation_programTitle()));
 65  0
         configurer.addField(section, ProgramConstants.LONG_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleFull()));
 66  0
         configurer.addField(section, ProgramConstants.SHORT_TITLE, new MessageKeyInfo(ProgramProperties.get().programInformation_titleShort()));
 67  0
         configurer.addField(section, ProgramConstants.TRANSCRIPT, new MessageKeyInfo(ProgramProperties.get().programInformation_titleTranscript()));
 68  0
         configurer.addField(section, ProgramConstants.DIPLOMA, new MessageKeyInfo(ProgramProperties.get().programInformation_titleDiploma())).setWidgetBinding(new DiplomaBinding());
 69  0
         return section;
 70  
     }
 71  
 
 72  
     private VerticalSection createDatesSection() {
 73  0
         VerticalSection section = new VerticalSection(SectionTitle.generateH3Title(ProgramProperties.get().programInformation_dates()));
 74  0
         configurer.addField(section, ProgramConstants.START_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_startTerm()));
 75  0
         configurer.addField(section, ProgramConstants.END_INSTITUTIONAL_ADMIT_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_admitTerm()));
 76  0
         configurer.addField(section, ProgramConstants.END_PROGRAM_ENTRY_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_entryTerm()));
 77  0
         configurer.addField(section, ProgramConstants.END_PROGRAM_ENROLL_TERM, new MessageKeyInfo(ProgramProperties.get().programInformation_enrollTerm()));
 78  0
         return section;
 79  
     }
 80  
 
 81  
     private VerticalSection createOtherInformationSection() {
 82  0
         VerticalSection section = new VerticalSection(SectionTitle.generateH3Title(ProgramProperties.get().programInformation_otherInformation()));
 83  0
         configurer.addField(section, ProgramConstants.LOCATION, new MessageKeyInfo(ProgramProperties.get().programInformation_location()));
 84  0
         Widget cip2000Picker = configureSearch(ProgramConstants.CIP_2000);
 85  0
         configurer.addField(section, ProgramConstants.CIP_2000, new MessageKeyInfo(ProgramProperties.get().programInformation_cip2000()), cip2000Picker);
 86  0
         Widget cip2010Picker = configureSearch(ProgramConstants.CIP_2010);
 87  0
         configurer.addField(section, ProgramConstants.CIP_2010, new MessageKeyInfo(ProgramProperties.get().programInformation_cip2010()), cip2010Picker);
 88  0
         configurer.addField(section, ProgramConstants.HEGIS_CODE, new MessageKeyInfo(ProgramProperties.get().programInformation_hegis()));
 89  0
         return section;
 90  
     }
 91  
 
 92  
     private VerticalSection createReadOnlySection() {
 93  0
         VerticalSection section = new VerticalSection();
 94  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_INSTITUTION_ID, new MessageKeyInfo(ProgramProperties.get().programInformation_institution()));
 95  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_TYPE_NAME, new MessageKeyInfo(ProgramProperties.get().programInformation_credentialProgram()));
 96  0
         configurer.addReadOnlyField(section, ProgramConstants.CREDENTIAL_PROGRAM_LEVEL, new MessageKeyInfo(ProgramProperties.get().programInformation_level()));
 97  0
         return section;
 98  
     }
 99  
 
 100  
         private Widget configureSearch(String fieldKey) {            
 101  
                 Widget searchWidget;
 102  0
                 QueryPath path = QueryPath.concat(null, fieldKey);
 103  0
                 Metadata meta = configurer.getModelDefinition().getMetadata(path);
 104  
                 
 105  0
                 searchWidget = new KSPicker(meta.getInitialLookup(), meta.getAdditionalLookups());
 106  0
                 SearchPanel panel = ((KSPicker) searchWidget).getSearchPanel();
 107  0
         if (panel != null) {
 108  0
             panel.setMutipleSelect(false);
 109  
         }
 110  
         
 111  0
                 return searchWidget;
 112  
         }
 113  
         
 114  0
     public class DiplomaBinding extends ModelWidgetBindingSupport<KSTextBox> {
 115  
                 private boolean isEmpty(String value){
 116  0
                         return value == null || (value != null && "".equals(value));
 117  
                 }
 118  
 
 119  
                 @Override
 120  
                 public void setModelValue(KSTextBox widget, DataModel model, String path) {
 121  0
                         String         diplomaTitle =         widget.getText();
 122  0
                         if(diplomaTitle != null)
 123  0
                                 model.set(QueryPath.concat(null, "/" + ProgramConstants.DIPLOMA), diplomaTitle);
 124  0
                 }
 125  
 
 126  
                 @Override
 127  
                 public void setWidgetValue(KSTextBox widget, DataModel model, String path) {
 128  0
                         String diplomaTitle = model.get("/" + ProgramConstants.DIPLOMA);
 129  0
                         if(isEmpty(diplomaTitle)){
 130  0
                                 String programTitle = model.get("/" + ProgramConstants.LONG_TITLE);
 131  0
                                 if (!isEmpty(programTitle))
 132  0
                                         widget.setText(programTitle);
 133  0
                         }
 134  
                         else
 135  0
                                 widget.setText(diplomaTitle);
 136  0
                 }
 137  
         }
 138  
 }