Rough version of images module that doesn't actually save image URLs i.e. Taxon has...
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / propertysheet / YearValidator.java
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.cdm.model.reference.BibtexReference;
17 import eu.etaxonomy.cdm.model.reference.StrictReferenceBase;
18 import eu.etaxonomy.taxeditor.model.CdmUtil;
19
20 /**
21 * @author p.ciardelli
22 * @created 10.11.2008
23 * @version 1.0
24 */
25 public class YearValidator implements ICellEditorValidator {
26 private static final Logger logger = Logger.getLogger(YearValidator.class);
27
28 /* (non-Javadoc)
29 * @see org.eclipse.jface.viewers.ICellEditorValidator#isValid(java.lang.Object)
30 */
31 public String isValid(Object value) {
32 String year = (String) value;
33 if (year.equals("")) {
34 return null;
35 }
36 try {
37 TimePeriod datePublished = CdmUtil.convertTimePeriod(year);
38 } catch (NumberFormatException e) {
39 return "Year must be between 1750 and 2030. Two years can also be given in the format 'xxxx-xxxx'.";
40 }
41 return null;
42 }
43 }