Project

General

Profile

Download (1.18 KB) 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.apache.log4j.Logger;
13
import org.eclipse.jface.viewers.ICellEditorValidator;
14

    
15
import eu.etaxonomy.cdm.model.common.TimePeriod;
16
import eu.etaxonomy.taxeditor.store.model.TimeUtil;
17

    
18
/**
19
 * @author p.ciardelli
20
 * @created 10.11.2008
21
 * @version 1.0
22
 */
23
public class YearValidator implements ICellEditorValidator {
24
	private static final Logger logger = Logger.getLogger(YearValidator.class);
25

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