use of org.jowidgets.validation.IValidationMessage in project jo-client-platform by jo-source.
the class DataModelSaveCommand method getVetoEnabledState.
@Override
IEnabledState getVetoEnabledState(final IDataModel model) {
if (model.hasExecutions()) {
return AbstractDataModelCommand.IN_PROCESS_STATE.get();
}
final IValidationResult validationResult = model.validate();
if (!validationResult.isValid()) {
final IValidationMessage worstFirst = validationResult.getWorstFirst();
final String context = worstFirst.getContext();
final String text = worstFirst.getText();
if (EmptyCheck.isEmpty(context)) {
return EnabledState.disabled(text);
} else {
return EnabledState.disabled(context + ": " + text);
}
}
return EnabledState.ENABLED;
}
use of org.jowidgets.validation.IValidationMessage in project jo-client-platform by jo-source.
the class BeanFormDefaults method initialize.
@Override
public void initialize(final IBeanFormBluePrint<?> bluePrint) {
bluePrint.setAutoResetValidation(true);
bluePrint.setCreateModeForegroundColor(Colors.GREEN);
bluePrint.setModifiedForegroundColor(Colors.STRONG);
bluePrint.setScrollbarsAllowed(true);
final IInputComponentValidationLabelBluePrint editModeValidationLabel = BPF.inputComponentValidationLabel();
final IDecorator<IValidationResult> editModeValidationDecorator = new IDecorator<IValidationResult>() {
@Override
public IValidationResult decorate(final IValidationResult original) {
if (original != null) {
final IValidationMessage worstFirst = original.getWorstFirst();
if (worstFirst != null && worstFirst.getType().equalOrWorse(MessageType.WARNING)) {
return original;
}
}
return null;
}
};
editModeValidationLabel.setInitialValidationDecorator(editModeValidationDecorator);
editModeValidationLabel.setUnmodifiedValidationDecorator(editModeValidationDecorator);
editModeValidationLabel.setEmptyIcon(IconsSmall.OK_GREYED);
bluePrint.setEditModeValidationLabel(editModeValidationLabel);
final IInputComponentValidationLabelBluePrint createModeValidationLabel = BPF.inputComponentValidationLabel();
final IDecorator<IValidationResult> createModeValidationDecorator = new IDecorator<IValidationResult>() {
@Override
public IValidationResult decorate(final IValidationResult original) {
if (original != null) {
final IValidationMessage worstFirst = original.getWorstFirst();
if (worstFirst != null && worstFirst.getType().equalOrWorse(MessageType.WARNING)) {
return original;
}
}
return null;
}
};
createModeValidationLabel.setInitialValidationDecorator(createModeValidationDecorator);
createModeValidationLabel.setUnmodifiedValidationDecorator(createModeValidationDecorator);
bluePrint.setCreateModeValidationLabel(createModeValidationLabel);
bluePrint.setCreateModeInputHint(Messages.getString("BeanFormDefaults.fill_out_mandatory_fields"));
bluePrint.setMandatoryBackgroundColor(CapColors.MANDATORY_BACKGROUND);
bluePrint.setMandatoryLabelDecorator(new IDecorator<String>() {
@Override
public String decorate(final String original) {
if (original != null) {
return original + "*";
}
return null;
}
});
bluePrint.setPropertyValidationLabel(BPF.validationResultLabel().setShowValidationMessage(false));
}
Aggregations