use of com.vaadin.v7.ui.CheckBox in project SORMAS-Project by hzi-braunschweig.
the class BulkTaskDataForm method addFields.
@Override
protected void addFields() {
if (!initialized) {
return;
}
taskStatusCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskStatus));
getContent().addComponent(taskStatusCheckbox, STATUS_CHECKBOX);
NullableOptionGroup status = addField(TaskBulkEditData.TASK_STATUS, NullableOptionGroup.class);
status.setEnabled(false);
FieldHelper.setRequiredWhen(getFieldGroup(), taskStatusCheckbox, Arrays.asList(TaskBulkEditData.TASK_STATUS), Arrays.asList(true));
taskStatusCheckbox.addValueChangeListener(e -> {
status.setEnabled((boolean) e.getProperty().getValue());
});
priorityCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskPriority));
getContent().addComponent(priorityCheckbox, PRORITY_CHECKBOX);
NullableOptionGroup priority = addField(TaskBulkEditData.TASK_PRIORITY, NullableOptionGroup.class);
priority.setEnabled(false);
FieldHelper.setRequiredWhen(getFieldGroup(), priorityCheckbox, Arrays.asList(TaskBulkEditData.TASK_PRIORITY), Arrays.asList(true));
priorityCheckbox.addValueChangeListener(e -> {
priority.setEnabled((boolean) e.getProperty().getValue());
});
assigneeCheckbox = new CheckBox(I18nProperties.getCaption(Captions.bulkTaskAssignee));
getContent().addComponent(assigneeCheckbox, ASSIGNEE_CHECKBOX);
ComboBox assignee = addField(TaskBulkEditData.TASK_ASSIGNEE, ComboBox.class);
assignee.setEnabled(false);
FieldHelper.addSoftRequiredStyleWhen(getFieldGroup(), assigneeCheckbox, Arrays.asList(TaskBulkEditData.TASK_ASSIGNEE), Arrays.asList(true), null);
List<UserReferenceDto> users = getUsers();
Map<String, Long> userTaskCounts = FacadeProvider.getTaskFacade().getPendingTaskCountPerUser(users.stream().map(ReferenceDto::getUuid).collect(Collectors.toList()));
for (UserReferenceDto user : users) {
assignee.addItem(user);
Long userTaskCount = userTaskCounts.get(user.getUuid());
assignee.setItemCaption(user, user.getCaption() + " (" + (userTaskCount != null ? userTaskCount.toString() : "0") + ")");
}
assigneeCheckbox.addValueChangeListener(e -> {
boolean changeAssignee = (boolean) e.getProperty().getValue();
assignee.setEnabled(changeAssignee);
assignee.setRequired(changeAssignee);
});
}
use of com.vaadin.v7.ui.CheckBox in project SORMAS-Project by hzi-braunschweig.
the class DatabaseExportView method createDatabaseTablesLayout.
private HorizontalLayout createDatabaseTablesLayout() {
HorizontalLayout databaseTablesLayout = new HorizontalLayout();
databaseTablesLayout.setMargin(false);
databaseTablesLayout.setSpacing(true);
VerticalLayout sormasDataLayout = new VerticalLayout();
sormasDataLayout.setMargin(false);
sormasDataLayout.setSpacing(false);
Label sormasDataHeadline = new Label(I18nProperties.getCaption(Captions.exportSormasData));
CssStyles.style(sormasDataHeadline, CssStyles.H4);
sormasDataLayout.addComponent(sormasDataHeadline);
VerticalLayout infrastructureDataLayout = new VerticalLayout();
infrastructureDataLayout.setMargin(false);
infrastructureDataLayout.setSpacing(false);
Label infrastructureDataHeadline = new Label(I18nProperties.getCaption(Captions.exportInfrastructureData));
CssStyles.style(infrastructureDataHeadline, CssStyles.H4);
infrastructureDataLayout.addComponent(infrastructureDataHeadline);
VerticalLayout configurationDataLayout = new VerticalLayout();
configurationDataLayout.setMargin(false);
configurationDataLayout.setSpacing(false);
Label configurationDataHeadline = new Label(I18nProperties.getCaption(Captions.exportConfigurationData));
CssStyles.style(configurationDataHeadline, CssStyles.H4);
configurationDataLayout.addComponent(configurationDataHeadline);
VerticalLayout externalDataLayout = new VerticalLayout();
externalDataLayout.setMargin(false);
externalDataLayout.setSpacing(false);
Label externalDataHeadline = new Label(I18nProperties.getCaption(Captions.exportExternalData));
CssStyles.style(externalDataHeadline, CssStyles.H4);
externalDataLayout.addComponent(externalDataHeadline);
List<FeatureConfigurationDto> featureConfigurations = FacadeProvider.getFeatureConfigurationFacade().getActiveServerFeatureConfigurations();
ConfigFacade configFacade = FacadeProvider.getConfigFacade();
for (DatabaseTable databaseTable : DatabaseTable.values()) {
if (!databaseTable.isEnabled(featureConfigurations, configFacade)) {
continue;
}
CheckBox checkBox = new CheckBox(databaseTable.toString());
int indent = getIndent(databaseTable);
if (indent == 1) {
CssStyles.style(checkBox, CssStyles.INDENT_LEFT_1);
} else if (indent == 2) {
CssStyles.style(checkBox, CssStyles.INDENT_LEFT_2);
} else if (indent == 3) {
CssStyles.style(checkBox, CssStyles.INDENT_LEFT_3);
}
switch(databaseTable.getDatabaseTableType()) {
case SORMAS:
sormasDataLayout.addComponent(checkBox);
break;
case INFRASTRUCTURE:
infrastructureDataLayout.addComponent(checkBox);
break;
case CONFIGURATION:
configurationDataLayout.addComponent(checkBox);
break;
case EXTERNAL:
externalDataLayout.addComponent(checkBox);
break;
default:
throw new IllegalArgumentException(databaseTable.getDatabaseTableType().toString());
}
databaseTableToggles.put(checkBox, databaseTable);
}
databaseTablesLayout.addComponent(sormasDataLayout);
databaseTablesLayout.addComponent(infrastructureDataLayout);
databaseTablesLayout.addComponent(configurationDataLayout);
databaseTablesLayout.addComponent(externalDataLayout);
return databaseTablesLayout;
}
use of com.vaadin.v7.ui.CheckBox in project SORMAS-Project by hzi-braunschweig.
the class DownloadUtil method createDatabaseExportStreamResource.
public static StreamResource createDatabaseExportStreamResource(DatabaseExportView databaseExportView, String fileName, String mimeType) {
StreamResource streamResource = new StreamResource(() -> {
Map<CheckBox, DatabaseTable> databaseToggles = databaseExportView.getDatabaseTableToggles();
List<DatabaseTable> tablesToExport = new ArrayList<>();
for (CheckBox checkBox : databaseToggles.keySet()) {
if (checkBox.getValue()) {
tablesToExport.add(databaseToggles.get(checkBox));
}
}
return new DelayedInputStream(() -> {
try {
String zipPath = FacadeProvider.getExportFacade().generateDatabaseExportArchive(tablesToExport);
return new BufferedInputStream(Files.newInputStream(new File(zipPath).toPath()));
} catch (IOException | ExportErrorException e) {
LoggerFactory.getLogger(DownloadUtil.class).error(e.getMessage(), e);
// TODO This currently requires the user to click the "Export" button again or reload the page as the UI
// is not automatically updated; this should be changed once Vaadin push is enabled (see #516)
databaseExportView.showExportErrorNotification();
return null;
}
});
}, fileName);
streamResource.setMIMEType(mimeType);
streamResource.setCacheTime(0);
return streamResource;
}
use of com.vaadin.v7.ui.CheckBox in project charts by vaadin.
the class ServerSideEvents method createControls.
private Layout createControls() {
visibilityToggling = new CheckBox("Disable series visibility toggling");
visibilityToggling.addValueChangeListener(e -> {
chart.setSeriesVisibilityTogglingDisabled(visibilityToggling.getValue());
});
final Button firstSeriesVisible = new Button("Hide first series");
firstSeriesVisible.setId("hideFirstSeries");
firstSeriesVisible.addClickListener(new Button.ClickListener() {
boolean hideSeries = true;
@Override
public void buttonClick(Button.ClickEvent event) {
Series firstSeries = chart.getConfiguration().getSeries().get(0);
((AbstractSeries) firstSeries).setVisible(!hideSeries);
hideSeries = !hideSeries;
String caption = hideSeries ? "Hide first series" : "Show first series";
firstSeriesVisible.setCaption(caption);
}
});
Button setExtremes = new Button("Toggle extremes");
setExtremes.setId("setExtremes");
setExtremes.addClickListener(new Button.ClickListener() {
public boolean extremesSet;
@Override
public void buttonClick(Button.ClickEvent event) {
if (extremesSet) {
chart.getConfiguration().getxAxis().setExtremes(10, 90);
} else {
chart.getConfiguration().getxAxis().setExtremes(20, 80);
}
extremesSet = !extremesSet;
}
});
final OptionGroup zoomLevels = new OptionGroup("Zoom Type");
zoomLevels.addItem(ZoomType.XY);
zoomLevels.addItem(ZoomType.X);
zoomLevels.addItem(ZoomType.Y);
zoomLevels.setValue(ZoomType.XY);
zoomLevels.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(Property.ValueChangeEvent event) {
ZoomType zoom = (ZoomType) zoomLevels.getValue();
chart.getConfiguration().getChart().setZoomType(zoom);
chart.drawChart();
}
});
Button resetHistory = new Button("Reset history");
resetHistory.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
lastEvent.setValue(null);
eventDetails.setValue(null);
historyLayout.removeAllComponents();
}
});
HorizontalLayout controls = new HorizontalLayout();
controls.setId("controls");
controls.setSpacing(true);
controls.addComponent(visibilityToggling);
controls.addComponent(firstSeriesVisible);
controls.addComponent(setExtremes);
controls.addComponent(zoomLevels);
controls.addComponent(resetHistory);
return controls;
}
use of com.vaadin.v7.ui.CheckBox in project CodenameOne by codenameone.
the class InstantUI method createEntryForProperty.
private void createEntryForProperty(PropertyBase b, Container cnt, ArrayList<UiBinding.Binding> allBindings, UiBinding uib) throws RuntimeException {
if (isExcludedProperty(b)) {
return;
}
Class cls = (Class) b.getClientProperty("cn1$cmpCls");
if (cls != null) {
try {
Component cmp = (Component) cls.newInstance();
cmp.setName(b.getName());
cnt.add(b.getLabel()).add(cmp);
allBindings.add(uib.bind(b, cmp));
} catch (Exception err) {
Log.e(err);
throw new RuntimeException("Custom property instant UI failed for " + b.getName() + " " + err);
}
return;
}
String[] multiLabels = (String[]) b.getClientProperty("cn1$multiChceLbl");
if (multiLabels != null) {
// multi choice component
final Object[] multiValues = (Object[]) b.getClientProperty("cn1$multiChceVal");
if (multiLabels.length < 5) {
// toggle buttons
ButtonGroup bg = new ButtonGroup();
RadioButton[] rbs = new RadioButton[multiLabels.length];
cnt.add(b.getLabel());
Container radioBox = new Container(new GridLayout(multiLabels.length));
for (int iter = 0; iter < multiLabels.length; iter++) {
rbs[iter] = RadioButton.createToggle(multiLabels[iter], bg);
radioBox.add(rbs[iter]);
}
cnt.add(radioBox);
allBindings.add(uib.bindGroup(b, multiValues, rbs));
} else {
Picker stringPicker = new Picker();
stringPicker.setStrings(multiLabels);
Map<Object, Object> m1 = new HashMap<Object, Object>();
Map<Object, Object> m2 = new HashMap<Object, Object>();
for (int iter = 0; iter < multiLabels.length; iter++) {
m1.put(multiLabels[iter], multiValues[iter]);
m2.put(multiValues[iter], multiLabels[iter]);
}
cnt.add(b.getLabel()).add(stringPicker);
allBindings.add(uib.bind(b, stringPicker, new UiBinding.PickerAdapter<Object>(new UiBinding.MappingConverter(m1), new UiBinding.MappingConverter(m2))));
}
return;
}
Class t = b.getGenericType();
if (t != null) {
if (t == Boolean.class) {
CheckBox cb = new CheckBox();
uib.bind(b, cb);
cnt.add(b.getLabel()).add(cb);
return;
}
if (t == Date.class) {
Picker dp = new Picker();
dp.setType(Display.PICKER_TYPE_DATE);
uib.bind(b, dp);
cnt.add(b.getLabel()).add(dp);
return;
}
}
TextField tf = new TextField();
tf.setConstraint(getTextFieldConstraint(b));
uib.bind(b, tf);
cnt.add(b.getLabel()).add(tf);
}
Aggregations