1
|
/**
|
2
|
* Copyright (C) 2016 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
|
package eu.etaxonomy.taxeditor.molecular.io.wizard;
|
10
|
|
11
|
|
12
|
import org.eclipse.core.databinding.validation.IValidator;
|
13
|
import org.eclipse.core.databinding.validation.ValidationStatus;
|
14
|
import org.eclipse.core.runtime.IStatus;
|
15
|
|
16
|
|
17
|
|
18
|
/**
|
19
|
* Validator to make sure a non-empty file name is provided.
|
20
|
*
|
21
|
* @author Ben Stöver
|
22
|
* @date 16.11.2016
|
23
|
*/
|
24
|
public class FileNameValidator implements IValidator {
|
25
|
/**
|
26
|
* {@inheritDoc}
|
27
|
*/
|
28
|
@Override
|
29
|
public IStatus validate(Object value) {
|
30
|
if ((value == null) || ((String)value).isEmpty()) {
|
31
|
return ValidationStatus.error("The file name must not be empty.");
|
32
|
}
|
33
|
else {
|
34
|
return ValidationStatus.ok();
|
35
|
}
|
36
|
//TODO Display warning, if the file extension does not match the selected format? (An according listener would have to be registered.)
|
37
|
}
|
38
|
}
|