import java.text.ParseException;
import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.osgi.util.NLS;
import org.simantics.utils.format.TimeFormat;
/**
*/
public class TimeInputValidator implements IInputValidator {
- Format decimalFormat = new DecimalFormat("0");
+ Format decimalFormat = new DecimalFormat("0"); //$NON-NLS-1$
Format timeFormat = new TimeFormat(100, 0);
public Double parse(String text) {
if (text==null) return null;
text = text.trim();
- if (text.equals("")) return null;
+ if (text.equals("")) return null; //$NON-NLS-1$
try {
return (Double) timeFormat.parseObject(text);
@Override
public String isValid(String text) {
- if (text==null) return "Null";
+ if (text == null)
+ return "Null"; //$NON-NLS-1$
text = text.trim();
- if (text.equals("")) return null;
+ if (text.equals("")) //$NON-NLS-1$
+ return null;
try {
Double d = (Double) timeFormat.parseObject(text);
-
- if (d != null && d.doubleValue()<minValue)
- return "The value must be at least "+minValue+" seconds.";
+
+ if (d != null && d.doubleValue() < minValue)
+ return NLS.bind(Messages.TimeInputValidator_ValueRange, minValue);
return null;
} catch (ParseException e) {
}
-
+
try {
Number n = (Number) decimalFormat.parseObject(text);
- if (n != null && n.doubleValue()<minValue)
- return "The value must be at least "+minValue+" seconds.";
+ if (n != null && n.doubleValue() < minValue)
+ return NLS.bind(Messages.TimeInputValidator_ValueRange, minValue);
return null;
} catch (ParseException e) {
- return "Unable to parse specified value as a measure of time.";
+ return "Unable to parse specified value as a measure of time."; //$NON-NLS-1$
}
}