cdm-vaadin/src/main/java/eu/etaxonomy/cdm/vaadin/component/TextFieldNFix.java @ 521a868a
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.component; |
10 |
|
11 |
import com.vaadin.data.Property; |
12 |
import com.vaadin.ui.TextField; |
13 |
|
14 |
/**
|
15 |
* TextField which has "" as null represnetation, fixed the ugly "null"s in the
|
16 |
* default TextField implementation in vaadin 7. TODO: this might no longer be
|
17 |
* required in vaadin 8 since it is supposed to have a mechanism to configure
|
18 |
* the null representations.
|
19 |
* <p>
|
20 |
* Additional features:
|
21 |
* <ul>
|
22 |
* <li>entered text is trimmed</li>
|
23 |
* </ul>
|
24 |
*
|
25 |
*
|
26 |
* @author a.kohlbecker
|
27 |
* @since Dec 21, 2017
|
28 |
*
|
29 |
*/
|
30 |
public class TextFieldNFix extends TextField { |
31 |
|
32 |
private static final long serialVersionUID = -7582619519894748364L; |
33 |
|
34 |
/**
|
35 |
* @param format
|
36 |
*/
|
37 |
public TextFieldNFix(String format) { |
38 |
super(format); |
39 |
init(); |
40 |
}
|
41 |
|
42 |
|
43 |
|
44 |
/**
|
45 |
*
|
46 |
*/
|
47 |
public TextFieldNFix() { |
48 |
super(); |
49 |
init(); |
50 |
}
|
51 |
|
52 |
|
53 |
|
54 |
/**
|
55 |
* @param dataSource
|
56 |
*/
|
57 |
public TextFieldNFix(Property dataSource) { |
58 |
super(dataSource); |
59 |
init(); |
60 |
}
|
61 |
|
62 |
|
63 |
|
64 |
/**
|
65 |
* @param caption
|
66 |
* @param dataSource
|
67 |
*/
|
68 |
public TextFieldNFix(String caption, Property dataSource) { |
69 |
super(caption, dataSource); |
70 |
init(); |
71 |
}
|
72 |
|
73 |
|
74 |
|
75 |
/**
|
76 |
* @param caption
|
77 |
* @param value
|
78 |
*/
|
79 |
public TextFieldNFix(String caption, String value) { |
80 |
super(caption, value); |
81 |
init(); |
82 |
}
|
83 |
|
84 |
|
85 |
|
86 |
/**
|
87 |
*
|
88 |
*/
|
89 |
protected void init() { |
90 |
setNullSettingAllowed(true); |
91 |
}
|
92 |
|
93 |
|
94 |
|
95 |
/**
|
96 |
* {@inheritDoc}
|
97 |
*/
|
98 |
@Override
|
99 |
public String getNullRepresentation() { |
100 |
return ""; |
101 |
}
|
102 |
|
103 |
|
104 |
|
105 |
/**
|
106 |
* {@inheritDoc}
|
107 |
*/
|
108 |
@Override
|
109 |
protected void setInternalValue(String newValue) { |
110 |
if(newValue != null){ |
111 |
newValue = newValue.trim(); |
112 |
if(newValue.isEmpty()){ |
113 |
newValue = null; |
114 |
}
|
115 |
}
|
116 |
super.setInternalValue(newValue); |
117 |
}
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
}
|
- « Previous
- 1
- …
- 6
- 7
- 8
- Next »