Missing file was added
authorEugene Ostroukhov <eugeneo@symbian.org>
Tue, 13 Jul 2010 08:58:31 -0700
changeset 440 533ef48d3b15
parent 439 57fff6202b74
child 441 85f06000ab13
Missing file was added
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NonEmptyStringValidator.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/NonEmptyStringValidator.java	Tue Jul 13 08:58:31 2010 -0700
@@ -0,0 +1,47 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.wizards;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.symbian.tools.wrttools.Activator;
+
+public class NonEmptyStringValidator implements IValidator {
+	private final String propertyName;
+    private final AbstractDataBindingPage page;
+
+	public NonEmptyStringValidator(String propertyName, AbstractDataBindingPage page) {
+		this.propertyName = propertyName;
+        this.page = page;
+	}
+
+	public IStatus validate(Object value) {
+        if (page != null && page.isActive()) {
+			if (value == null || value.toString().trim().length() == 0) {
+				return new Status(IStatus.ERROR, Activator.PLUGIN_ID,
+						MessageFormat.format("Field {0} is empty",
+								propertyName));
+			}
+		}
+		return Status.OK_STATUS;
+	}
+}
\ No newline at end of file