Example usage for com.google.gwt.i18n.client NumberFormat getDecimalFormat

List of usage examples for com.google.gwt.i18n.client NumberFormat getDecimalFormat

Introduction

In this page you can find the example usage for com.google.gwt.i18n.client NumberFormat getDecimalFormat.

Prototype

public static NumberFormat getDecimalFormat() 

Source Link

Document

Provides the standard decimal format for the default locale.

Usage

From source file:co.fxl.data.format.gwt.GWTNumberFormat.java

License:Open Source License

protected NumberFormat getNumberFormat() {
    if (defaultFormatStyle == null) {
        return NumberFormat.getDecimalFormat();
    } else {// w ww  . java2s .  c o  m
        return NumberFormat.getFormat(defaultFormatStyle);
    }
}

From source file:com.colinalworth.celltable.columns.client.converters.DoubleConverter.java

License:Apache License

@Override
public Double fromCellToModel(String cell) {
    return "".equals(cell) ? null : NumberFormat.getDecimalFormat().parse(cell);
}

From source file:com.colinalworth.celltable.columns.client.converters.DoubleConverter.java

License:Apache License

@Override
public String fromModelToCell(Double model) {
    return model == null ? "" : NumberFormat.getDecimalFormat().format(model);
}

From source file:com.colinalworth.celltable.columns.client.converters.NumberConverter.java

License:Apache License

public Number fromCellToModel(String cell) {
    return "".equals(cell) ? null : NumberFormat.getDecimalFormat().parse(cell);
}

From source file:com.colinalworth.celltable.columns.client.converters.NumberConverter.java

License:Apache License

public String fromModelToCell(Number model) {
    return model == null ? "" : NumberFormat.getDecimalFormat().format(model);
}

From source file:com.extjs.gxt.samples.client.examples.binding.BasicBindingExample.java

License:Open Source License

@Override
protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    El.fly(parent).addStyleName("binding-example");

    final Stock stock = TestData.getStocks().get(0);

    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);/*from  w  w w.ja  v a  2s.  co  m*/

    StringBuffer sb = new StringBuffer();
    sb.append("<div class=text style='line-height: 1.5em'>");
    sb.append("<b>Name:</b> {name}<br>");
    sb.append("<b>Symbol:</b> {symbol}<br>");
    sb.append("<b>Last:</b> {last}<br>");
    sb.append("<b>Change:</b> {[new Number(values.change).toFixed(2)]}<br>");
    sb.append("<b>Updated:</b> {date:date(\"MM/dd/y\")}<br>");
    sb.append("</div>");

    final XTemplate template = XTemplate.create(sb.toString());
    final HTML html = new HTML();
    html.setWidth("160px");

    template.overwrite(html.getElement(), Util.getJsObject(stock));
    hp.add(html);
    // update template when model changes
    stock.addChangeListener(new ChangeListener() {
        public void modelChanged(ChangeEvent event) {
            template.overwrite(html.getElement(), Util.getJsObject(stock));
        }
    });

    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);
    panel.setWidth(350);

    TextField<String> name = new TextField<String>();
    name.setName("nameField");
    name.setFieldLabel("Name");
    panel.add(name);

    TextField<String> symbol = new TextField<String>();
    symbol.setName("symbol");
    symbol.setFieldLabel("Symbol");
    panel.add(symbol);

    NumberField open = new NumberField();
    open.setName("last");
    open.setFieldLabel("Last");
    panel.add(open);

    NumberField change = new NumberField();
    change.setName("change");
    change.setFieldLabel("Change");
    change.setFormat(NumberFormat.getDecimalFormat());
    panel.add(change);

    DateField last = new DateField();
    last.setName("date");
    last.setFieldLabel("Updated");
    panel.add(last);

    SimpleComboBox<String> scb = new SimpleComboBox<String>();
    for (Stock s : TestData.getStocks()) {
        scb.add(s.getName());
    }
    scb.setFieldLabel("Name");
    scb.setForceSelection(true);
    scb.setTypeAhead(true);
    scb.setName("company");
    scb.setTriggerAction(TriggerAction.ALL);
    panel.add(scb);

    hp.add(panel);

    FormBinding binding = new FormBinding(panel);
    // manually add bindings
    binding.addFieldBinding(new FieldBinding(name, "name"));
    binding.addFieldBinding(new FieldBinding(symbol, "symbol"));
    binding.addFieldBinding(new SimpleComboBoxFieldBinding(scb, "name"));

    // auto bind remaining fields, field name must match model property name
    binding.autoBind();
    binding.bind(stock);

    add(hp);
}

From source file:com.extjs.gxt.samples.client.examples.binding.GridBindingExample.java

License:Open Source License

private FormPanel createForm() {
    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);//from  w ww.j av  a 2s.  c  o  m

    TextField<String> name = new TextField<String>();
    name.setName("name");
    name.setFieldLabel("Name");
    panel.add(name);

    TextField<String> symbol = new TextField<String>();
    symbol.setName("symbol");
    symbol.setFieldLabel("Symbol");
    panel.add(symbol);

    NumberField open = new NumberField();
    open.setName("last");
    open.setFieldLabel("Last");
    panel.add(open);

    NumberField change = new NumberField();
    change.setName("change");
    change.setFieldLabel("Change");
    change.setFormat(NumberFormat.getDecimalFormat());
    panel.add(change);

    DateField last = new DateField();
    last.setName("date");
    last.setFieldLabel("Updated");
    panel.add(last);

    return panel;
}

From source file:com.extjs.gxt.ui.client.util.Format.java

License:sencha.com license

/**
 * Provides the standard decimal format for the default locale.
 * //from   w  ww.j  av a 2 s .c  o m
 * @param value the value
 * @return the value
 */
public static String decimal(double value) {
    return NumberFormat.getDecimalFormat().format(value);
}

From source file:com.extjs.gxt.ui.client.widget.form.NumberPropertyEditor.java

License:sencha.com license

public Number convertStringValue(String value) {
    // first try to create a typed value directly from the raw text
    try {// w  w w.  ja  va 2s .c o  m
        if (type == Short.class) {
            return Short.valueOf(value);
        } else if (type == Integer.class) {
            return Integer.valueOf(value);
        } else if (type == Long.class) {
            return Long.valueOf(value);
        } else if (type == Float.class) {
            return Float.valueOf(value);
        } else {
            return Double.valueOf(value);
        }
    } catch (Exception e) {
    }

    // second, stip all unwanted characters
    String stripValue = stripValue(value);
    try {
        if (type == Short.class) {
            return Short.valueOf(stripValue);
        } else if (type == Integer.class) {
            return Integer.valueOf(stripValue);
        } else if (type == Long.class) {
            return Long.valueOf(stripValue);
        } else if (type == Float.class) {
            return Float.valueOf(stripValue);
        } else {
            return Double.valueOf(stripValue);
        }
    } catch (Exception e) {
    }

    // third try parsing with the formatter
    if (format != null) {
        Double d = format.parse(value);
        return returnTypedValue(d);
    } else {
        Double d = NumberFormat.getDecimalFormat().parse(value);
        return returnTypedValue(d);
    }
}

From source file:com.gafactory.core.client.ui.BaseToolbar.java

License:Open Source License

public void setRowCount(int newRowCount) {
    rowCounterNavbarText.setVisible(true);
    rowCounter.setText(": " + NumberFormat.getDecimalFormat().format(newRowCount));
}