1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.ui;
import java.lang.reflect.Method;
import com.vaadin.data.Property;
@ClientWidget(com.vaadin.terminal.gwt.client.ui.VCheckBox.class)
public class CheckBox extends Button {
/**
* Creates a new switch button.
*/
public CheckBox() {
setSwitchMode(true);
}
/**
* Creates a new switch button with a caption and a set initial state.
*
* @param caption
* the caption of the switch button
* @param initialState
* the initial state of the switch button
*/
@SuppressWarnings("deprecation")
public CheckBox(String caption, boolean initialState) {
super(caption, initialState);
}
/**
* Creates a new switch button with a caption and a click listener.
*
* @param caption
* the caption of the switch button
* @param listener
* the click listener
*/
public CheckBox(String caption, ClickListener listener) {
super(caption, listener);
setSwitchMode(true);
}
/**
* Convenience method for creating a new switch button with a method
* listening button clicks. Using this method is discouraged because it
* cannot be checked during compilation. Use
* {@link #addListener(Class, Object, Method)} or
* {@link #addListener(com.vaadin.ui.Component.Listener)} instead. The
* method must have either no parameters, or only one parameter of
* Button.ClickEvent type.
*
* @param caption
* the Button caption.
* @param target
* the Object having the method for listening button clicks.
* @param methodName
* the name of the method in target object, that receives button
* click events.
*/
public CheckBox(String caption, Object target, String methodName) {
super(caption, target, methodName);
setSwitchMode(true);
}
/**
* Creates a new switch button that is connected to a boolean property.
*
* @param state
* the Initial state of the switch-button.
* @param dataSource
*/
@SuppressWarnings("deprecation")
public CheckBox(String caption, Property dataSource) {
super(caption, dataSource);
setSwitchMode(true);
}
/**
* Creates a new push button with a set caption.
*
* The value of the push button is always false and they are immediate by
* default.
*
* @param caption
* the Button caption.
*/
@SuppressWarnings("deprecation")
public CheckBox(String caption) {
super(caption, false);
}
@Deprecated
@Override
public void setSwitchMode(boolean switchMode)
throws UnsupportedOperationException {
if (this.switchMode && !switchMode) {
throw new UnsupportedOperationException(
"CheckBox is always in switch mode (consider using a Button)");
}
super.setSwitchMode(true);
}
@Override
public void setDisableOnClick(boolean disableOnClick) {
throw new UnsupportedOperationException(
"CheckBox does not support disable on click");
}
}
|