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