use of com.vaadin.flow.component.progressbar.ProgressBar in project DoodleVerse by davidemarcoli.
the class BuildHouseView method startLoadingBar.
/**
* Start a Loading-Bar when saving
* @return the Loading-Bar Thread
*/
@SneakyThrows
private Thread startLoadingBar() {
return new Thread(() -> {
ProgressBar loadingBar = new ProgressBar();
loadingBar.setMin(0);
loadingBar.setValue(0);
loadingBar.setMax(MathUtils.getInstance().randomMinMax(2000, 5000));
while (loadingBar.getMax() > loadingBar.getValue()) {
int nextValue = random.nextInt((int) (loadingBar.getMax() / 5));
try {
Thread.sleep(nextValue);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
loadingBar.setValue(Math.min(loadingBar.getValue() + nextValue, loadingBar.getMax()));
}
});
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project furms by unity-idm.
the class PendingRequestsView method createSiteConnectionLayout.
private VerticalLayout createSiteConnectionLayout(UI ui, SiteId siteId) {
Button button = new Button(getTranslation("view.site-admin.pending-requests.page.agent.connection"));
Label resultLabel = new Label();
ProgressBar progressBar = new ProgressBar();
progressBar.setIndeterminate(true);
progressBar.setVisible(false);
progressBar.setWidth("10em");
button.addClickListener(event -> handleExceptions(() -> siteAgentConnectionService.getSiteAgentStatus(siteId)).ifPresent(siteAgentStatus -> {
resultLabel.setText("");
progressBar.setVisible(true);
siteAgentStatus.jobFuture.thenAcceptAsync(status -> ui.access(() -> {
resultLabel.setText(getTranslation("view.site-admin.pending-requests.page.agent." + status.status.name()));
progressBar.setVisible(false);
}));
}));
VerticalLayout verticalLayout = new VerticalLayout(button, new HorizontalLayout(new Label(getTranslation("view.site-admin.pending-requests.page.agent.status")), progressBar, resultLabel));
verticalLayout.setPadding(false);
return verticalLayout;
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarView method createIndeterminateProgressBar.
private void createIndeterminateProgressBar() {
ProgressBar progressBar = new ProgressBar();
progressBar.setIndeterminate(true);
progressBar.setId("indeterminate-progress-bar");
addCard("Indeterminate progress bar", progressBar);
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarView method createBasicProgressBar.
private void createBasicProgressBar() {
ProgressBar progressBar = new ProgressBar();
progressBar.setValue(0.345);
progressBar.setId("default-progress-bar");
addCard("Progress bar", progressBar);
}
use of com.vaadin.flow.component.progressbar.ProgressBar in project flow-components by vaadin.
the class ProgressBarTest method setValueShouldUpdateValueToMax.
@Test
public void setValueShouldUpdateValueToMax() {
double min = 1;
double max = 99;
double value = 66;
ProgressBar progressBar = new ProgressBar(min, max, value);
assertThat("initial value is wrong", progressBar.getValue(), is(value));
progressBar.setValue(max);
assertThat("min is wrong", progressBar.getMin(), is(min));
assertThat("max is wrong", progressBar.getMax(), is(max));
assertThat("updated value is wrong", progressBar.getValue(), is(max));
}
Aggregations