Search in sources :

Example 11 with RadioButton

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);
}
Also used : RadioButton(com.google.gwt.user.client.ui.RadioButton) MockValueChangeHandler(com.googlecode.gwt.MockValueChangeHandler) Test(org.junit.Test)

Example 12 with RadioButton

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");
}
Also used : RadioButton(com.google.gwt.user.client.ui.RadioButton) Test(org.junit.Test)

Example 13 with RadioButton

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();
}
Also used : RadioButton(com.google.gwt.user.client.ui.RadioButton) MockValueChangeHandler(com.googlecode.gwt.MockValueChangeHandler) Test(org.junit.Test)

Example 14 with RadioButton

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);
            }
        }
    }
}
Also used : InputElement(com.google.gwt.dom.client.InputElement) Element(com.google.gwt.dom.client.Element) Widget(com.google.gwt.user.client.ui.Widget) RadioButton(com.google.gwt.user.client.ui.RadioButton) InputElement(com.google.gwt.dom.client.InputElement)

Example 15 with RadioButton

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);
}
Also used : Node(com.google.gwt.dom.client.Node) RadioButton(com.google.gwt.user.client.ui.RadioButton) SVGImage(org.vectomatic.dom.svg.ui.SVGImage)

Aggregations

RadioButton (com.google.gwt.user.client.ui.RadioButton)31 Test (org.junit.Test)11 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 Label (com.google.gwt.user.client.ui.Label)4 Widget (com.google.gwt.user.client.ui.Widget)4 MockValueChangeHandler (com.googlecode.gwt.MockValueChangeHandler)4 InputElement (com.google.gwt.dom.client.InputElement)3 Element (com.google.gwt.dom.client.Element)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)2 EntityModelRadioButtonEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)2 StringEntityModelTextAreaLabelEditor (org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextAreaLabelEditor)2 AgreementInfo (com.google.gerrit.client.info.AgreementInfo)1 SmallHeading (com.google.gerrit.client.ui.SmallHeading)1 HeadingElement (com.google.gwt.dom.client.HeadingElement)1 Node (com.google.gwt.dom.client.Node)1