Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-client/src/main/java/org/dive4elements/river/client/client/ui/wq/WTable.java@821a02bbfb4e |
children | 172338b1407f |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.client.client.ui.wq; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 import com.google.gwt.i18n.client.NumberFormat; | |
5 | |
6 import com.smartgwt.client.types.ListGridFieldType; | |
7 import com.smartgwt.client.types.SelectionStyle; | |
8 import com.smartgwt.client.widgets.grid.CellFormatter; | |
9 import com.smartgwt.client.widgets.grid.ListGrid; | |
10 import com.smartgwt.client.widgets.grid.ListGridField; | |
11 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
12 | |
13 import org.dive4elements.river.client.client.FLYSConstants; | |
14 | |
15 /** | |
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
17 */ | |
18 public class WTable extends ListGrid { | |
19 | |
20 /** The message class that provides i18n strings.*/ | |
21 protected FLYSConstants MESSAGE = GWT.create(FLYSConstants.class); | |
22 | |
23 | |
24 public WTable() { | |
25 setWidth100(); | |
26 setHeight100(); | |
27 setSelectionType(SelectionStyle.NONE); | |
28 setSelectionType(SelectionStyle.NONE); | |
29 setShowHeaderContextMenu(false); | |
30 setShowRecordComponents(true); | |
31 setShowRecordComponentsByCell(true); | |
32 setEmptyMessage(MESSAGE.empty_table()); | |
33 | |
34 ListGridField name = new ListGridField("name", MESSAGE.name()); | |
35 name.setType(ListGridFieldType.TEXT); | |
36 name.setWidth("*"); | |
37 | |
38 ListGridField type = new ListGridField("type", MESSAGE.type()); | |
39 type.setType(ListGridFieldType.TEXT); | |
40 type.setWidth("50"); | |
41 | |
42 final NumberFormat nf = NumberFormat.getDecimalFormat(); | |
43 | |
44 ListGridField value = new ListGridField("value", MESSAGE.wq_value_w()); | |
45 value.setType(ListGridFieldType.FLOAT); | |
46 value.setCellFormatter(new CellFormatter() { | |
47 @Override | |
48 public String format(Object v, ListGridRecord r, int row, int col) { | |
49 if (v == null) { | |
50 return null; | |
51 } | |
52 | |
53 try { | |
54 double value = Double.valueOf(v.toString()); | |
55 return nf.format(value); | |
56 } | |
57 catch (NumberFormatException nfe) { | |
58 return v.toString(); | |
59 } | |
60 } | |
61 }); | |
62 | |
63 setFields(name, type, value); | |
64 } | |
65 } | |
66 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |