Coverage Report - org.kuali.student.common.ui.client.configurable.mvc.ValidationEventBindingImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidationEventBindingImpl
0%
0/11
0%
0/12
2.75
ValidationEventBindingImpl$1
0%
0/5
0%
0/2
2.75
ValidationEventBindingImpl$2
0%
0/4
N/A
2.75
ValidationEventBindingImpl$3
0%
0/4
N/A
2.75
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.common.ui.client.configurable.mvc;
 17  
 
 18  
 import org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityGroup;
 19  
 import org.kuali.student.common.ui.client.mvc.Callback;
 20  
 import org.kuali.student.common.ui.client.mvc.HasFocusLostCallbacks;
 21  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 22  
 import org.kuali.student.common.ui.client.widgets.list.HasSelectionChangeHandlers;
 23  
 import org.kuali.student.common.ui.client.widgets.list.SelectionChangeEvent;
 24  
 import org.kuali.student.common.ui.client.widgets.list.SelectionChangeHandler;
 25  
 
 26  
 import com.google.gwt.core.client.GWT;
 27  
 import com.google.gwt.event.dom.client.BlurEvent;
 28  
 import com.google.gwt.event.dom.client.BlurHandler;
 29  
 import com.google.gwt.event.dom.client.HasBlurHandlers;
 30  
 import com.google.gwt.user.client.ui.Widget;
 31  
 
 32  0
 public class ValidationEventBindingImpl  implements ValidationEventBinding {
 33  
     
 34  
     public void bind(final FieldDescriptor fd) {
 35  0
             Widget w = fd.getFieldWidget();
 36  
         
 37  0
         if (w instanceof HasSelectionChangeHandlers){
 38  0
                 ((HasSelectionChangeHandlers) w).addSelectionChangeHandler(new SelectionChangeHandler(){
 39  
                                 @Override
 40  
                                 public void onSelectionChange(SelectionChangeEvent event) {
 41  0
                                         if(event.isUserInitiated()){
 42  0
                                                 fd.setHasHadFocus(true);
 43  0
                                 fd.getValidationRequestCallback().exec(true);
 44  
                                         }
 45  0
                                 }
 46  
                         });
 47  
         }
 48  0
         else if (w instanceof HasBlurHandlers) {
 49  0
             ((HasBlurHandlers)w).addBlurHandler(new BlurHandler() {
 50  
                 public void onBlur(BlurEvent event) {
 51  0
                         fd.setHasHadFocus(true);
 52  0
                         fd.getValidationRequestCallback().exec(true);
 53  0
                 }
 54  
             });
 55  
         }
 56  0
         else if(w instanceof HasFocusLostCallbacks){
 57  0
                 ((HasFocusLostCallbacks) w).addFocusLostCallback(new Callback<Boolean>(){
 58  
                                 @Override
 59  
                                 public void exec(Boolean result) {
 60  0
                                         fd.setHasHadFocus(true);
 61  0
                         fd.getValidationRequestCallback().exec(true);
 62  0
                                 }
 63  
                         });
 64  
         }
 65  0
         else if(w instanceof KSLabel 
 66  
                         || w instanceof org.kuali.student.common.ui.client.configurable.mvc.multiplicity.MultiplicityComposite
 67  
                         || w instanceof MultiplicityGroup){
 68  
                 //Do nothing these are valid but do not fire validation events (maybe?)
 69  
         }
 70  
         else {
 71  0
                 GWT.log("The field with key: " + fd.getFieldKey() +
 72  
                                 " does not use a widget which implements an interface that can perform on the fly validation", null);
 73  
         }
 74  
 
 75  0
     }
 76  
 }