1
|
/**
|
2
|
* Copyright (C) 2017 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.cdm.vaadin.view.registration;
|
10
|
|
11
|
import java.util.Locale;
|
12
|
|
13
|
import com.vaadin.data.util.converter.Converter;
|
14
|
import com.vaadin.server.FontAwesome;
|
15
|
|
16
|
import eu.etaxonomy.cdm.api.service.dto.RegistrationType;
|
17
|
|
18
|
/**
|
19
|
* @author a.kohlbecker
|
20
|
* @since Mar 7, 2017
|
21
|
*
|
22
|
*/
|
23
|
public class RegistrationTypeConverter implements Converter<String, RegistrationType> {
|
24
|
@Override
|
25
|
public RegistrationType convertToModel(String value, Class<? extends RegistrationType> targetType,
|
26
|
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
27
|
// not implemented
|
28
|
return null;
|
29
|
}
|
30
|
|
31
|
@Override
|
32
|
public String convertToPresentation(RegistrationType value, Class<? extends String> targetType,
|
33
|
Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException {
|
34
|
if(value.equals(RegistrationType.NAME)) {
|
35
|
return FontAwesome.TAG.getHtml();
|
36
|
}
|
37
|
if(value.equals(RegistrationType.TYPIFICATION)) {
|
38
|
return FontAwesome.TAGS.getHtml();
|
39
|
}
|
40
|
return FontAwesome.WARNING.getHtml();
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public Class<RegistrationType> getModelType() {
|
45
|
return RegistrationType.class;
|
46
|
}
|
47
|
|
48
|
@Override
|
49
|
public Class<String> getPresentationType() {
|
50
|
return String.class;
|
51
|
}
|
52
|
}
|