Project

General

Profile

Download (1019 Bytes) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.propertysheet;
11

    
12
import org.eclipse.jface.viewers.ICellEditorValidator;
13

    
14
import eu.etaxonomy.taxeditor.model.TimeHelper;
15

    
16
/**
17
 * @author p.ciardelli
18
 * @created 10.11.2008
19
 * @version 1.0
20
 */
21
public class YearValidator implements ICellEditorValidator {
22

    
23
	/* (non-Javadoc)
24
	 * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
25
	 */
26
	public String isValid(Object value) {
27
		String year = (String) value;
28
		if (year.equals("")) {
29
			return null;
30
		}
31
		try {
32
			TimeHelper.convertTimePeriod(year);
33
		} catch (NumberFormatException e) {
34
			return "Year must be between 1750 and 2030. Two years can also be given in the format 'xxxx-xxxx'.";
35
		}
36
		return null;
37
	}
38
}
(24-24/24)