Search in sources :

Example 6 with IDecorator

use of org.jowidgets.util.IDecorator 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));
}
Also used : IValidationMessage(org.jowidgets.validation.IValidationMessage) IValidationResult(org.jowidgets.validation.IValidationResult) IInputComponentValidationLabelBluePrint(org.jowidgets.api.widgets.blueprint.IInputComponentValidationLabelBluePrint) IDecorator(org.jowidgets.util.IDecorator)

Aggregations

IDecorator (org.jowidgets.util.IDecorator)6 InvocationHandler (java.lang.reflect.InvocationHandler)4 AbstractCapServiceInvocationHandler (org.jowidgets.cap.common.tools.proxy.AbstractCapServiceInvocationHandler)3 IInputComponentValidationLabelBluePrint (org.jowidgets.api.widgets.blueprint.IInputComponentValidationLabelBluePrint)1 ISecureServiceId (org.jowidgets.cap.security.common.api.ISecureServiceId)1 IValidationMessage (org.jowidgets.validation.IValidationMessage)1 IValidationResult (org.jowidgets.validation.IValidationResult)1