-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in 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.utils.ui.validators;\r
-\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-\r
-import org.eclipse.jface.dialogs.IInputValidator;\r
-\r
-/**\r
- * Regular expression validator\r
- * \r
- * @author Toni Kalajainen\r
- */\r
-public class RegexpValidator implements IInputValidator {\r
-\r
- // Hostname mask\r
- //^([a-zA-Z0-9\\*]([a-zA-Z0-9\\-\\*]{0,61}[a-zA-Z0-9\\*])?\\.)*[a-zA-Z0-9\\*]([a-zA-Z0-9\\-\\*]{0,61}[a-zA-Z0-9\\*])?$\r
- \r
- // Untested\r
- //public static final String URL_VALIDATOR_STRING = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\\?\\/.=]+$";\r
- //public static RegexpValidator URL_VALIDATOR = new RegexpValidator(URL_VALIDATOR_STRING, "Invalid URL");\r
- \r
- private final Pattern pattern;\r
- private final String errorMsg;\r
- \r
- public RegexpValidator(String regexp, String errorMsg) {\r
- pattern = Pattern.compile(regexp);\r
- this.errorMsg = errorMsg;\r
- }\r
- \r
- public RegexpValidator(Pattern pattern, String errorMsg) {\r
- this.pattern = pattern;\r
- this.errorMsg = errorMsg;\r
- }\r
-\r
- public String isValid(String newText) {\r
- Matcher m = pattern.matcher(newText);\r
- if (m.matches()) return null;\r
- return errorMsg;\r
- }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.utils.ui.validators;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.dialogs.IInputValidator;
+
+/**
+ * Regular expression validator
+ *
+ * @author Toni Kalajainen
+ */
+public class RegexpValidator implements IInputValidator {
+
+ // Hostname mask
+ //^([a-zA-Z0-9\\*]([a-zA-Z0-9\\-\\*]{0,61}[a-zA-Z0-9\\*])?\\.)*[a-zA-Z0-9\\*]([a-zA-Z0-9\\-\\*]{0,61}[a-zA-Z0-9\\*])?$
+
+ // Untested
+ //public static final String URL_VALIDATOR_STRING = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\\?\\/.=]+$";
+ //public static RegexpValidator URL_VALIDATOR = new RegexpValidator(URL_VALIDATOR_STRING, "Invalid URL");
+
+ private final Pattern pattern;
+ private final String errorMsg;
+
+ public RegexpValidator(String regexp, String errorMsg) {
+ pattern = Pattern.compile(regexp);
+ this.errorMsg = errorMsg;
+ }
+
+ public RegexpValidator(Pattern pattern, String errorMsg) {
+ this.pattern = pattern;
+ this.errorMsg = errorMsg;
+ }
+
+ public String isValid(String newText) {
+ Matcher m = pattern.matcher(newText);
+ if (m.matches()) return null;
+ return errorMsg;
+ }
+
+}