mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-05 04:38:10 +08:00
PL-9960 Required field in a non-editable field group is being validated
This commit is contained in:
parent
3c806bf4af
commit
b65e517f54
@ -27,7 +27,9 @@ import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.BeanValidation;
|
||||
import com.haulmont.cuba.core.global.MessageTools;
|
||||
import com.haulmont.cuba.core.global.MetadataTools;
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
import com.haulmont.cuba.gui.components.Field;
|
||||
import com.haulmont.cuba.gui.components.RequiredValueMissingException;
|
||||
import com.haulmont.cuba.gui.components.ValidationException;
|
||||
import com.haulmont.cuba.gui.components.compatibility.ComponentValueListenerWrapper;
|
||||
import com.haulmont.cuba.gui.components.validators.BeanValidator;
|
||||
import com.haulmont.cuba.gui.data.Datasource;
|
||||
@ -121,7 +123,7 @@ public abstract class DesktopAbstractField<C extends JComponent> extends Desktop
|
||||
|
||||
@Override
|
||||
public void validate() throws ValidationException {
|
||||
if (!isVisible() || !isEditable() || !isEnabled())
|
||||
if (!isVisible() || !isEditableWithParent() || !isEnabled())
|
||||
return;
|
||||
|
||||
Object value = getValue();
|
||||
|
@ -99,7 +99,7 @@ public abstract class DesktopAbstractTextField<T extends JTextComponent> extends
|
||||
|
||||
@Override
|
||||
public void updateMissingValueState() {
|
||||
boolean state = required && editable && StringUtils.isBlank(impl.getText());
|
||||
boolean state = isRequired() && isEditableWithParent() && StringUtils.isBlank(impl.getText());
|
||||
decorateMissingValue(impl, state);
|
||||
if (getComposition() instanceof JScrollPane) {
|
||||
decorateMissingValue(getComposition(), state);
|
||||
|
@ -325,6 +325,9 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
|
||||
@Override
|
||||
public void validate() throws ValidationException {
|
||||
if (!isVisible() || !isEditableWithParent() || !isEnabled())
|
||||
return;
|
||||
|
||||
try {
|
||||
constructDate();
|
||||
super.validate();
|
||||
@ -632,7 +635,7 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
|
||||
@Override
|
||||
public void updateMissingValueState() {
|
||||
boolean value = required && editable && datePicker.getEditor().getValue() == null;
|
||||
boolean value = required && isEditableWithParent() && datePicker.getEditor().getValue() == null;
|
||||
decorateMissingValue(datePicker.getEditor(), value);
|
||||
if (isHourUsed()) {
|
||||
decorateMissingValue(timeField.getImpl(), value);
|
||||
|
@ -893,7 +893,7 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel>
|
||||
|
||||
@Override
|
||||
public void validate() throws ValidationException {
|
||||
if (!isVisible() || !isEditable() || !isEnabled()) {
|
||||
if (!isVisible() || !isEditableWithParent() || !isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ public class DesktopLookupField extends DesktopAbstractOptionsField<JComponent>
|
||||
@Override
|
||||
public void updateMissingValueState() {
|
||||
Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||
boolean value = required && editable && enabled && editorComponent instanceof JTextComponent
|
||||
boolean value = required && isEditableWithParent() && isEnabledWithParent() && editorComponent instanceof JTextComponent
|
||||
&& StringUtils.isEmpty(((JTextComponent) editorComponent).getText());
|
||||
decorateMissingValue(comboBox, value);
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ public class DesktopPickerField extends DesktopAbstractField<Picker>
|
||||
return;
|
||||
}
|
||||
JTextComponent editor = (JTextComponent) impl.getEditor();
|
||||
boolean value = required && editable && StringUtils.isBlank(editor.getText());
|
||||
boolean value = required && isEditableWithParent() && StringUtils.isBlank(editor.getText());
|
||||
|
||||
decorateMissingValue(impl.getEditor(), value);
|
||||
}
|
||||
|
@ -253,7 +253,10 @@ public class DesktopSearchField extends DesktopAbstractOptionsField<JComponent>
|
||||
|
||||
protected void updateEditState() {
|
||||
Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||
boolean value = required && editable && enabled && editorComponent instanceof JTextComponent
|
||||
boolean value = required
|
||||
&& isEditableWithParent()
|
||||
&& isEnabledWithParent()
|
||||
&& editorComponent instanceof JTextComponent
|
||||
&& StringUtils.isEmpty(((JTextComponent) editorComponent).getText());
|
||||
if (value) {
|
||||
comboBox.setBackground(requiredBgColor);
|
||||
|
@ -389,7 +389,7 @@ public class DesktopSuggestionField extends DesktopAbstractOptionsField<JCompone
|
||||
|
||||
protected void updateEditState() {
|
||||
Component editorComponent = comboBox.getEditor().getEditorComponent();
|
||||
boolean value = required && editable && enabled && editorComponent instanceof JTextComponent
|
||||
boolean value = required && isEditableWithParent() && isEnabledWithParent() && editorComponent instanceof JTextComponent
|
||||
&& StringUtils.isEmpty(((JTextComponent) editorComponent).getText());
|
||||
if (value) {
|
||||
comboBox.setBackground(requiredBgColor);
|
||||
|
@ -97,7 +97,7 @@ public class DesktopTextField extends DesktopAbstractTextField<JTextComponent> i
|
||||
|
||||
protected void refreshInputPrompt() {
|
||||
if (StringUtils.isNotBlank(inputPrompt)) {
|
||||
if (isEnabledWithParent() && isEditable()) {
|
||||
if (isEnabledWithParent() && isEditableWithParent()) {
|
||||
// Save old tooltipText value to use it later
|
||||
String toolTipText = this.impl.getToolTipText();
|
||||
|
||||
@ -136,7 +136,7 @@ public class DesktopTextField extends DesktopAbstractTextField<JTextComponent> i
|
||||
public void setInputPrompt(String inputPrompt) {
|
||||
this.inputPrompt = inputPrompt;
|
||||
|
||||
if ((!this.impl.isEditable() || !this.impl.isEnabled()) && StringUtils.isNotBlank(inputPrompt)) {
|
||||
if ((!isEditableWithParent() || !this.impl.isEnabled()) && StringUtils.isNotBlank(inputPrompt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ public class DesktopTimeField extends DesktopAbstractField<JFormattedTextField>
|
||||
@Override
|
||||
public void updateMissingValueState() {
|
||||
Object implValue = impl.getValue();
|
||||
boolean value = required && editable
|
||||
boolean value = required && isEditableWithParent()
|
||||
&& (implValue == null || implValue instanceof String && StringUtils.isBlank((String) implValue));
|
||||
decorateMissingValue(impl, value);
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ public abstract class WebAbstractField<T extends com.vaadin.ui.AbstractField>
|
||||
setValidationError(null);
|
||||
}
|
||||
|
||||
if (!isVisible() || !isEditable() || !isEnabled()) {
|
||||
if (!isVisible() || !isEditableWithParent() || !isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -173,6 +173,14 @@ public class WebCurrencyField extends WebAbstractField<CubaCurrencyField> implem
|
||||
|
||||
@Override
|
||||
public void validate() throws ValidationException {
|
||||
if (hasValidationError()) {
|
||||
setValidationError(null);
|
||||
}
|
||||
|
||||
if (!isVisible() || !isEditableWithParent() || !isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
textField.validate();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ import org.dom4j.Element;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -660,7 +659,7 @@ public class WebFieldGroup extends WebAbstractComponent<CubaFieldGroupLayout>
|
||||
|
||||
@Override
|
||||
public void validate() throws ValidationException {
|
||||
if (!isVisible() || !isEditable() || !isEnabled()) {
|
||||
if (!isVisible() || !isEditableWithParent() || !isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user