Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.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 | 5a299d49a989 |
children | d59dcaf52796 |
comparison
equal
deleted
inserted
replaced
905:478a571f1f94 | 906:39acba4b5f0b |
---|---|
2 | 2 |
3 import java.util.List; | 3 import java.util.List; |
4 | 4 |
5 import com.google.gwt.core.client.GWT; | 5 import com.google.gwt.core.client.GWT; |
6 import com.google.gwt.user.client.rpc.AsyncCallback; | 6 import com.google.gwt.user.client.rpc.AsyncCallback; |
7 import com.google.gwt.i18n.client.NumberFormat; | |
7 | 8 |
8 import com.smartgwt.client.util.SC; | 9 import com.smartgwt.client.util.SC; |
9 import com.smartgwt.client.widgets.Canvas; | 10 import com.smartgwt.client.widgets.Canvas; |
10 import com.smartgwt.client.widgets.layout.VLayout; | 11 import com.smartgwt.client.widgets.layout.VLayout; |
11 import com.smartgwt.client.widgets.grid.ListGrid; | 12 import com.smartgwt.client.widgets.grid.ListGrid; |
12 import com.smartgwt.client.widgets.grid.ListGridField; | 13 import com.smartgwt.client.widgets.grid.ListGridField; |
13 import com.smartgwt.client.widgets.grid.ListGridRecord; | 14 import com.smartgwt.client.widgets.grid.ListGridRecord; |
15 import com.smartgwt.client.types.ListGridFieldType; | |
14 | 16 |
15 import de.intevation.flys.client.shared.model.DataList; | 17 import de.intevation.flys.client.shared.model.DataList; |
16 | 18 |
17 import de.intevation.flys.client.client.FLYSConstants; | 19 import de.intevation.flys.client.client.FLYSConstants; |
18 import de.intevation.flys.client.client.Config; | 20 import de.intevation.flys.client.client.Config; |
113 * | 115 * |
114 * @param list List if String[] containing the data. | 116 * @param list List if String[] containing the data. |
115 */ | 117 */ |
116 public void setData(List list) { | 118 public void setData(List list) { |
117 String[] header = (String[])list.get(0); | 119 String[] header = (String[])list.get(0); |
120 String[] firstValues = (String[])list.get(1); | |
118 ListGridField[] fields = new ListGridField[header.length]; | 121 ListGridField[] fields = new ListGridField[header.length]; |
119 for(int i = 0; i < header.length; i++) { | 122 for(int i = 0; i < header.length; i++) { |
120 ListGridField f = new ListGridField(String.valueOf(i)); | 123 ListGridField f = new ListGridField(String.valueOf(i)); |
121 fields[i] = f; | 124 fields[i] = f; |
122 f.setTitle(header[i]); | 125 f.setTitle(header[i]); |
126 | |
127 Config config = Config.getInstance(); | |
128 String locale = config.getLocale(); | |
129 try { | |
130 NumberFormat nf; | |
131 if (locale.equals("de")) { | |
132 nf = NumberFormat.getFormat("#,##"); | |
133 } | |
134 else { | |
135 nf = NumberFormat.getFormat("#.##"); | |
136 } | |
137 nf.parse(firstValues[i]); | |
138 f.setType(ListGridFieldType.FLOAT); | |
139 } | |
140 catch (NumberFormatException nfe) { | |
141 f.setType(ListGridFieldType.TEXT); | |
142 } | |
143 | |
123 } | 144 } |
124 | 145 |
125 if (header.length == 2) { | 146 if (header.length == 2) { |
126 dataTable.setFields(fields[0], fields[1]); | 147 dataTable.setFields(fields[0], fields[1]); |
127 } | 148 } |