Revision c20ea7df src/gr/grnet/pithos/web/client/foldertree/Folder.java
b/src/gr/grnet/pithos/web/client/foldertree/Folder.java | ||
---|---|---|
47 | 47 |
import com.google.gwt.http.client.Response; |
48 | 48 |
import com.google.gwt.http.client.URL; |
49 | 49 |
import com.google.gwt.i18n.client.DateTimeFormat; |
50 |
import com.google.gwt.i18n.client.NumberFormat; |
|
50 | 51 |
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat; |
51 | 52 |
import com.google.gwt.json.client.JSONArray; |
52 | 53 |
import com.google.gwt.json.client.JSONObject; |
... | ... | |
338 | 339 |
|
339 | 340 |
@Override |
340 | 341 |
public String getSizeAsString() { |
341 |
return "0 KB"; |
|
342 |
long bytes = calculateContentsSize(); |
|
343 |
NumberFormat nf = NumberFormat.getFormat("######.#"); |
|
344 |
if (bytes < 1024) |
|
345 |
return String.valueOf(bytes) + " B"; |
|
346 |
else if (bytes < 1024 * 1024) |
|
347 |
return nf.format(Double.valueOf(bytes)/(1024)) + " KB"; |
|
348 |
else if (bytes < 1024 * 1024 * 1024) |
|
349 |
return nf.format(Double.valueOf(bytes)/(1024 * 1024)) + " MB"; |
|
350 |
return nf.format(Double.valueOf(bytes)/(1024 * 1024 * 1024)) + " GB"; |
|
351 |
} |
|
352 |
|
|
353 |
private long calculateContentsSize() { |
|
354 |
long total = 0; |
|
355 |
for (File f : files) |
|
356 |
total += f.getBytes(); |
|
357 |
return total; |
|
342 | 358 |
} |
343 | 359 |
|
344 | 360 |
@Override |
Also available in: Unified diff