Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/wq/QDTable.java @ 1498:ed16f28e9063
#196 Localize numbers in W/Q/D tables.
flys-client/trunk@3611 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 06 Jan 2012 11:07:32 +0000 |
parents | 047a44270348 |
children | 5659b5e8c9a8 |
comparison
equal
deleted
inserted
replaced
1497:895e6bc4bb73 | 1498:ed16f28e9063 |
---|---|
1 package de.intevation.flys.client.client.ui.wq; | 1 package de.intevation.flys.client.client.ui.wq; |
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; |
8 import com.smartgwt.client.widgets.grid.CellFormatter; | |
7 import com.smartgwt.client.widgets.grid.ListGrid; | 9 import com.smartgwt.client.widgets.grid.ListGrid; |
8 import com.smartgwt.client.widgets.grid.ListGridField; | 10 import com.smartgwt.client.widgets.grid.ListGridField; |
11 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
9 | 12 |
10 import de.intevation.flys.client.client.FLYSConstants; | 13 import de.intevation.flys.client.client.FLYSConstants; |
11 | 14 |
12 | 15 |
13 /** | 16 /** |
49 | 52 |
50 ListGridField type = new ListGridField("type", MESSAGE.type()); | 53 ListGridField type = new ListGridField("type", MESSAGE.type()); |
51 type.setType(ListGridFieldType.TEXT); | 54 type.setType(ListGridFieldType.TEXT); |
52 type.setWidth("20%"); | 55 type.setWidth("20%"); |
53 | 56 |
57 final NumberFormat nf = NumberFormat.getDecimalFormat(); | |
58 | |
54 ListGridField value = new ListGridField("value", MESSAGE.wq_value()); | 59 ListGridField value = new ListGridField("value", MESSAGE.wq_value()); |
55 value.setType(ListGridFieldType.FLOAT); | 60 value.setType(ListGridFieldType.FLOAT); |
61 value.setCellFormatter(new CellFormatter() { | |
62 @Override | |
63 public String format(Object v, ListGridRecord r, int row, int col) { | |
64 if (v == null) { | |
65 return null; | |
66 } | |
67 | |
68 try { | |
69 double value = Double.valueOf(v.toString()); | |
70 return nf.format(value); | |
71 } | |
72 catch (NumberFormatException nfe) { | |
73 return v.toString(); | |
74 } | |
75 } | |
76 }); | |
56 value.setWidth("20%"); | 77 value.setWidth("20%"); |
57 | 78 |
58 setFields(addMax, addMin, name, type, value); | 79 setFields(addMax, addMin, name, type, value); |
59 } | 80 } |
60 | 81 |