Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
KSRadioButton |
|
| 1.1428571428571428;1.143 | ||||
KSRadioButton$1 |
|
| 1.1428571428571428;1.143 | ||||
KSRadioButton$2 |
|
| 1.1428571428571428;1.143 | ||||
KSRadioButton$3 |
|
| 1.1428571428571428;1.143 |
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.RadioButton; | |
25 | ||
26 | /** | |
27 | * KSRadioButton wraps gwt RadioButton. This class provides most of the same functionality, but sets KS css styles | |
28 | * for its default look and a variety of RadioButton events (for improved browser compatibility and customizability). | |
29 | * | |
30 | * @author Kuali Student Team | |
31 | * | |
32 | */ | |
33 | public class KSRadioButton extends RadioButton{ | |
34 | ||
35 | /** | |
36 | * Creates a new radio button associated with a particular group name, and initialized with the given label (optionally treated as HTML). | |
37 | * | |
38 | * @param name the name of the radio button group | |
39 | * @param label the text to appear in the label | |
40 | * @param asHTML true to treat the label as HTML, false otherwise. | |
41 | */ | |
42 | public KSRadioButton(String group, String label, boolean asHTML) { | |
43 | 0 | super(group, label, asHTML); |
44 | 0 | setupDefaultStyle(); |
45 | 0 | } |
46 | ||
47 | /** | |
48 | * Creates a new radio associated with a particular group name, and initialized with the given HTML label. | |
49 | * | |
50 | * @param name the name of the radio button group | |
51 | * @param label the text to appear in the label | |
52 | */ | |
53 | public KSRadioButton(String group, String label) { | |
54 | 0 | super(group, label); |
55 | 0 | setupDefaultStyle(); |
56 | 0 | } |
57 | ||
58 | /** | |
59 | * Creates a new radio associated with a particular group name. | |
60 | * | |
61 | * @param name the name of the radio button group | |
62 | */ | |
63 | public KSRadioButton(String group) { | |
64 | 0 | super(group); |
65 | 0 | setupDefaultStyle(); |
66 | 0 | } |
67 | ||
68 | /** | |
69 | * This method sets the default style for the radio button and radio button events. | |
70 | * | |
71 | */ | |
72 | private void setupDefaultStyle() { | |
73 | 0 | addStyleName("KS-Radio"); |
74 | ||
75 | 0 | this.addBlurHandler(new BlurHandler(){ |
76 | public void onBlur(BlurEvent event) { | |
77 | 0 | KSRadioButton.this.removeStyleName("KS-Radio-Focus"); |
78 | ||
79 | 0 | } |
80 | }); | |
81 | ||
82 | 0 | this.addFocusHandler(new FocusHandler(){ |
83 | public void onFocus(FocusEvent event) { | |
84 | 0 | KSRadioButton.this.addStyleName("KS-Radio-Focus"); |
85 | ||
86 | 0 | } |
87 | }); | |
88 | ||
89 | //hover does not function correctly on radio buttons | |
90 | /* this.addMouseOverHandler(new MouseOverHandler(){ | |
91 | public void onMouseOver(MouseOverEvent event) { | |
92 | KSRadioButton.this.addStyleName(KSStyles.KS_RADIO_HOVER_STYLE); | |
93 | ||
94 | } | |
95 | }); | |
96 | ||
97 | this.addMouseOutHandler(new MouseOutHandler(){ | |
98 | ||
99 | public void onMouseOut(MouseOutEvent event) { | |
100 | KSRadioButton.this.removeStyleName(KSStyles.KS_RADIO_HOVER_STYLE); | |
101 | ||
102 | } | |
103 | ||
104 | });*/ | |
105 | ||
106 | 0 | this.addValueChangeHandler(new ValueChangeHandler<Boolean>(){ |
107 | @Override | |
108 | ||
109 | public void onValueChange(ValueChangeEvent<Boolean> event) { | |
110 | 0 | if(KSRadioButton.this.getValue()){ |
111 | 0 | KSRadioButton.this.addStyleName("KS-Radio-Selected"); |
112 | } | |
113 | else{ | |
114 | 0 | KSRadioButton.this.removeStyleName("KS-Radio-Selected"); |
115 | 0 | KSRadioButton.this.setFocus(false); |
116 | } | |
117 | ||
118 | 0 | } |
119 | }); | |
120 | ||
121 | 0 | } |
122 | ||
123 | ||
124 | } | |
125 | ||
126 |