1
|
/**
|
2
|
* Copyright (C) 2018 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.component.registration;
|
10
|
|
11
|
import java.util.Collection;
|
12
|
|
13
|
import com.vaadin.data.Container;
|
14
|
import com.vaadin.ui.NativeSelect;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
|
17
|
|
18
|
/**
|
19
|
* @author a.kohlbecker
|
20
|
* @since Jul 4, 2018
|
21
|
*
|
22
|
*/
|
23
|
public class RegistrationStatusSelect extends NativeSelect {
|
24
|
|
25
|
|
26
|
private static final long serialVersionUID = 2400974680207121417L;
|
27
|
|
28
|
Object previousValue = null;
|
29
|
|
30
|
public RegistrationStatusSelect(){
|
31
|
super();
|
32
|
init();
|
33
|
}
|
34
|
|
35
|
/**
|
36
|
* @param caption
|
37
|
* @param options
|
38
|
*/
|
39
|
public RegistrationStatusSelect(String caption, Collection<?> options) {
|
40
|
super(caption, options);
|
41
|
init();
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* @param caption
|
46
|
* @param dataSource
|
47
|
*/
|
48
|
public RegistrationStatusSelect(String caption, Container dataSource) {
|
49
|
super(caption, dataSource);
|
50
|
init();
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* @param caption
|
55
|
*/
|
56
|
public RegistrationStatusSelect(String caption) {
|
57
|
super(caption);
|
58
|
init();
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
*
|
63
|
*/
|
64
|
public void init() {
|
65
|
addStyleName("registration-status");
|
66
|
setWidth("110px");
|
67
|
|
68
|
addValueChangeListener(e -> updateStyles());
|
69
|
}
|
70
|
|
71
|
|
72
|
/**
|
73
|
* @param newValue
|
74
|
* @param previousValue
|
75
|
*/
|
76
|
public void updateStyles() {
|
77
|
Object newValue = getValue();
|
78
|
String styles = getStyleName();
|
79
|
if(previousValue != null){
|
80
|
styles = styles.replace("registration-status-" + ((RegistrationStatus)previousValue).name(), "");
|
81
|
}
|
82
|
if(newValue != null){
|
83
|
setStyleName(styles + " registration-status-" + ((RegistrationStatus)newValue).name());
|
84
|
}
|
85
|
previousValue = newValue;
|
86
|
}
|
87
|
|
88
|
}
|