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.RadioButton;
27
28
29
30
31
32
33
34
35 public class KSRadioButton extends RadioButton{
36
37
38
39
40
41
42
43
44 public KSRadioButton(String group, String label, boolean asHTML) {
45 super(group, label, asHTML);
46 ensureDebugId(DebugIdUtils.createWebDriverSafeDebugId(group + "-" + label));
47 setupDefaultStyle();
48 }
49
50
51
52
53
54
55
56 public KSRadioButton(String group, String label) {
57 super(group, label);
58 ensureDebugId(DebugIdUtils.createWebDriverSafeDebugId(group + "-" + label));
59 setupDefaultStyle();
60 }
61
62
63
64
65
66
67 public KSRadioButton(String group) {
68 super(group);
69 setupDefaultStyle();
70 }
71
72
73
74
75
76 private void setupDefaultStyle() {
77 addStyleName("KS-Radio");
78
79 this.addBlurHandler(new BlurHandler(){
80 public void onBlur(BlurEvent event) {
81 KSRadioButton.this.removeStyleName("KS-Radio-Focus");
82
83 }
84 });
85
86 this.addFocusHandler(new FocusHandler(){
87 public void onFocus(FocusEvent event) {
88 KSRadioButton.this.addStyleName("KS-Radio-Focus");
89
90 }
91 });
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 this.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
111 @Override
112
113 public void onValueChange(ValueChangeEvent<Boolean> event) {
114 if(KSRadioButton.this.getValue()){
115 KSRadioButton.this.addStyleName("KS-Radio-Selected");
116 }
117 else{
118 KSRadioButton.this.removeStyleName("KS-Radio-Selected");
119 KSRadioButton.this.setFocus(false);
120 }
121
122 }
123 });
124
125 }
126
127
128 }
129
130