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);
}
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));
}
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));
}
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));
}
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;
}
Aggregations