Coverage Report - org.kuali.student.common.ui.client.widgets.KSCheckBox
 
Classes in this File Line Coverage Branch Coverage Complexity
KSCheckBox
0%
0/12
N/A
1.167
KSCheckBox$1
0%
0/3
N/A
1.167
KSCheckBox$2
0%
0/3
N/A
1.167
KSCheckBox$3
0%
0/6
0%
0/2
1.167
 
 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.widgets;
 17  
 
 18  
 import org.kuali.student.common.ui.client.util.DebugIdUtils;
 19  
 
 20  
 import com.google.gwt.event.dom.client.BlurEvent;
 21  
 import com.google.gwt.event.dom.client.BlurHandler;
 22  
 import com.google.gwt.event.dom.client.FocusEvent;
 23  
 import com.google.gwt.event.dom.client.FocusHandler;
 24  
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 25  
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 26  
 import com.google.gwt.user.client.ui.CheckBox;
 27  
 
 28  
 
 29  
 /**
 30  
  * KSCheckBox wraps gwt Checkbox.  This class provides most of the same functionality, but sets KS css styles
 31  
  * for its default look and a variety of checkbox events (for improved browser compatibility and customizability).
 32  
  * @author Kuali Student Team
 33  
  *
 34  
  */
 35  
 public class KSCheckBox extends CheckBox{
 36  
 
 37  
     /**
 38  
      * Creates a check box with no label.
 39  
      *
 40  
      */
 41  
     public KSCheckBox(){
 42  0
         super();
 43  0
         setupDefaultStyle();
 44  0
     }
 45  
 
 46  
     /**
 47  
      * Creates a check box with the specified text label.
 48  
      *
 49  
      * @param label the check box's label
 50  
      */
 51  
     public KSCheckBox(String label){
 52  0
         super(label);
 53  0
         ensureDebugId(DebugIdUtils.createWebDriverSafeDebugId(label));
 54  0
         setupDefaultStyle();
 55  0
     }
 56  
 
 57  
     /**
 58  
      * This method sets the default style for the checkbox and checkbox events.
 59  
      *
 60  
      */
 61  
     private void setupDefaultStyle(){
 62  0
         addStyleName("KS-Checkbox");
 63  
 
 64  0
         this.addBlurHandler(new BlurHandler(){
 65  
             public void onBlur(BlurEvent event) {
 66  0
                 KSCheckBox.this.removeStyleName("KS-Checkbox-Focus");
 67  
 
 68  0
             }
 69  
         });
 70  
 
 71  0
         this.addFocusHandler(new FocusHandler(){
 72  
             public void onFocus(FocusEvent event) {
 73  0
                 KSCheckBox.this.addStyleName("KS-Checkbox-Focus");
 74  
 
 75  0
             }
 76  
         });
 77  
 
 78  
         //hover does not function fully for check boxes as is
 79  
 /*        this.addMouseOverHandler(new MouseOverHandler(){
 80  
             public void onMouseOver(MouseOverEvent event) {
 81  
                 KSCheckBox.this.addStyleName(KSStyles.KS_CHECKBOX_HOVER_STYLE);
 82  
 
 83  
             }
 84  
         });
 85  
 
 86  
         this.addMouseOutHandler(new MouseOutHandler(){
 87  
 
 88  
             public void onMouseOut(MouseOutEvent event) {
 89  
                 KSCheckBox.this.removeStyleName(KSStyles.KS_CHECKBOX_HOVER_STYLE);
 90  
 
 91  
             }
 92  
 
 93  
         });*/
 94  
 
 95  0
         this.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
 96  
             @Override
 97  
 
 98  
                 public void onValueChange(ValueChangeEvent<Boolean> event) {
 99  0
                     if(KSCheckBox.this.getValue()){
 100  0
                         KSCheckBox.this.addStyleName("KS-Checkbox-Checked");
 101  
                     }
 102  
                     else{
 103  0
                         KSCheckBox.this.removeStyleName("KS-Checkbox-Checked");
 104  0
                         KSCheckBox.this.setFocus(false);
 105  
                     }
 106  0
                 }
 107  
             });
 108  0
     }
 109  
 
 110  
 }