diff org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ReadOnlyValidator.d @ 78:0a55d2d5a946

Added file for databinding
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 11:35:29 +0200
parents
children 6be48cf9f95c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/validation/ReadOnlyValidator.d	Tue Apr 14 11:35:29 2009 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright cast(C) 2005, 2006 db4objects Inc. (http://www.db4o.com) and others.
+ *
+ * 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:
+ *     db4objects - Initial API and implementation
+ *     Boris Bokowski (IBM Corporation) - bug 118429
+ *     Tom Schindl<tom.schindl@bestsolution.at> - bugfix for 217940
+ */
+module org.eclipse.core.internal.databinding.validation.ReadOnlyValidator;
+
+import java.lang.all;
+
+import org.eclipse.core.databinding.validation.IValidator;
+import org.eclipse.core.databinding.validation.ValidationStatus;
+import org.eclipse.core.internal.databinding.BindingMessages;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * ReadOnlyValidator. A validator that can be used as a partial validator for read-only fields.
+ */
+public class ReadOnlyValidator : IValidator {
+
+    private static ReadOnlyValidator singleton = null;
+
+    /**
+     * Returns the ReadOnlyValidator
+     *
+     * @return the ReadOnlyValidator
+     */
+    public static ReadOnlyValidator getDefault() {
+        if (singleton is null) {
+            singleton = new ReadOnlyValidator();
+        }
+        return singleton;
+    }
+
+    public IStatus validate(Object value) {
+        // No changes are allowed
+        return ValidationStatus.error(BindingMessages
+                .getStringcast(BindingMessages.VALIDATE_NO_CHANGE_ALLOWED_HELP));
+    }
+
+}