Java Code Examples for com.google.gwt.i18n.client.NumberFormat#getFormat()
The following examples show how to use
com.google.gwt.i18n.client.NumberFormat#getFormat() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HitsListPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onSearchArrived() { /** * Update the cursor. Prepare a stack for 2 sections the Title with * search time and the list of hits */ NumberFormat format = NumberFormat.getFormat("#.###"); String stats = I18N.message("aboutresults", new String[] { "" + Search.get().getEstimatedHits(), format.format((double) Search.get().getTime() / (double) 1000) }); stats += " (<b>" + format.format((double) Search.get().getTime() / (double) 1000) + "</b> " + I18N.message("seconds").toLowerCase() + ")"; cursor.setMessage(stats); GUISearchOptions options = Search.get().getOptions(); if (options.getType() == GUISearchOptions.TYPE_FULLTEXT) grid.setCanExpandRows(); GUIDocument[] result = Search.get().getLastResult(); if (result != null) grid.setDocuments(result); if (Search.get().isHasMore()) Log.warn(I18N.message("possiblemorehits"), I18N.message("possiblemorehitsdetail")); cursor.setMaxDisplayedRecords(options.getMaxHits()); }
Example 2
Source File: GUIExtensibleObject.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Appends a new value for a given multiple attribute. Returns the new * attribute that represent the value * * @param name name of the attribute * * @return the attribute */ public GUIAttribute addAttributeValue(String name) { List<GUIAttribute> actualValues = getValues(name); GUIAttribute lastValue = actualValues.get(actualValues.size() - 1); GUIAttribute newAtt = (GUIAttribute) lastValue.clone(); newAtt.setValue(null); newAtt.setMultiple(false); newAtt.setParent(name); NumberFormat nf = NumberFormat.getFormat("0000"); newAtt.setName(name + "-" + nf.format(actualValues.size())); putAttributeAfter(lastValue.getName(), newAtt); return newAtt; }
Example 3
Source File: Util.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
public static String formatLong(long number) { String str; NumberFormat fmt = NumberFormat.getFormat("#,###"); str = fmt.format(number); str = str.replace(',', I18N.groupingSepator()); return str; }
Example 4
Source File: Util.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Format file size in KB. * * @param size The file size in bytes. * * @return The formated file size. */ public static String formatSizeKB(double size) { String str; if (size < 1) { str = "0 KB"; } else if (size < 1024) { str = "1 KB"; } else { NumberFormat fmt = NumberFormat.getFormat("#,###"); str = fmt.format(Math.ceil(size / 1024)) + " KB"; str = str.replace(',', I18N.groupingSepator()); } return str; }
Example 5
Source File: Util.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Format file size in bytes * * @param size The file size in bytes * * @return the formatted size */ public static String formatSizeBytes(double size) { String str; NumberFormat fmt = NumberFormat.getFormat("#,###"); str = fmt.format(size) + " bytes"; str = str.replace(',', I18N.groupingSepator()); return str; }
Example 6
Source File: DisplayerGwtFormatter.java From dashbuilder with Apache License 2.0 | 5 votes |
protected NumberFormat getNumberFormat(String pattern) { if (StringUtils.isBlank(pattern)) { return getNumberFormat(ColumnSettings.NUMBER_PATTERN); } NumberFormat format = numberPatternMap.get(pattern); if (format == null) { format = NumberFormat.getFormat(pattern); numberPatternMap.put(pattern, format); } return format; }
Example 7
Source File: NumberRenderer.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
public NumberRenderer(String format) { if (format == null) { this.formater = NumberFormat.getDecimalFormat(); } else { this.formater = NumberFormat.getFormat(format); } }
Example 8
Source File: OutputProgressBar.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
public void setValue(T value) { this.value = value; double val = 0; if (value == null) { val = this.min; } else { val = value.doubleValue(); } if (val > this.max) { val = this.max; } else if (val < this.min) { val = this.min; } this.progressBarElement.setAttribute(OutputProgressBar.ATT_ARIA_VALUE, value + ""); double percent = 100 * (val - this.min) / (this.max - this.min); this.progressBarElement.getStyle().setProperty("width", percent, Unit.PCT); NumberFormat formatter = NumberFormat.getFormat("#.##"); String stringToDisplay = this.format; stringToDisplay = RegExp.compile("\\{0\\}").replace(stringToDisplay, formatter.format(val)); stringToDisplay = RegExp.compile("\\{1\\}").replace(stringToDisplay, formatter.format(percent)); stringToDisplay = RegExp.compile("\\{2\\}").replace(stringToDisplay, formatter.format(this.min)); stringToDisplay = RegExp.compile("\\{3\\}").replace(stringToDisplay, formatter.format(this.max)); this.progressBarElement.removeAllChildren(); if (this.displayValue) { this.progressBarElement.setInnerText(stringToDisplay); } else { SpanElement reader = Document.get().createSpanElement(); reader.setInnerText(stringToDisplay); reader.addClassName("sr-only"); this.progressBarElement.appendChild(reader); } }
Example 9
Source File: InputFile.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void redraw() { this.cancelBtn.removeFromParent(); this.uploadBtn.removeFromParent(); this.fileNameAnchor.removeFromParent(); this.placeholderText.removeFromParent(); this.progressBarWrapper.removeFromParent(); if (this.fileId != null) { this.append(this.progressBarWrapper); this.addAddon(this.cancelBtn); } else { FileDto value = this.getValue(); if (value != null) { NumberFormat nf = NumberFormat.getFormat("#.##"); long size = value.getContentLength(); String displaySize = ""; if (size > 1024 * 1024) { displaySize = nf.format(size / (1024 * 1024D)) + " MB"; } else if (size > 1024) { displaySize = nf.format(size / 1024D) + " KB"; } else { displaySize = nf.format(size) + " B"; } this.fileNameAnchor.setLink(urlDownload + value.getToken()); this.fileNameAnchor.setText(value.getName() + " - (" + displaySize + ")"); this.placeholderText.setText(null); this.append(this.fileNameAnchor); this.addAddon(this.cancelBtn); } else { this.fileNameAnchor.setLink(null); this.fileNameAnchor.setText(null); this.placeholderText.setText(this.placeholder); this.append(this.placeholderText); } this.addAddon(this.uploadBtn); } }
Example 10
Source File: IntegerTokenHelper.java From putnami-web-toolkit with GNU Lesser General Public License v3.0 | 4 votes |
public void setFormater(String format) { this.formater = NumberFormat.getFormat(format); }
Example 11
Source File: DecimalFormat.java From openchemlib-js with BSD 3-Clause "New" or "Revised" License | 4 votes |
public DecimalFormat(String pattern) { formatter = NumberFormat.getFormat(pattern); }