comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/TableDataPanel.java @ 1486:efdb4fe5a69e

Improved the TableDataPanel (for displaying calculation results) to support CSV exports with more than 5 columns. flys-client/trunk@3560 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 02 Jan 2012 10:23:29 +0000
parents bc06a671ef60
children 03de5c424f95
comparison
equal deleted inserted replaced
1485:00e429e6420c 1486:efdb4fe5a69e
119 dataTable.setEmptyMessage(MESSAGES.error_no_calc_result()); 119 dataTable.setEmptyMessage(MESSAGES.error_no_calc_result());
120 dataTable.redraw(); 120 dataTable.redraw();
121 return; 121 return;
122 } 122 }
123 123
124 Config config = Config.getInstance();
125 String locale = config.getLocale();
126
127 NumberFormat nf;
128 if (locale.equals("de")) {
129 nf = NumberFormat.getFormat("#,##");
130 }
131 else {
132 nf = NumberFormat.getFormat("#.##");
133 }
134
124 String[] header = (String[])list.get(0); 135 String[] header = (String[])list.get(0);
125 String[] firstValues = (String[])list.get(1); 136 String[] firstValues = (String[])list.get(1);
126 137
127 ListGridField[] fields = new ListGridField[header.length]; 138 ListGridField[] fields = new ListGridField[header.length];
139
128 for(int i = 0; i < header.length; i++) { 140 for(int i = 0; i < header.length; i++) {
129 ListGridField f = new ListGridField(String.valueOf(i)); 141 ListGridField f = new ListGridField(String.valueOf(i));
130 fields[i] = f; 142 fields[i] = f;
131 f.setTitle(header[i]); 143 f.setTitle(header[i]);
132 144
133 Config config = Config.getInstance();
134 String locale = config.getLocale();
135 try { 145 try {
136 NumberFormat nf;
137 if (locale.equals("de")) {
138 nf = NumberFormat.getFormat("#,##");
139 }
140 else {
141 nf = NumberFormat.getFormat("#.##");
142 }
143 nf.parse(firstValues[i]); 146 nf.parse(firstValues[i]);
144 f.setType(ListGridFieldType.FLOAT); 147 f.setType(ListGridFieldType.FLOAT);
145 } 148 }
146 catch (NumberFormatException nfe) { 149 catch (NumberFormatException nfe) {
147 f.setType(ListGridFieldType.TEXT); 150 f.setType(ListGridFieldType.TEXT);
148 } 151 }
149
150 } 152 }
151 153
152 if (header.length == 2) { 154 dataTable.setFields(fields);
153 dataTable.setFields(fields[0], fields[1]);
154 }
155 else if(header.length == 3) {
156 dataTable.setFields(fields[0], fields[1], fields[2]);
157 }
158 else if(header.length == 4) {
159 dataTable.setFields(fields[0], fields[1], fields[2], fields[3]);
160 }
161 else if(header.length == 5) {
162 dataTable.setFields(
163 fields[0],
164 fields[1],
165 fields[2],
166 fields[3],
167 fields[4]);
168 }
169 155
170 for(int i = 1; i < list.size(); i++) { 156 for(int i = 1; i < list.size(); i++) {
171 String[] sItem = (String[])list.get(i); 157 String[] sItem = (String[])list.get(i);
172 ListGridRecord r = new ListGridRecord(); 158 ListGridRecord r = new ListGridRecord();
173 for(int j = 0; j < sItem.length; j++) { 159 for(int j = 0; j < sItem.length; j++) {

http://dive4elements.wald.intevation.org