package de.ptb.epics.eve.editor.views.detectorchannelview;

import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.IStatus;


/**
 * @author Marcus Michalsky
 * @since 1.27
 */
public class MaxAttemptsTargetToModelValidator implements IValidator {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public IStatus validate(Object value) {
		String val = (String) value;
		if (val.isEmpty()) {
			return ValidationStatus.ok();
		}
		try {
			int i = Integer.parseInt(val);
			if (i < 0) {
				return ValidationStatus.error("Max Attempts must not be negative!");
			}
			if (i == 0) {
				return ValidationStatus.error("Max Attempts  must not be zero!");
			}
			return ValidationStatus.ok();
		} catch (NumberFormatException e) {
			return ValidationStatus.error("cannot parse integer.");
		}
	}
}
@@ -654,100 +654,8 @@
 %09%09%7D%0A
-%09%09%09if (i == 0) %7B%0A%09%09%09%09return ValidationStatus.error(%22Max Attempts  must not be zero!%22);%0A%09%09%09%7D%0A
 %09%09%09r

allow 0 for max attempts in standard channel