1 | @Deprecated↵ | | 1 | @Deprecated↵
|
2 | public static class IntegerCellEditor extends TextCellEditor↵ | | 2 | public static class FloatCellEditor extends TextCellEditor↵
|
3 | {↵ | | 3 | {↵
|
4 | public IntegerCellEditor(Composite composite)↵ | | 4 | public FloatCellEditor(Composite composite)↵
|
5 | {↵ | | 5 | {↵
|
6 | super(composite);↵ | | 6 | super(composite);↵
|
7 | setValidator↵ | | 7 | setValidator↵
|
8 | (new ICellEditorValidator()↵ | | 8 | (new ICellEditorValidator()↵
|
9 | {↵ | | 9 | {↵
|
10 | public String isValid(Object object)↵ | | 10 | public String isValid(Object object)↵
|
11 | {↵ | | 11 | {↵
|
12 | if (object instanceof Integer)↵ | | 12 | if (object instanceof Float)↵
|
13 | {↵ | | 13 | {↵
|
14 | return null;↵ | | 14 | return null;↵
|
15 | }↵ | | 15 | }↵
|
16 | else↵ | | 16 | else↵
|
17 | {↵ | | 17 | {↵
|
18 | String string = (String)object;↵ | | 18 | String string = (String)object;↵
|
19 | try↵ | | 19 | try↵
|
20 | {↵ | | 20 | {↵
|
21 | Integer.parseInt(string);↵ | | 21 | Float.parseFloat(string);↵
|
22 | return null;↵ | | 22 | return null;↵
|
23 | }↵ | | 23 | }↵
|
24 | catch (NumberFormatException exception)↵ | | 24 | catch (NumberFormatException exception)↵
|
25 | {↵ | | 25 | {↵
|
26 | return exception.getMessage();↵ | | 26 | return exception.getMessage();↵
|
27 | }↵ | | 27 | }↵
|
28 | }↵ | | 28 | }↵
|
29 | }↵ | | 29 | }↵
|
30 | });↵ | | 30 | });↵
|
31 | }↵ | | 31 | }↵
|
|
32 | @Override↵ | | 32 | @Override↵
|
33 | public Object doGetValue()↵ | | 33 | public Object doGetValue()↵
|
34 | {↵ | | 34 | {↵
|
35 | return new Integer(Integer.parseInt((String)super.doGetValue()));↵ | | 35 | return new Float(Float.parseFloat((String)super.doGetValue()));↵
|
36 | }↵ | | 36 | }↵
|
|
37 | @Override↵ | | 37 | @Override↵
|
38 | public void doSetValue(Object value)↵ | | 38 | public void doSetValue(Object value)↵
|
39 | {↵ | | 39 | {↵
|
40 | super.doSetValue(value.toString()); | | 40 | super.doSetValue(value.toString());
|