Search in sources :

Example 11 with ProgressBar

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

the class ProgressBarTest method setValueShouldThrowIfValueLessThanMin.

@Test
public void setValueShouldThrowIfValueLessThanMin() {
    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(9);
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) Test(org.junit.Test)

Example 12 with ProgressBar

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

the class ProgressBarTest method minMaxConstructorShouldInitializeMinAndMax.

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

Example 13 with ProgressBar

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

the class ProgressBarTest method fullConstructorShouldInitializeAllFields.

@Test
public void fullConstructorShouldInitializeAllFields() {
    double min = 1.8312;
    double max = 3.1415927;
    double value = 2.25;
    ProgressBar progressBar = new ProgressBar(min, max, value);
    assertThat("initial min is wrong", progressBar.getMin(), is(min));
    assertThat("initial max is wrong", progressBar.getMax(), is(max));
    assertThat("initial value is wrong", progressBar.getValue(), is(value));
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) Test(org.junit.Test)

Example 14 with ProgressBar

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

the class ProgressBarTest method defaultConstructorShouldInitializeAllFieldsToDefault.

@Test
public void defaultConstructorShouldInitializeAllFieldsToDefault() {
    ProgressBar progressBar = new ProgressBar();
    assertThat("initial min is wrong", progressBar.getMin(), is(0.0));
    assertThat("initial max is wrong", progressBar.getMax(), is(1.0));
    assertThat("initial value is wrong", progressBar.getValue(), is(0.0));
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) Test(org.junit.Test)

Example 15 with ProgressBar

use of com.vaadin.flow.component.progressbar.ProgressBar in project psip-automation by bssw-psip.

the class Assessment method createActivitySummaryAsProgress.

@SuppressWarnings("unused")
private Component createActivitySummaryAsProgress(Activity activity) {
    FormLayout form = new FormLayout();
    for (Category category : activity.getCategories()) {
        int score = 0;
        for (Item item : category.getItems()) {
            if (item.getScore().isPresent()) {
                score += item.getScore().get();
            }
        }
        ProgressBar bar = new ProgressBar(0, category.getItems().size() > 0 ? 100 * category.getItems().size() : 1);
        bar.getElement().getStyle().set("height", "10px");
        bar.setValue(score);
        if (category.getItems().isEmpty()) {
            bar.getElement().setEnabled(false);
        }
        FormItem formItem = form.addFormItem(bar, category.getName());
        // Set width of label otherwise it will wrap
        formItem.getElement().getStyle().set("--vaadin-form-item-label-width", "15em");
        // FormLayout defaults to 2 columns so span both
        form.setColspan(formItem, 2);
    }
    return form;
}
Also used : FormLayout(com.vaadin.flow.component.formlayout.FormLayout) ScoreItem(io.bssw.psip.ui.components.ScoreItem) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) Item(io.bssw.psip.backend.data.Item) Category(io.bssw.psip.backend.data.Category) FormItem(com.vaadin.flow.component.formlayout.FormLayout.FormItem) ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar)

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