Search in sources :

Example 6 with ProgressBar

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()));
        }
    });
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) SneakyThrows(lombok.SneakyThrows)

Example 7 with ProgressBar

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;
}
Also used : ComponentRenderer(com.vaadin.flow.data.renderer.ComponentRenderer) UTCTimeUtils.convertToZoneTime(io.imunity.furms.utils.UTCTimeUtils.convertToZoneTime) Component(com.vaadin.flow.component.Component) PLAY(com.vaadin.flow.component.icon.VaadinIcon.PLAY) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) LoggerFactory(org.slf4j.LoggerFactory) Label(com.vaadin.flow.component.html.Label) MenuButton(io.imunity.furms.ui.components.MenuButton) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) DenseGrid(io.imunity.furms.ui.components.DenseGrid) SiteAgentConnectionService(io.imunity.furms.api.site_agent_pending_message.SiteAgentConnectionService) Map(java.util.Map) UI(com.vaadin.flow.component.UI) ANGLE_RIGHT(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_RIGHT) Paragraph(com.vaadin.flow.component.html.Paragraph) SiteAdminMenu(io.imunity.furms.ui.views.site.SiteAdminMenu) CorrelationId(io.imunity.furms.domain.site_agent.CorrelationId) MethodHandles(java.lang.invoke.MethodHandles) MissingResourceException(java.util.MissingResourceException) Set(java.util.Set) SearchLayout(io.imunity.furms.ui.components.administrators.SearchLayout) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) ANGLE_DOWN(com.vaadin.flow.component.icon.VaadinIcon.ANGLE_DOWN) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) Optional(java.util.Optional) Dialog(com.vaadin.flow.component.dialog.Dialog) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) VaadinExceptionHandler.handleExceptions(io.imunity.furms.ui.utils.VaadinExceptionHandler.handleExceptions) ResourceGetter.getCurrentResourceId(io.imunity.furms.ui.utils.ResourceGetter.getCurrentResourceId) IconButton(io.imunity.furms.ui.components.IconButton) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) HashMap(java.util.HashMap) REFRESH(com.vaadin.flow.component.icon.VaadinIcon.REFRESH) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Grid(com.vaadin.flow.component.grid.Grid) UIContext(io.imunity.furms.ui.user_context.UIContext) Logger(org.slf4j.Logger) CENTER(com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment.CENTER) ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) SiteId(io.imunity.furms.domain.sites.SiteId) TRASH(com.vaadin.flow.component.icon.VaadinIcon.TRASH) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) GridActionsButtonLayout(io.imunity.furms.ui.components.GridActionsButtonLayout) Consumer(java.util.function.Consumer) Button(com.vaadin.flow.component.button.Button) DateTimeFormatter(java.time.format.DateTimeFormatter) MenuButton(io.imunity.furms.ui.components.MenuButton) IconButton(io.imunity.furms.ui.components.IconButton) Button(com.vaadin.flow.component.button.Button) Label(com.vaadin.flow.component.html.Label) VerticalLayout(com.vaadin.flow.component.orderedlayout.VerticalLayout) ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 8 with ProgressBar

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);
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar)

Example 9 with 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);
}
Also used : ProgressBar(com.vaadin.flow.component.progressbar.ProgressBar)

Example 10 with 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));
}
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