]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/chart/property/TimeInputValidator.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / chart / property / TimeInputValidator.java
index ff3c508c2e1c78167afd01cfa7debdf85b8f1b96..dd7bf1f8a7255e2e193986f58e74b401ce04aacd 100644 (file)
@@ -1,81 +1,81 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.modeling.ui.chart.property;\r
-\r
-import java.text.DecimalFormat;\r
-import java.text.Format;\r
-import java.text.ParseException;\r
-\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
-import org.simantics.utils.format.TimeFormat;\r
-\r
-/**\r
- * @author Toni Kalajainen\r
- */\r
-public class TimeInputValidator implements IInputValidator {\r
-       \r
-       Format decimalFormat = new DecimalFormat("0");\r
-\r
-       Format timeFormat = new TimeFormat(100, 0);\r
-       \r
-       double minValue;\r
-       \r
-       public TimeInputValidator(double minValue) {\r
-               this.minValue = minValue;\r
-       }       \r
-       \r
-       public Double parse(String text) {\r
-               if (text==null) return null;\r
-               text = text.trim();\r
-               if (text.equals("")) return null;\r
-\r
-               try {\r
-                       return (Double) timeFormat.parseObject(text);\r
-               } catch (ParseException e) {\r
-               }\r
-\r
-               try {\r
-                       Number n = (Number) decimalFormat.parseObject(text);\r
-                       if (n instanceof Double) return (Double) n;\r
-                       return n.doubleValue();\r
-               } catch (ParseException e) {\r
-               }\r
-               \r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public String isValid(String text) {\r
-               if (text==null) return "Null";\r
-               text = text.trim();\r
-               if (text.equals("")) return null;\r
-\r
-               try {\r
-                       Double d = (Double) timeFormat.parseObject(text);\r
-                       \r
-                       if (d != null && d.doubleValue()<minValue)\r
-                               return "The value must be at least "+minValue+" seconds.";\r
-                       return null;\r
-               } catch (ParseException e) {\r
-               }\r
-               \r
-               try {\r
-                       Number n = (Number) decimalFormat.parseObject(text);\r
-                       if (n != null && n.doubleValue()<minValue)\r
-                               return "The value must be at least "+minValue+" seconds.";\r
-                       return null;\r
-               } catch (ParseException e) {\r
-                       return "Unable to parse specified value as a measure of time.";\r
-               }\r
-       }\r
-       \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.ui.chart.property;
+
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.text.ParseException;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.simantics.utils.format.TimeFormat;
+
+/**
+ * @author Toni Kalajainen
+ */
+public class TimeInputValidator implements IInputValidator {
+       
+       Format decimalFormat = new DecimalFormat("0");
+
+       Format timeFormat = new TimeFormat(100, 0);
+       
+       double minValue;
+       
+       public TimeInputValidator(double minValue) {
+               this.minValue = minValue;
+       }       
+       
+       public Double parse(String text) {
+               if (text==null) return null;
+               text = text.trim();
+               if (text.equals("")) return null;
+
+               try {
+                       return (Double) timeFormat.parseObject(text);
+               } catch (ParseException e) {
+               }
+
+               try {
+                       Number n = (Number) decimalFormat.parseObject(text);
+                       if (n instanceof Double) return (Double) n;
+                       return n.doubleValue();
+               } catch (ParseException e) {
+               }
+               
+               return null;
+       }
+
+       @Override
+       public String isValid(String text) {
+               if (text==null) return "Null";
+               text = text.trim();
+               if (text.equals("")) return null;
+
+               try {
+                       Double d = (Double) timeFormat.parseObject(text);
+                       
+                       if (d != null && d.doubleValue()<minValue)
+                               return "The value must be at least "+minValue+" seconds.";
+                       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.";
+                       return null;
+               } catch (ParseException e) {
+                       return "Unable to parse specified value as a measure of time.";
+               }
+       }
+       
+}