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