protected void attachListener(CheckBox checkBox, final AttributePermissionVariant activeVariant) { checkBox.addValueChangeListener(e -> { if (itemChanging) { return; } if (propertyPermissionsTable.getSelected().isEmpty()) { return; } itemChanging = true; markTargetPermission(PermissionUiHelper.getCheckBoxVariant(e.getValue(), activeVariant)); if (activeVariant != AttributePermissionVariant.MODIFY) modifyCheckBox.setValue(false); if (activeVariant != AttributePermissionVariant.READ_ONLY) readOnlyCheckBox.setValue(false); if (activeVariant != AttributePermissionVariant.HIDE) hideCheckBox.setValue(false); allModifyCheck.setValue(isAllModified()); allReadOnlyCheck.setValue(isAllReadOnly()); allHideCheck.setValue(isAllHide()); // todo enforce property change instead of item attributeTargetsDs.updateItem(item); itemChanging = false; }); }
public Boolean getResponsive() { return responsive.getValue(); }
protected void createFtsSwitch() { ftsSwitch = uiComponents.create(CheckBox.class); ftsSwitch.setCaption(getMainMessage("filter.ftsSwitch")); ftsSwitch.setValue(filterMode == FilterMode.FTS_MODE); ftsSwitch.addValueChangeListener(e -> { filterMode = Boolean.TRUE.equals(e.getValue()) ? FilterMode.FTS_MODE : FilterMode.GENERIC_MODE; switchFilterMode(filterMode); }); ftsSwitch.setVisible(modeSwitchVisible); }
public void setSelectAllCheckBox(boolean value) { canSelectAllCheckboxGenerateEvents = false; boolean isEditable = selectAllCheckBox.isEditable(); try { selectAllCheckBox.setEditable(true); selectAllCheckBox.setValue(value); } finally { canSelectAllCheckboxGenerateEvents = true; selectAllCheckBox.setEditable(isEditable); } }
protected void updateCheckers(AttributePermissionVariant permissionVariant) { if (modifyCheckBox.isEditable()) { modifyCheckBox.setValue(permissionVariant == AttributePermissionVariant.MODIFY); } if (readOnlyCheckBox.isEditable()) { readOnlyCheckBox.setValue(permissionVariant == AttributePermissionVariant.READ_ONLY); } if (hideCheckBox.isEditable()) { hideCheckBox.setValue(permissionVariant == AttributePermissionVariant.HIDE); } }
private boolean isAllModified() { return permissionControls.stream().allMatch(c -> c.modifyCheckBox.getValue() || !c.modifyCheckBox.isEditable()); }
filterName.setValue(filterEntity.getName()); availableForAllCb.setValue(filterEntity.getUser() == null); defaultCb.setValue(filterEntity.getIsDefault()); applyDefaultCb.setValue(filterEntity.getApplyDefault()); globalDefaultCb.setValue(filterEntity.getGlobalDefault()); globalDefaultCb.setEnabled(false); availableForAllCb.setVisible(false); availableForAllLabel.setVisible(false); globalDefaultCb.setVisible(false); globalDefaultLabel.setVisible(false); availableForAllCb.addValueChangeListener(e -> { Boolean isFilterAvailableForAll = (Boolean) e.getValue(); globalDefaultCb.setEnabled(isFilterAvailableForAll); if (!isFilterAvailableForAll) { globalDefaultCb.setValue(null); applyDefaultCb.setVisible(manualApplyRequired); applyDefaultLabel.setVisible(manualApplyRequired); defaultCb.setVisible(false); defaultLabel.setVisible(false);
protected void addAttribute(Set<LoggedAttribute> enabledAttributes, String name, boolean editable) { CheckBox checkBox = factory.createComponent(CheckBox.class); if (enabledAttributes != null && isEntityHaveAttribute(name, enabledAttributes)) { checkBox.setValue(true); } checkBox.setId(name); checkBox.setCaption(name); checkBox.setEditable(editable); checkBox.addValueChangeListener(e -> checkAllCheckboxes()); attributesBoxScroll.add(checkBox); }
protected void updateCheckBoxes(PermissionVariant permissionVariant, CheckBox allowCheckBox, CheckBox denyCheckBox) { if (permissionVariant == PermissionVariant.ALLOWED) { allowCheckBox.setValue(true); denyCheckBox.setValue(false); } else if (permissionVariant == PermissionVariant.DISALLOWED) { denyCheckBox.setValue(true); allowCheckBox.setValue(false); } else { allowCheckBox.setValue(false); denyCheckBox.setValue(false); } }
protected void setBoolean(BooleanParameterValue value) { checkBox.setValue(value == null ? null : value.getValue()); checkBox.setVisible(true); } }
protected void initTransformations() { ReportInputParameter parameter = getItem(); predefinedTransformation.setValue(parameter.getPredefinedTransformation() != null); enableControlsByTransformationType(parameter.getPredefinedTransformation() != null); predefinedTransformation.addValueChangeListener(e -> { boolean hasPredefinedTransformation = e.getValue() != null && e.getValue(); enableControlsByTransformationType(hasPredefinedTransformation); if (hasPredefinedTransformation) { parameter.setTransformationScript(null); } else { parameter.setPredefinedTransformation(null); } }); predefinedTransformation.setEditable(security.isEntityOpPermitted(ReportInputParameter.class, EntityOp.UPDATE)); }
protected void initTimeZoneFields() { Map<String, String> options = new TreeMap<>(); for (String id : TimeZone.getAvailableIDs()) { TimeZone timeZone = TimeZone.getTimeZone(id); options.put(timeZones.getDisplayNameLong(timeZone), id); } timeZoneLookup.setOptionsMap(options); timeZoneAutoField.setCaption(messages.getMainMessage("timeZone.auto")); timeZoneAutoField.setDescription(messages.getMainMessage("timeZone.auto.descr")); timeZoneAutoField.addValueChangeListener(e -> timeZoneLookup.setEnabled(!Boolean.TRUE.equals(e.getValue()))); UserTimeZone userTimeZone = userManagementService.loadOwnTimeZone(); timeZoneLookup.setValue(userTimeZone.name); timeZoneAutoField.setValue(userTimeZone.auto); }
protected void attachCheckBoxListener(final CheckBox checkBox, final String metaProperty, final EntityOp operation, final PermissionVariant activeVariant) { checkBox.addValueChangeListener(e -> { if (itemChanging) return; checkerControl.getDenyChecker().setValue(false); } else if (activeVariant == PermissionVariant.DISALLOWED) { checkerControl.getAllowChecker().setValue(false); isAllowedAll &= Boolean.TRUE.equals(control.getAllowChecker().getValue()); isDenyAll &= Boolean.TRUE.equals(control.getDenyChecker().getValue()); allAllowCheck.setValue(isAllowedAll); allDenyCheck.setValue(isDenyAll);
protected CheckBox createUnaryField(final ValueProperty valueProperty) { CheckBox field = componentsFactory.createComponent(CheckBox.class); field.addValueChangeListener(e -> { Object newValue = BooleanUtils.isTrue((Boolean) e.getValue()) ? true : null; _setValue(newValue, valueProperty); }); field.setValue((Boolean) _getValue(valueProperty)); field.setAlignment(Component.Alignment.MIDDLE_LEFT); return field; }
@Override public void init(Map<String, Object> params) { super.init(params); getDialogOptions() .setWidth(theme.get("cuba.gui.ResetPasswordsDialog.width")) .setResizable(false); generatePasswordsCheckBox.addValueChangeListener(e -> { if (Boolean.TRUE.equals(e.getValue())) { sendEmailsCheckBox.setEnabled(true); updateExpectedResultLabel(); } else { sendEmailsCheckBox.setValue(false); sendEmailsCheckBox.setEnabled(false); } expectedResultLabel.setVisible(getGeneratePasswords()); }); sendEmailsCheckBox.addValueChangeListener(e -> updateExpectedResultLabel()); }
textSelection.setVisible(true); textSelection.addValueChangeListener(e -> changeTableTextSelectionEnabled()); entitiesDs.setSoftDeletion(!removedRecords.isChecked()); entitiesDs.setQuery(String.format("select e from %s e", meta.getName()));
protected void updateCheckBoxes(OperationPermissionTarget item) { itemChanging = true; if (isSingleSelection()) { if (item != null) { for (EntityOperationControl control : operationControls) { updateCheckBoxes(item.getValue(control.getMetaProperty()), control.getAllowChecker(), control.getDenyChecker()); } boolean isAllowedAll = true; boolean isDenyAll = true; for (EntityOperationControl control : operationControls) { if (control.isControlVisible()) { isAllowedAll &= Boolean.TRUE.equals(control.getAllowChecker().getValue()); isDenyAll &= Boolean.TRUE.equals(control.getDenyChecker().getValue()); } } allAllowCheck.setValue(isAllowedAll); allDenyCheck.setValue(isDenyAll); } else { deselectAllCheckers(); } } else { deselectAllCheckers(); } itemChanging = false; }
protected void attachCheckBoxListener(CheckBox checkBox, UiPermissionVariant activeVariant) { checkBox.addValueChangeListener(e -> { if (itemChanging) return; if (uiPermissionsTable.getSelected().isEmpty()) return; itemChanging = true; UiPermissionVariant permissionVariant = PermissionUiHelper.getCheckBoxVariant(e.getValue(), activeVariant); UiPermissionTarget target = uiPermissionsTable.getSingleSelected(); markItemPermission(permissionVariant, target); uiPermissionTargetsDs.updateItem(target); itemChanging = false; }); }
protected void createTimeZoneField() { FieldGroup.FieldConfig timeZoneFc = fieldGroupRight.getFieldNN("timeZone"); HBoxLayout hbox = uiComponents.create(HBoxLayout.class); hbox.setSpacing(true); timeZoneLookup = uiComponents.create(LookupField.TYPE_STRING); timeZoneLookup.setDatasource(timeZoneFc.getTargetDatasource(), timeZoneFc.getProperty()); timeZoneLookup.setRequired(false); MetaClass userMetaClass = userDs.getMetaClass(); timeZoneLookup.setEditable(fieldGroupRight.isEditable() && security.isEntityAttrUpdatePermitted(userMetaClass, timeZoneFc.getProperty())); Map<String, String> options = new TreeMap<>(); for (String id : TimeZone.getAvailableIDs()) { TimeZone timeZone = TimeZone.getTimeZone(id); options.put(timeZones.getDisplayNameLong(timeZone), id); } timeZoneLookup.setOptionsMap(options); hbox.add(timeZoneLookup); CheckBox autoDetectField = uiComponents.create(CheckBox.class); autoDetectField.setDatasource(timeZoneFc.getTargetDatasource(), "timeZoneAuto"); autoDetectField.setCaption(messages.getMainMessage("timeZone.auto")); autoDetectField.setDescription(messages.getMainMessage("timeZone.auto.descr")); autoDetectField.setAlignment(Alignment.MIDDLE_RIGHT); autoDetectField.setEditable(fieldGroupRight.isEditable() && security.isEntityAttrUpdatePermitted(userMetaClass, "timeZoneAuto")); hbox.add(autoDetectField); hbox.expand(timeZoneLookup); timeZoneFc.setComponent(hbox); }