use of com.google.gwt.user.client.ui.RadioButton in project gwt-test-utils by gwt-test-utils.
the class RadioButtonTest method clickOnDetachedRadionButton.
@Test
public void clickOnDetachedRadionButton() {
// Given
RadioButton rb0 = new RadioButton("myRadioGroup", "foo");
rb0.setValue(true);
RootPanel.get().add(rb0);
MockValueChangeHandler<Boolean> rb0MockChangeHandler = new MockValueChangeHandler<Boolean>();
rb0.addValueChangeHandler(rb0MockChangeHandler);
RadioButton rb1 = new RadioButton("myRadioGroup", "bar");
RootPanel.get().add(rb1);
MockValueChangeHandler<Boolean> rb1MockChangeHandler = new MockValueChangeHandler<Boolean>();
rb1.addValueChangeHandler(rb1MockChangeHandler);
// Preconditions
assertThat(rb0.getValue()).isTrue();
assertThat(rb0MockChangeHandler.getCallCount()).isEqualTo(0);
assertThat(rb1.getValue()).isFalse();
assertThat(rb1MockChangeHandler.getCallCount()).isEqualTo(0);
// When
RootPanel.get().remove(rb1);
Browser.click(rb1);
// Then
assertThat(rb1.getValue()).isTrue();
assertThat(rb1MockChangeHandler.getCallCount()).isEqualTo(1);
assertThat(rb0.getValue()).isTrue();
assertThat(rb0MockChangeHandler.getCallCount()).isEqualTo(0);
}
use of com.google.gwt.user.client.ui.RadioButton in project gwt-test-utils by gwt-test-utils.
the class RadioButtonTest method name.
@Test
public void name() {
// Given
RadioButton rb = new RadioButton("myRadioGroup", "foo");
// Preconditions
assertThat(rb.getName()).isEqualTo("myRadioGroup");
// When
rb.setName("name");
// Then
assertThat(rb.getName()).isEqualTo("name");
}
use of com.google.gwt.user.client.ui.RadioButton in project gwt-test-utils by gwt-test-utils.
the class RadioButtonTest method radioButton_Group.
@Test
public void radioButton_Group() {
// Given
RadioButton rb0 = new RadioButton("myRadioGroup", "foo");
RootPanel.get().add(rb0);
MockValueChangeHandler<Boolean> rb0MockChangeHandler = new MockValueChangeHandler<Boolean>();
rb0.addValueChangeHandler(rb0MockChangeHandler);
RadioButton rb1 = new RadioButton("myRadioGroup", "bar");
RootPanel.get().add(rb1);
MockValueChangeHandler<Boolean> rb1MockChangeHandler = new MockValueChangeHandler<Boolean>();
rb1.addValueChangeHandler(rb1MockChangeHandler);
RadioButton rb2 = new RadioButton("myRadioGroup", "baz");
RootPanel.get().add(rb2);
MockValueChangeHandler<Boolean> rb2MockChangeHandler = new MockValueChangeHandler<Boolean>();
rb2.addValueChangeHandler(rb2MockChangeHandler);
// When 1
Browser.click(rb1);
// Then 1
assertThat(rb0.getValue()).isEqualTo(false);
assertThat(rb0MockChangeHandler.getCallCount()).isEqualTo(0);
assertThat(rb1.getValue()).isEqualTo(true);
assertThat(rb1MockChangeHandler.getCallCount()).isEqualTo(1);
assertThat(rb1MockChangeHandler.getLast()).isTrue();
assertThat(rb2.getValue()).isEqualTo(false);
assertThat(rb2MockChangeHandler.getCallCount()).isEqualTo(0);
// When 2
Browser.click(rb2);
// Then 2
assertThat(rb0.getValue()).isEqualTo(false);
assertThat(rb0MockChangeHandler.getCallCount()).isEqualTo(0);
assertThat(rb1.getValue()).isEqualTo(false);
assertThat(rb1MockChangeHandler.getCallCount()).isEqualTo(2);
assertThat(rb1MockChangeHandler.getLast()).isFalse();
assertThat(rb2.getValue()).isEqualTo(true);
assertThat(rb2MockChangeHandler.getCallCount()).isEqualTo(1);
assertThat(rb2MockChangeHandler.getLast()).isTrue();
}
use of com.google.gwt.user.client.ui.RadioButton in project cuba by cuba-platform.
the class CubaOptionGroupWidget method updateItemsSelection.
protected void updateItemsSelection() {
for (Widget w : panel) {
if (w instanceof RadioButton) {
Element input = w.getElement().getFirstChildElement();
if (input instanceof InputElement) {
boolean checked = ((InputElement) input).isDefaultChecked();
((InputElement) input).setChecked(checked);
}
}
}
}
use of com.google.gwt.user.client.ui.RadioButton in project che by eclipse.
the class RadioButtonGroup method addButton.
/**
* Adds the new button to the group.
*
* @param label
* button's label
* @param title
* button's tooltip
* @param icon
* button's icon
* @param clickHandler
* click handler
*/
public void addButton(String label, String title, @Nullable SVGResource icon, ClickHandler clickHandler) {
final RadioButton radioButton = new RadioButton(GROUP_NAME, label);
radioButton.setTitle(title);
radioButton.setStyleName(resources.getCSS().button());
radioButton.addClickHandler(clickHandler);
final Node child = radioButton.getElement().getLastChild();
if (icon != null) {
final SVGImage svgImage = new SVGImage(icon);
child.insertFirst(svgImage.getElement());
}
mainPanel.add(radioButton);
buttons.add(radioButton);
}
Aggregations