Coverage Report - org.kuali.student.lum.program.client.major.edit.ManagingBodiesEditConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
ManagingBodiesEditConfiguration
0%
0/44
0%
0/10
3.6
ManagingBodiesEditConfiguration$1
0%
0/6
0%
0/4
3.6
ManagingBodiesEditConfiguration$2
0%
0/7
0%
0/8
3.6
ManagingBodiesEditConfiguration$3
0%
0/6
0%
0/4
3.6
 
 1  
 package org.kuali.student.lum.program.client.major.edit;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor;
 6  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.HorizontalSection;
 7  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 8  
 import org.kuali.student.common.ui.client.mvc.Callback;
 9  
 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
 10  
 import org.kuali.student.common.ui.client.widgets.KSItemLabel;
 11  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.MessageKeyInfo;
 12  
 import org.kuali.student.common.ui.client.widgets.list.KSSelectedList;
 13  
 import org.kuali.student.common.ui.client.widgets.search.SelectedResults;
 14  
 import org.kuali.student.lum.common.client.configuration.AbstractSectionConfiguration;
 15  
 import org.kuali.student.lum.program.client.ProgramConstants;
 16  
 import org.kuali.student.lum.program.client.ProgramSections;
 17  
 import org.kuali.student.lum.program.client.properties.ProgramProperties;
 18  
 
 19  
 import com.google.gwt.event.dom.client.ClickEvent;
 20  
 import com.google.gwt.event.dom.client.ClickHandler;
 21  
 
 22  
 /**
 23  
  * @author Igor
 24  
  */
 25  
 public class ManagingBodiesEditConfiguration extends AbstractSectionConfiguration {
 26  
 
 27  0
     public ManagingBodiesEditConfiguration() {
 28  0
         rootSection = new VerticalSectionView(ProgramSections.MANAGE_BODIES_EDIT, ProgramProperties.get().program_menu_sections_managingBodies(), ProgramConstants.PROGRAM_MODEL_ID);
 29  0
     }
 30  
 
 31  
     @Override
 32  
     protected void buildLayout() {
 33  
 
 34  
         HorizontalSection section;
 35  
         
 36  0
         section = new HorizontalSection();
 37  0
         FieldDescriptor cou = configurer.addField(section, ProgramConstants.CURRICULUM_OVERSIGHT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_curriculumOversightUnit()));
 38  0
         FieldDescriptor cod = configurer.addField(section, ProgramConstants.CURRICULUM_OVERSIGHT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_curriculumOversightDivision()));
 39  0
         rootSection.addSection(section);
 40  
         
 41  0
         section = new HorizontalSection();
 42  0
         FieldDescriptor sou = configurer.addField(section, ProgramConstants.STUDENT_OVERSIGHT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_studentOversightUnit()));
 43  0
         FieldDescriptor sod = configurer.addField(section, ProgramConstants.STUDENT_OVERSIGHT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_studentOversightDivision()));
 44  0
         rootSection.addSection(section);
 45  
         
 46  0
         section = new HorizontalSection();
 47  0
         FieldDescriptor du = configurer.addField(section, ProgramConstants.DEPLOYMENT_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_deploymentUnit()));
 48  0
         FieldDescriptor dd = configurer.addField(section, ProgramConstants.DEPLOYMENT_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_deploymentDivision()));
 49  0
         rootSection.addSection(section);
 50  
         
 51  0
         section = new HorizontalSection();
 52  0
         FieldDescriptor fru = configurer.addField(section, ProgramConstants.FINANCIAL_RESOURCES_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialResourcesUnit()));
 53  0
         FieldDescriptor frd = configurer.addField(section, ProgramConstants.FINANCIAL_RESOURCES_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialResourcesDivision()));
 54  0
         rootSection.addSection(section);
 55  
         
 56  0
         section = new HorizontalSection();
 57  0
         FieldDescriptor fcu = configurer.addField(section, ProgramConstants.FINANCIAL_CONTROL_UNIT, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialControlUnit()));
 58  0
         FieldDescriptor fcd = configurer.addField(section, ProgramConstants.FINANCIAL_CONTROL_DIVISION, new MessageKeyInfo(ProgramProperties.get().managingBodies_financialControlDivision()));
 59  0
         rootSection.addSection(section);
 60  
 
 61  0
         final KSCheckBox unitCheckBox = new KSCheckBox("I want the \"Add to List\" button to populate all units below");//Make a message
 62  0
         final KSCheckBox divisionCheckBox = new KSCheckBox("I want the \"Add to List\" button to populate all divisions below");//Make a message
 63  0
         unitCheckBox.setValue(true);
 64  0
         divisionCheckBox.setValue(true);
 65  0
         final KSSelectedList[] unitSelects = new KSSelectedList[]{(KSSelectedList) sou.getFieldWidget(),
 66  
                         (KSSelectedList) du.getFieldWidget(),(KSSelectedList) fru.getFieldWidget(),(KSSelectedList) fcu.getFieldWidget()};
 67  0
         final KSSelectedList[] divisionSelects = new KSSelectedList[]{(KSSelectedList) sod.getFieldWidget(),
 68  
                         (KSSelectedList) dd.getFieldWidget(),(KSSelectedList) frd.getFieldWidget(),(KSSelectedList) fcd.getFieldWidget()};
 69  
 
 70  0
         rootSection.addStyleName("KS-Dropdown-Short");
 71  
         
 72  
         //get a handle to the add to list button, chain in adding to all fds 
 73  0
         if(cou.getFieldWidget() instanceof KSSelectedList){
 74  0
                 final KSSelectedList couWidget = (KSSelectedList)cou.getFieldWidget();
 75  
                 
 76  0
                 couWidget.getMainPanel().insert(unitCheckBox, 1);
 77  
                 
 78  
                 //While testing the permission this broke... I am not sure why it broke but this element
 79  
                 // returns a null when doing the getAddItemButton, this might be because with CheckPermissions
 80  
                 // set to true certain Model data is not passed thru to the clients .... need Daniel and Will's
 81  
                 // help to investigate and make certain that that is not the case
 82  
                 
 83  0
                 if (couWidget.getAddItemButton() != null){
 84  0
                 couWidget.getAddItemButton().addClickHandler(new ClickHandler(){
 85  
                                 public void onClick(ClickEvent event) {
 86  0
                                         if(unitCheckBox.getValue()){
 87  0
                                                 KSItemLabel lastAdded = couWidget.getSelectedItems().get(couWidget.getSelectedItems().size()-1);
 88  0
                             for(KSSelectedList select:unitSelects){
 89  0
                                 select.addItem(lastAdded.getKey(), lastAdded.getDisplayText());
 90  
                         }
 91  
                         }
 92  0
                                 }
 93  
                 });
 94  
                 }
 95  
                 //Also add a hook into the advanced search
 96  0
                 if (couWidget.getPicker() != null){
 97  0
                 final Callback<List<SelectedResults>> originalAdvancedSearchCallback = couWidget.getPicker().getAdvancedSearchCallback();
 98  
                 
 99  0
                 couWidget.getPicker().setAdvancedSearchCallback(new Callback<List<SelectedResults>>() {
 100  
                 public void exec(List<SelectedResults> results) {
 101  
                         //Chain the original call and add the new item(s) to the rest of the selects
 102  0
                         originalAdvancedSearchCallback.exec(results);
 103  0
                     if (unitCheckBox.getValue() && results.size() > 0) {
 104  0
                                                 for (SelectedResults res : results) {
 105  0
                             for(KSSelectedList select:unitSelects){
 106  0
                                     select.addItem(res.getReturnKey(), res.getDisplayKey());
 107  
                             }
 108  
                             }
 109  
                     }
 110  0
                 }
 111  
             });
 112  
                 
 113  
         }
 114  
         }
 115  0
         if(cod.getFieldWidget() instanceof KSSelectedList){
 116  0
                 final KSSelectedList codWidget = (KSSelectedList)cod.getFieldWidget();
 117  0
                 codWidget.getMainPanel().insert(divisionCheckBox, 1);
 118  0
                 if (codWidget.getAddItemButton() != null){
 119  0
                 codWidget.getAddItemButton().addClickHandler(new ClickHandler(){
 120  
                                 public void onClick(ClickEvent event) {
 121  0
                                         if(divisionCheckBox.getValue()){
 122  0
                                                 KSItemLabel lastAdded = codWidget.getSelectedItems().get(codWidget.getSelectedItems().size()-1);
 123  0
                             for(KSSelectedList select:divisionSelects){
 124  0
                                 select.addItem(lastAdded.getKey(), lastAdded.getDisplayText());
 125  
                         }
 126  
                         }
 127  0
                                 }
 128  
                 });
 129  
                 }
 130  
         }
 131  
         
 132  
 
 133  0
     }
 134  
 
 135  
 }