KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > provisional > validation > ReadOnlyValidator


1 /*
2  * Copyright (C) 2005 db4objects Inc. http://www.db4o.com
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * db4objects - Initial API and implementation
11  */

12
13 package org.eclipse.jface.internal.databinding.provisional.validation;
14
15 import org.eclipse.jface.internal.databinding.internal.BindingMessages;
16
17 /**
18  * ReadOnlyValidator. The validator that can be used for read-only fields.
19  */

20 public class ReadOnlyValidator implements IValidator {
21     
22     private static ReadOnlyValidator singleton = null;
23     
24     /**
25      * Returns the ReadOnlyValidator
26      *
27      * @return the ReadOnlyValidator
28      */

29     public static ReadOnlyValidator getDefault() {
30         if (singleton == null) {
31             singleton = new ReadOnlyValidator();
32         }
33         return singleton;
34     }
35
36     /* (non-Javadoc)
37      * @see org.eclipse.jface.databinding.validator.IValidator#isPartiallyValid(java.lang.Object)
38      */

39     public ValidationError isPartiallyValid(Object JavaDoc fragment) {
40         // No changes are allowed
41
return ValidationError.error(BindingMessages.getString("Validate_NoChangeAllowed")); //$NON-NLS-1$
42
}
43
44     /* (non-Javadoc)
45      * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
46      */

47     public ValidationError isValid(Object JavaDoc value) {
48         // The current value is always valid
49
return null;
50     }
51
52 }
53
Popular Tags