Search in sources :

Example 1 with ProgressBar

use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.

the class ProgressBarView method createProgressBarWithThemeVariant.

private void createProgressBarWithThemeVariant() {
    ProgressBar progressBar = new ProgressBar();
    progressBar.setId("progress-bar-theme-variant");
    progressBar.setValue(0.345);
    progressBar.addThemeVariants(ProgressBarVariant.LUMO_ERROR);
    NativeButton removeVariantButton = new NativeButton("Remove theme variant", e -> progressBar.removeThemeVariants(ProgressBarVariant.LUMO_ERROR));
    removeVariantButton.setId("remove-theme-variant-button");
    addCard("Progress Bar Theme Variant", progressBar, removeVariantButton);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar)

Example 2 with ProgressBar

use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.

the class ProgressBarView method createProgressBarWithCustomBounds.

private void createProgressBarWithCustomBounds() {
    ProgressBar progressBar = new ProgressBar(10, 100, 20);
    NativeButton progressButton = new NativeButton("Make progress", e -> {
        double value = progressBar.getValue() + 10;
        if (value > progressBar.getMax()) {
            value = progressBar.getMin();
        }
        progressBar.setValue(value);
    });
    progressBar.setId("custom-progress-bar");
    progressButton.setId("progress-button");
    addCard("Progress bar with custom bounds", progressBar, progressButton);
}
Also used : NativeButton(com.vaadin.flow.component.html.NativeButton) ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar)

Example 3 with ProgressBar

use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.

the class ProgressBarTest method setValueShouldUpdateValueToMin.

@Test
public void setValueShouldUpdateValueToMin() {
    double min = 10;
    double max = 100;
    double value = 42;
    ProgressBar progressBar = new ProgressBar(min, max, value);
    assertThat("initial value is wrong", progressBar.getValue(), is(value));
    progressBar.setValue(min);
    assertThat("min is wrong", progressBar.getMin(), is(min));
    assertThat("max is wrong", progressBar.getMax(), is(max));
    assertThat("updated value is wrong", progressBar.getValue(), is(min));
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) Test(org.junit.Test)

Example 4 with ProgressBar

use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.

the class ProgressBarTest method setValueShouldUpdateValue.

@Test
public void setValueShouldUpdateValue() {
    double min = 10;
    double max = 100;
    double value = 25;
    ProgressBar progressBar = new ProgressBar(min, max);
    assertThat("initial value is wrong", progressBar.getValue(), is(min));
    progressBar.setValue(value);
    assertThat("min is wrong", progressBar.getMin(), is(min));
    assertThat("max is wrong", progressBar.getMax(), is(max));
    assertThat("updated value is wrong", progressBar.getValue(), is(value));
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) Test(org.junit.Test)

Example 5 with ProgressBar

use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.

the class ProgressBarTest method setValueShouldThrowIfValueGreaterThanMax.

@Test
public void setValueShouldThrowIfValueGreaterThanMax() {
    double min = 10.0;
    double max = 100.0;
    thrown.expect(IllegalArgumentException.class);
    thrown.expectMessage(String.format("value must be between min ('%s') and max ('%s')", min, max));
    ProgressBar progressBar = new ProgressBar(min, max);
    progressBar.setValue(101);
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) Test(org.junit.Test)

Aggregations

ProgressBar (com.vaadin.flow.component.progressbar.ProgressBar)15 Test (org.junit.Test)8 NativeButton (com.vaadin.flow.component.html.NativeButton)2 Component (com.vaadin.flow.component.Component)1 UI (com.vaadin.flow.component.UI)1 Button (com.vaadin.flow.component.button.Button)1 Checkbox (com.vaadin.flow.component.checkbox.Checkbox)1 Dialog (com.vaadin.flow.component.dialog.Dialog)1 FormLayout (com.vaadin.flow.component.formlayout.FormLayout)1 FormItem (com.vaadin.flow.component.formlayout.FormLayout.FormItem)1 ColumnTextAlign (com.vaadin.flow.component.grid.ColumnTextAlign)1 Grid (com.vaadin.flow.component.grid.Grid)1 Label (com.vaadin.flow.component.html.Label)1 Paragraph (com.vaadin.flow.component.html.Paragraph)1 ANGLE_DOWN (com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN)1 ANGLE_RIGHT (com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT)1 PLAY (com.vaadin.flow.component.icon.VaadinIcon.PLAY)1 REFRESH (com.vaadin.flow.component.icon.VaadinIcon.REFRESH)1 TRASH (com.vaadin.flow.component.icon.VaadinIcon.TRASH)1 CENTER (com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment.CENTER)1