Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/range/RangeTable.java @ 906:39acba4b5f0b
Added formatter for numeric columns that converts the decimal separator.
(Issue200)
flys-client/trunk@2758 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 15 Sep 2011 14:48:31 +0000 |
parents | dd702348b878 |
children | 748e7c828d03 |
comparison
equal
deleted
inserted
replaced
905:478a571f1f94 | 906:39acba4b5f0b |
---|---|
1 package de.intevation.flys.client.client.ui.range; | 1 package de.intevation.flys.client.client.ui.range; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 import com.google.gwt.i18n.client.NumberFormat; | |
4 | 5 |
5 import com.smartgwt.client.types.ListGridFieldType; | 6 import com.smartgwt.client.types.ListGridFieldType; |
6 import com.smartgwt.client.types.SelectionStyle; | 7 import com.smartgwt.client.types.SelectionStyle; |
7 import com.smartgwt.client.widgets.grid.ListGrid; | 8 import com.smartgwt.client.widgets.grid.ListGrid; |
8 import com.smartgwt.client.widgets.grid.ListGridField; | 9 import com.smartgwt.client.widgets.grid.ListGridField; |
10 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
11 import com.smartgwt.client.widgets.grid.CellFormatter; | |
9 | 12 |
10 import de.intevation.flys.client.client.FLYSConstants; | 13 import de.intevation.flys.client.client.FLYSConstants; |
11 import de.intevation.flys.client.client.FLYSImages; | 14 import de.intevation.flys.client.client.FLYSImages; |
12 | 15 |
13 | 16 |
43 "description", MESSAGES.description()); | 46 "description", MESSAGES.description()); |
44 ddescr.setType(ListGridFieldType.TEXT); | 47 ddescr.setType(ListGridFieldType.TEXT); |
45 ddescr.setWidth("*"); | 48 ddescr.setWidth("*"); |
46 ListGridField from = new ListGridField("from", MESSAGES.from()); | 49 ListGridField from = new ListGridField("from", MESSAGES.from()); |
47 from.setType(ListGridFieldType.FLOAT); | 50 from.setType(ListGridFieldType.FLOAT); |
51 from.setCellFormatter(new CellFormatter() { | |
52 public String format( | |
53 Object value, | |
54 ListGridRecord record, | |
55 int rowNum, int colNum) { | |
56 if (value == null) return null; | |
57 try { | |
58 NumberFormat nf; | |
59 double v = Double.parseDouble((String)value); | |
60 nf = NumberFormat.getFormat("###0.00##"); | |
61 return nf.format(v); | |
62 } | |
63 catch (Exception e) { | |
64 return value.toString(); | |
65 } | |
66 } | |
67 } | |
68 ); | |
69 | |
48 from.setWidth("12%"); | 70 from.setWidth("12%"); |
49 | 71 |
50 ListGridField to = new ListGridField("to", MESSAGES.to()); | 72 ListGridField to = new ListGridField("to", MESSAGES.to()); |
51 to.setType(ListGridFieldType.FLOAT); | 73 to.setType(ListGridFieldType.FLOAT); |
74 to.setCellFormatter(new CellFormatter() { | |
75 public String format( | |
76 Object value, | |
77 ListGridRecord record, | |
78 int rowNum, int colNum) { | |
79 if (value == null) return null; | |
80 GWT.log((String)value); | |
81 try { | |
82 NumberFormat nf; | |
83 double v = Double.parseDouble((String)value); | |
84 nf = NumberFormat.getFormat("###0.00##"); | |
85 return nf.format(v); | |
86 } | |
87 catch (Exception e) { | |
88 return value.toString(); | |
89 } | |
90 } | |
91 } | |
92 ); | |
93 | |
52 to.setWidth("12%"); | 94 to.setWidth("12%"); |
53 | 95 |
54 ListGridField dside = new ListGridField( | 96 ListGridField dside = new ListGridField( |
55 "riverside", MESSAGES.riverside()); | 97 "riverside", MESSAGES.riverside()); |
56 dside.setType(ListGridFieldType.TEXT); | 98 dside.setType(ListGridFieldType.TEXT); |