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