Coverage Report - org.kuali.student.lum.program.client.major.edit.ManagingBodiesEditConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
ManagingBodiesEditConfiguration
0%
0/39
0%
0/4
2.5
ManagingBodiesEditConfiguration$1
0%
0/6
0%
0/4
2.5
ManagingBodiesEditConfiguration$2
0%
0/6
0%
0/4
2.5
 
 1  
 package org.kuali.student.lum.program.client.major.edit;
 2  
 
 3  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
 4  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
 5  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 6  
 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
 7  
 import org.kuali.student.common.ui.client.widgets.KSItemLabel;
 8  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 9  
 import org.kuali.student.common.ui.client.widgets.list.KSSelectedList;
 10  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 11  
 import org.kuali.student.lum.program.client.ProgramConstants;
 12  
 import org.kuali.student.lum.program.client.ProgramSections;
 13  
 import org.kuali.student.lum.program.client.properties.ProgramProperties;
 14  
 
 15  
 import com.google.gwt.event.dom.client.ClickEvent;
 16  
 import com.google.gwt.event.dom.client.ClickHandler;
 17  
 
 18  
 /**
 19  
  * @author Igor
 20  
  */
 21  
 public class ManagingBodiesEditConfiguration extends AbstractSectionConfiguration {
 22  
 
 23  0
     public ManagingBodiesEditConfiguration() {
 24  0
         rootSection = new VerticalSectionView(ProgramSections.MANAGE_BODIES_EDIT, ProgramProperties.get().program_menu_sections_managingBodies(), ProgramConstants.PROGRAM_MODEL_ID);
 25  0
     }
 26  
 
 27  
     @Override
 28  
     protected void buildLayout() {
 29  
 
 30  
         HorizontalSection section;
 31  
         
 32  0
         section = new HorizontalSection();
 33  0
         FieldDescriptor cou = configurer.addField(section, ProgramConstants.CURRICULUM_OVERSIGHT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_curriculumOversightUnit()));
 34  0
         FieldDescriptor cod = configurer.addField(section, ProgramConstants.CURRICULUM_OVERSIGHT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_curriculumOversightDivision()));
 35  0
         rootSection.addSection(section);
 36  
         
 37  0
         section = new HorizontalSection();
 38  0
         FieldDescriptor sou = configurer.addField(section, ProgramConstants.STUDENT_OVERSIGHT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_studentOversightUnit()));
 39  0
         FieldDescriptor sod = configurer.addField(section, ProgramConstants.STUDENT_OVERSIGHT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_studentOversightDivision()));
 40  0
         rootSection.addSection(section);
 41  
         
 42  0
         section = new HorizontalSection();
 43  0
         FieldDescriptor du = configurer.addField(section, ProgramConstants.DEPLOYMENT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_deploymentUnit()));
 44  0
         FieldDescriptor dd = configurer.addField(section, ProgramConstants.DEPLOYMENT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_deploymentDivision()));
 45  0
         rootSection.addSection(section);
 46  
         
 47  0
         section = new HorizontalSection();
 48  0
         FieldDescriptor fru = configurer.addField(section, ProgramConstants.FINANCIAL_RESOURCES_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialResourcesUnit()));
 49  0
         FieldDescriptor frd = configurer.addField(section, ProgramConstants.FINANCIAL_RESOURCES_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialResourcesDivision()));
 50  0
         rootSection.addSection(section);
 51  
         
 52  0
         section = new HorizontalSection();
 53  0
         FieldDescriptor fcu = configurer.addField(section, ProgramConstants.FINANCIAL_CONTROL_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialControlUnit()));
 54  0
         FieldDescriptor fcd = configurer.addField(section, ProgramConstants.FINANCIAL_CONTROL_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialControlDivision()));
 55  0
         rootSection.addSection(section);
 56  
 
 57  0
         final KSCheckBox unitCheckBox = new KSCheckBox("I want the \"Add to List\" button to populate all units below");//Make a message
 58  0
         final KSCheckBox divisionCheckBox = new KSCheckBox("I want the \"Add to List\" button to populate all divisions below");//Make a message
 59  0
         unitCheckBox.setValue(true);
 60  0
         divisionCheckBox.setValue(true);
 61  0
         final KSSelectedList[] unitSelects = new KSSelectedList[]{(KSSelectedList) sou.getFieldWidget(),
 62  
                         (KSSelectedList) du.getFieldWidget(),(KSSelectedList) fru.getFieldWidget(),(KSSelectedList) fcu.getFieldWidget()};
 63  0
         final KSSelectedList[] divisionSelects = new KSSelectedList[]{(KSSelectedList) sod.getFieldWidget(),
 64  
                         (KSSelectedList) dd.getFieldWidget(),(KSSelectedList) frd.getFieldWidget(),(KSSelectedList) fcd.getFieldWidget()};
 65  
 
 66  0
         rootSection.addStyleName("KS-Dropdown-Short");
 67  
         
 68  
         //get a handle to the add to list button, chain in adding to all fds 
 69  0
         if(cou.getFieldWidget() instanceof KSSelectedList){
 70  0
                 final KSSelectedList couWidget = (KSSelectedList)cou.getFieldWidget();
 71  0
                 couWidget.getMainPanel().insert(unitCheckBox, 1);
 72  0
                 couWidget.getAddItemButton().addClickHandler(new ClickHandler(){
 73  
                                 public void onClick(ClickEvent event) {
 74  0
                                         if(unitCheckBox.getValue()){
 75  0
                                                 KSItemLabel lastAdded = couWidget.getSelectedItems().get(couWidget.getSelectedItems().size()-1);
 76  0
                             for(KSSelectedList select:unitSelects){
 77  0
                                 select.addItem(lastAdded.getKey(), lastAdded.getDisplayText());
 78  
                         }
 79  
                         }
 80  0
                                 }
 81  
                 });
 82  
         }
 83  0
         if(cod.getFieldWidget() instanceof KSSelectedList){
 84  0
                 final KSSelectedList codWidget = (KSSelectedList)cod.getFieldWidget();
 85  0
                 codWidget.getMainPanel().insert(divisionCheckBox, 1);
 86  0
                 codWidget.getAddItemButton().addClickHandler(new ClickHandler(){
 87  
                                 public void onClick(ClickEvent event) {
 88  0
                                         if(divisionCheckBox.getValue()){
 89  0
                                                 KSItemLabel lastAdded = codWidget.getSelectedItems().get(codWidget.getSelectedItems().size()-1);
 90  0
                             for(KSSelectedList select:divisionSelects){
 91  0
                                 select.addItem(lastAdded.getKey(), lastAdded.getDisplayText());
 92  
                         }
 93  
                         }
 94  0
                                 }
 95  
                 });
 96  
         }
 97  0
     }
 98  
 
 99  
 }