1
2
3
4
5
6
7
8
9
10
11
12
13
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
29
30
31
32
33 public class KSCheckBox extends CheckBox{
34
35
36
37
38
39 public KSCheckBox(){
40 super();
41 setupDefaultStyle();
42 }
43
44
45
46
47
48
49 public KSCheckBox(String label){
50 super(label);
51 setupDefaultStyle();
52 }
53
54
55
56
57
58 private void setupDefaultStyle(){
59 addStyleName("KS-Checkbox");
60
61 this.addBlurHandler(new BlurHandler(){
62 public void onBlur(BlurEvent event) {
63 KSCheckBox.this.removeStyleName("KS-Checkbox-Focus");
64
65 }
66 });
67
68 this.addFocusHandler(new FocusHandler(){
69 public void onFocus(FocusEvent event) {
70 KSCheckBox.this.addStyleName("KS-Checkbox-Focus");
71
72 }
73 });
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 this.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
93 @Override
94
95 public void onValueChange(ValueChangeEvent<Boolean> event) {
96 if(KSCheckBox.this.getValue()){
97 KSCheckBox.this.addStyleName("KS-Checkbox-Checked");
98 }
99 else{
100 KSCheckBox.this.removeStyleName("KS-Checkbox-Checked");
101 }
102
103 }
104 });
105 }
106
107 }