Search in sources :

Example 51 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project furms by unity-idm.

the class InvitationsView method createMainContextMenu.

private Component createMainContextMenu(InviteeService inviteeService, Map<InvitationId, Checkbox> checkboxes) {
    GridActionMenu contextMenu = new GridActionMenu();
    contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.confirm"), CHECK_CIRCLE), event -> {
        try {
            checkboxes.entrySet().stream().filter(x -> x.getValue().getValue()).forEach(x -> inviteeService.acceptBy(x.getKey()));
        } catch (InvitationNotExistingException e) {
            showErrorNotification(getTranslation("invitation.already.removed"));
        } catch (Exception e) {
            LOG.warn("Could not accept Invitations. ", e);
            showErrorNotification(getTranslation("base.error.message"));
        }
        loadGrid();
    });
    contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.reject"), CLOSE_CIRCLE), event -> {
        if (checkboxes.entrySet().stream().anyMatch(x -> x.getValue().getValue()))
            createMainConfirmDialog(checkboxes).open();
    });
    return contextMenu.getTarget();
}
Also used : UTCTimeUtils.convertToZoneTime(io.imunity.furms.utils.UTCTimeUtils.convertToZoneTime) Component(com.vaadin.flow.component.Component) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) LoggerFactory(org.slf4j.LoggerFactory) Label(com.vaadin.flow.component.html.Label) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) HashMap(java.util.HashMap) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) DenseGrid(io.imunity.furms.ui.components.DenseGrid) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Map(java.util.Map) UserSettingsMenu(io.imunity.furms.ui.views.user_settings.UserSettingsMenu) Grid(com.vaadin.flow.component.grid.Grid) UIContext(io.imunity.furms.ui.user_context.UIContext) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) Set(java.util.Set) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) DateTimeFormatter(java.time.format.DateTimeFormatter) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Optional(java.util.Optional) CLOSE_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE) CHECK_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE) Dialog(com.vaadin.flow.component.dialog.Dialog) InviteeService(io.imunity.furms.api.invitations.InviteeService) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) MenuButton(io.imunity.furms.ui.components.MenuButton) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException)

Example 52 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project furms by unity-idm.

the class InvitationsView method createMainConfirmDialog.

private Dialog createMainConfirmDialog(Map<InvitationId, Checkbox> checkboxes) {
    FurmsDialog furmsDialog = new FurmsDialog(getTranslation("view.user-settings.invitations.page.removal.confirm.bulk"));
    furmsDialog.addConfirmButtonClickListener(event -> {
        try {
            checkboxes.entrySet().stream().filter(x -> x.getValue().getValue()).forEach(x -> inviteeService.removeBy(x.getKey()));
        } catch (Exception e) {
            LOG.warn("Could not reject Invitations. ", e);
            showErrorNotification(getTranslation("base.error.message"));
        }
        loadGrid();
    });
    return furmsDialog;
}
Also used : UTCTimeUtils.convertToZoneTime(io.imunity.furms.utils.UTCTimeUtils.convertToZoneTime) Component(com.vaadin.flow.component.Component) NotificationUtils.showErrorNotification(io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout) LoggerFactory(org.slf4j.LoggerFactory) Label(com.vaadin.flow.component.html.Label) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog) MenuButton(io.imunity.furms.ui.components.MenuButton) HashMap(java.util.HashMap) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException) PageTitle(io.imunity.furms.ui.components.PageTitle) Route(com.vaadin.flow.router.Route) DenseGrid(io.imunity.furms.ui.components.DenseGrid) FurmsViewComponent(io.imunity.furms.ui.components.FurmsViewComponent) Map(java.util.Map) UserSettingsMenu(io.imunity.furms.ui.views.user_settings.UserSettingsMenu) Grid(com.vaadin.flow.component.grid.Grid) UIContext(io.imunity.furms.ui.user_context.UIContext) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) Set(java.util.Set) GridActionMenu(io.imunity.furms.ui.components.GridActionMenu) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) DateTimeFormatter(java.time.format.DateTimeFormatter) ColumnTextAlign(com.vaadin.flow.component.grid.ColumnTextAlign) InvitationId(io.imunity.furms.domain.invitations.InvitationId) Optional(java.util.Optional) CLOSE_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CLOSE_CIRCLE) CHECK_CIRCLE(com.vaadin.flow.component.icon.VaadinIcon.CHECK_CIRCLE) Dialog(com.vaadin.flow.component.dialog.Dialog) InviteeService(io.imunity.furms.api.invitations.InviteeService) ViewHeaderLayout(io.imunity.furms.ui.components.ViewHeaderLayout) InvitationNotExistingException(io.imunity.furms.api.validation.exceptions.InvitationNotExistingException) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog)

Example 53 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project furms by unity-idm.

the class PendingRequestsView method createMainConfirmDialog.

private Dialog createMainConfirmDialog(Map<CorrelationId, Checkbox> checkboxes, Consumer<CorrelationId> consumer, String message) {
    FurmsDialog furmsDialog = new FurmsDialog(message);
    furmsDialog.addConfirmButtonClickListener(event -> {
        try {
            checkboxes.entrySet().stream().filter(x -> x.getValue().getValue()).forEach(x -> consumer.accept(x.getKey()));
        } catch (Exception e) {
            LOG.warn("Error: ", e);
            showErrorNotification(getTranslation("base.error.message"));
        }
        loadGrid();
    });
    return furmsDialog;
}
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) MissingResourceException(java.util.MissingResourceException) FurmsDialog(io.imunity.furms.ui.components.FurmsDialog)

Example 54 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class ServerSideEvents method createControls.

private Component createControls() {
    visibilityToggling = new Checkbox("Disable series visibility toggling");
    visibilityToggling.setId("visibilityToggler");
    visibilityToggling.addValueChangeListener(e -> chart.setVisibilityTogglingDisabled(visibilityToggling.getValue()));
    visibilityToggling.setValue(false);
    final Button firstSeriesVisible = new Button("Hide first series", e -> {
        Series firstSeries = chart.getConfiguration().getSeries().get(0);
        ((AbstractSeries) firstSeries).setVisible(!hideSeries);
        hideSeries = !hideSeries;
    });
    firstSeriesVisible.setId("hideFirstSeries");
    final RadioButtonGroup<Dimension> zoomLevels = new RadioButtonGroup<>();
    zoomLevels.setItems(Dimension.XY, Dimension.X, Dimension.Y);
    zoomLevels.setValue(Dimension.XY);
    zoomLevels.addValueChangeListener(event -> {
        chart.getConfiguration().getChart().setZoomType(zoomLevels.getValue());
        chart.drawChart();
    });
    Button resetHistory = new Button("Reset history");
    resetHistory.setId("resetHistory");
    resetHistory.addClickListener(event -> {
        historyLayout.removeAll();
    });
    Button toggleExtremes = new Button("Toggle Extremes");
    toggleExtremes.setId("toggleExtremes");
    toggleExtremes.addClickListener(e -> {
        if (setExtremes) {
            chart.getConfiguration().getyAxes().getAxis(0).setExtremes(9, 15);
        } else {
            chart.getConfiguration().resetZoom();
        }
        setExtremes = !setExtremes;
    });
    HorizontalLayout controls = new HorizontalLayout();
    controls.setId("controls");
    controls.add(visibilityToggling);
    controls.add(firstSeriesVisible);
    controls.add(zoomLevels);
    controls.add(resetHistory);
    controls.add(toggleExtremes);
    return controls;
}
Also used : PlotOptionsSeries(com.vaadin.flow.component.charts.model.PlotOptionsSeries) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Series(com.vaadin.flow.component.charts.model.Series) AbstractSeries(com.vaadin.flow.component.charts.model.AbstractSeries) Button(com.vaadin.flow.component.button.Button) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) RadioButtonGroup(com.vaadin.flow.component.radiobutton.RadioButtonGroup) Dimension(com.vaadin.flow.component.charts.model.Dimension) AbstractSeries(com.vaadin.flow.component.charts.model.AbstractSeries) HorizontalLayout(com.vaadin.flow.component.orderedlayout.HorizontalLayout)

Example 55 with Checkbox

use of com.vaadin.flow.component.checkbox.Checkbox in project flow-components by vaadin.

the class BoxPlot method initDemo.

@Override
public void initDemo() {
    final Chart chart = new Chart();
    chart.getConfiguration().setTitle("Box Plot Example");
    Legend legend = new Legend();
    legend.setEnabled(false);
    chart.getConfiguration().setLegend(legend);
    XAxis xaxis = chart.getConfiguration().getxAxis();
    xaxis.setTitle("Experiment No.");
    xaxis.setCategories("1", "2", "3", "4", "5");
    YAxis yAxis = chart.getConfiguration().getyAxis();
    yAxis.setTitle("Observations");
    PlotLine plotLine = new PlotLine();
    plotLine.setValue(932);
    plotLine.setZIndex(0);
    Label label = new Label("Theoretical mean: 932");
    label.setAlign(HorizontalAlign.CENTER);
    plotLine.setLabel(label);
    yAxis.setPlotLines(plotLine);
    final DataSeries observations = new DataSeries();
    observations.setName("Observations");
    // Add PlotBoxItems contain all fields relevant for plot box chart
    observations.add(new BoxPlotItem(760, 801, 848, 895, 965));
    // Example with no arg constructor
    BoxPlotItem plotBoxItem = new BoxPlotItem();
    plotBoxItem.setLow(733);
    plotBoxItem.setLowerQuartile(853);
    plotBoxItem.setMedian(939);
    plotBoxItem.setUpperQuartile(980);
    plotBoxItem.setHigh(1080);
    observations.add(plotBoxItem);
    observations.add(new BoxPlotItem(714, 762, 817, 870, 918));
    observations.add(new BoxPlotItem(724, 802, 806, 871, 950));
    observations.add(new BoxPlotItem(834, 836, 864, 882, 910));
    PlotOptionsBoxplot plotOptions = new PlotOptionsBoxplot();
    SeriesTooltip observationsTooltip = new SeriesTooltip();
    observationsTooltip.setHeaderFormat("<em>Experiment No {point.key}</em><br/>");
    plotOptions.setTooltip(observationsTooltip);
    observations.setPlotOptions(plotOptions);
    chart.getConfiguration().addSeries(observations);
    final DataSeries outlier = new DataSeries();
    outlier.setName("Outlier");
    outlier.add(new DataSeriesItem(0, 644));
    outlier.add(new DataSeriesItem(4, 718));
    outlier.add(new DataSeriesItem(4, 951));
    outlier.add(new DataSeriesItem(4, 969));
    PlotOptionsScatter outlierOptions = new PlotOptionsScatter();
    SeriesTooltip outlierTooltip = new SeriesTooltip();
    outlierTooltip.setPointFormat("Observation: {point.y}");
    outlierOptions.setTooltip(outlierTooltip);
    outlier.setPlotOptions(outlierOptions);
    chart.getConfiguration().addSeries(outlier);
    Checkbox useCustomStyles = new Checkbox("Use custom styling");
    useCustomStyles.addValueChangeListener(e -> {
        PlotOptionsBoxplot options = new PlotOptionsBoxplot();
        if (e.getValue()) {
            options.setClassName("custom-style");
            options.setWhiskerLength("70");
        }
        observations.setPlotOptions(options);
        chart.drawChart(true);
    });
    add(chart, useCustomStyles);
}
Also used : Legend(com.vaadin.flow.component.charts.model.Legend) PlotOptionsScatter(com.vaadin.flow.component.charts.model.PlotOptionsScatter) Label(com.vaadin.flow.component.charts.model.Label) XAxis(com.vaadin.flow.component.charts.model.XAxis) BoxPlotItem(com.vaadin.flow.component.charts.model.BoxPlotItem) Checkbox(com.vaadin.flow.component.checkbox.Checkbox) PlotOptionsBoxplot(com.vaadin.flow.component.charts.model.PlotOptionsBoxplot) PlotLine(com.vaadin.flow.component.charts.model.PlotLine) DataSeries(com.vaadin.flow.component.charts.model.DataSeries) Chart(com.vaadin.flow.component.charts.Chart) DataSeriesItem(com.vaadin.flow.component.charts.model.DataSeriesItem) YAxis(com.vaadin.flow.component.charts.model.YAxis) SeriesTooltip(com.vaadin.flow.component.charts.model.SeriesTooltip)

Aggregations

Checkbox (com.vaadin.flow.component.checkbox.Checkbox)68 HorizontalLayout (com.vaadin.flow.component.orderedlayout.HorizontalLayout)16 Div (com.vaadin.flow.component.html.Div)14 TextField (com.vaadin.flow.component.textfield.TextField)14 Route (com.vaadin.flow.router.Route)14 Button (com.vaadin.flow.component.button.Button)12 Grid (com.vaadin.flow.component.grid.Grid)12 Label (com.vaadin.flow.component.html.Label)12 Collectors (java.util.stream.Collectors)10 Component (com.vaadin.flow.component.Component)8 NativeButton (com.vaadin.flow.component.html.NativeButton)8 VerticalLayout (com.vaadin.flow.component.orderedlayout.VerticalLayout)8 Optional (java.util.Optional)8 Binder (com.vaadin.flow.data.binder.Binder)7 EmailValidator (com.vaadin.flow.data.validator.EmailValidator)7 Set (java.util.Set)7 FurmsViewComponent (io.imunity.furms.ui.components.FurmsViewComponent)6 PageTitle (io.imunity.furms.ui.components.PageTitle)6 NotificationUtils.showErrorNotification (io.imunity.furms.ui.utils.NotificationUtils.showErrorNotification)6 DateTimeFormatter (java.time.format.DateTimeFormatter)6