Search in sources :

Example 1 with ToggleButton

use of com.google.gwt.user.client.ui.ToggleButton in project gwt-test-utils by gwt-test-utils.

the class ToggleButtonTest method click.

@Test
public void click() {
    // Given
    final ToggleButton toggleButton = new ToggleButton("Up", "Down");
    // needs to be attached
    RootPanel.get().add(toggleButton);
    clicked = false;
    toggleButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            clicked = true;
        }
    });
    // Preconditions
    assertThat(toggleButton.isDown()).as("ToggleButton should not be toggled by default").isFalse();
    assertThat(toggleButton.getText()).isEqualTo("Up");
    // When
    Browser.click(toggleButton);
    // Then
    assertThat(clicked).as("ToggleButton onClick was not triggered").isTrue();
    assertThat(toggleButton.isDown()).as("ToggleButton should be toggled after being clicked once").isTrue();
    assertThat(toggleButton.getText()).isEqualTo("Down");
    // When 2
    Browser.click(toggleButton);
    assertThat(toggleButton.isDown()).as("ToggleButton should not be toggled after being clicked twice").isFalse();
    assertThat(toggleButton.getText()).isEqualTo("Up");
}
Also used : ToggleButton(com.google.gwt.user.client.ui.ToggleButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Test(org.junit.Test)

Example 2 with ToggleButton

use of com.google.gwt.user.client.ui.ToggleButton in project gwt-cs by iSergio.

the class Picking method buildPanel.

@Override
public void buildPanel() {
    viewerPanel = new ViewerPanel();
    showCartographicPositionOnMouseOver();
    _showPosOnMouseOverTBtn = new ToggleButton("Show Cartographic Position on Mouse Over");
    _showPosOnMouseOverTBtn.setValue(true);
    _showPosOnMouseOverTBtn.addValueChangeHandler(new MValueChangeHandler());
    _pickEntityTBtn = new ToggleButton("Pick Entity");
    _pickEntityTBtn.addValueChangeHandler(new MValueChangeHandler());
    _drillDownPickingTBtn = new ToggleButton("Drill-Down Picking");
    _drillDownPickingTBtn.addValueChangeHandler(new MValueChangeHandler());
    _pickPositionTBtn = new ToggleButton("Pick position");
    _pickPositionTBtn.addValueChangeHandler(new MValueChangeHandler());
    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(_showPosOnMouseOverTBtn);
    hPanel.add(_pickEntityTBtn);
    hPanel.add(_drillDownPickingTBtn);
    hPanel.add(_pickPositionTBtn);
    AbsolutePanel aPanel = new AbsolutePanel();
    aPanel.add(viewerPanel);
    aPanel.add(hPanel, 20, 20);
    contentPanel.add(new HTML("<p>Use the mouse to select and manipulate objects in the scene.</p>"));
    contentPanel.add(aPanel);
    initWidget(contentPanel);
}
Also used : ViewerPanel(org.cesiumjs.cs.widgets.ViewerPanel) ToggleButton(com.google.gwt.user.client.ui.ToggleButton) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) HTML(com.google.gwt.user.client.ui.HTML)

Aggregations

ToggleButton (com.google.gwt.user.client.ui.ToggleButton)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 HTML (com.google.gwt.user.client.ui.HTML)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 ViewerPanel (org.cesiumjs.cs.widgets.ViewerPanel)1 Test (org.junit.Test)1