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

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

Introduction

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

Prototype

public static NumberFormat getFormat(String pattern) 

Source Link

Document

Gets a NumberFormat instance for the default locale using the specified pattern and the default currencyCode.

Usage

From source file:com.wcs.wcslib.vaadin.widget.multifileupload.client.UploadClientUtil.java

License:Apache License

public static String getHumanReadableByteCount(long bytes, boolean si) {
    int unit = si ? 1000 : 1024;
    if (bytes < unit) {
        return bytes + " B";
    }/* ww w  .j a v  a 2 s. c  o m*/
    int exp = (int) (Math.log(bytes) / Math.log(unit));
    String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");

    //return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
    return NumberFormat.getFormat("#.0").format(bytes / Math.pow(unit, exp)) + " " + pre + "B";
}

From source file:com.webgocommerce.client.view.uirventrada.UIrvEntrada.java

private void initListener() {
    btnAfectoIgv.addClickHandler(this);
    btnNoAfectoIgv.addClickHandler(this);
    uiSearchCliente.btnBuscar.addClickHandler(this);
    uiControlVenta.btnGenerar.addKeyUpHandler(this);
    uiControlVenta.btnGenerar.addClickHandler(this);
    uiControlVenta.btnAgregar.addKeyUpHandler(this);
    uiControlVenta.btnAgregar.addClickHandler(this);
    uiControlVenta.btnQuitar.addKeyUpHandler(this);
    uiControlVenta.btnNuevo.addKeyUpHandler(this);
    uiControlVenta.btnQuitar.addClickHandler(this);
    uiControlVenta.btnNuevo.addClickHandler(this);
    uiInfoDoc.lstTipoDoc.addChangeHandler(this);
    uiInfoDoc.lstTipoDoc.addBlurHandler(this);
    uiInfoDoc.lstTipoDoc.addKeyUpHandler(this);
    uiInfoDoc.lstSerieCorre.addChangeHandler(this);
    uiInfoDoc.lstSerieCorre.addKeyUpHandler(this);
    uiInfoDoc.lstSerieCorre.addBlurHandler(this);
    uiInfoMoneda.lstMoneda.addKeyUpHandler(this);
    uiSearchCliente.txtRucFacturacion.addKeyUpHandler(this);
    uiSearchCliente.txtRucFacturacion.addBlurHandler(this);
    uiControlVenta.txtPrecio.txtInputPrecio.addKeyUpHandler(this);
    uiControlVenta.txtPrecio.btnCombo.addClickHandler(this);
    uiControlVenta.txtCantidad.addKeyUpHandler(this);
    uiSearch.txtBuscar.addKeyUpHandler(this);
    uiSearch.btnRefrescar.addClickHandler(this);
    uiStockItemAlm.getGridItem().addHandler(this, KeyUpEvent.getType());
    uiGridDetalleVenta.grid.addHandler(this, KeyUpEvent.getType());
    uiControlVenta.txtPrecio.gridPrecioItem.addHandler(this, KeyUpEvent.getType());
    uiStockItemAlm.getGridItem().getSelectionModel()
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
                public void onSelectionChange(SelectionChangeEvent event) {
                    beanItem = uiStockItemAlm.getGridItem().getSelectionModel().getSelectedObject();
                    cleanPrecioCantidad();
                }//from w  ww  . j a v a 2  s .co  m
            });
    uiControlVenta.txtPrecio.gridPrecioItem.getSelectionModel()
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
                public void onSelectionChange(SelectionChangeEvent event) {
                    if (uiControlVenta.txtPrecio.gridPrecioItem.getSelectionModel()
                            .getSelectedObject() != null) {
                        beanPrecioItem = uiControlVenta.txtPrecio.gridPrecioItem.getSelectionModel()
                                .getSelectedObject();
                        uiControlVenta.txtPrecio.txtInputPrecio
                                .setText(beanPrecioItem.getDescripcion() + " | " + NumberFormat
                                        .getFormat("#########.##").format(beanPrecioItem.getPrecioVenta()));
                        uiControlVenta.txtPrecio.hidePopup();
                        uiControlVenta.txtPrecio.txtInputPrecio.setFocus(true);
                    }
                }
            });

}

From source file:com.webgocommerce.client.view.uirventrada.UIrvEntradaImpl.java

@Override
public void calcularMontoTotales() {
    resetMontoTotales();//  www.j a  v  a2  s.c  o  m
    Iterator<DetalleVentaProxy> iterador = uiGridDetalleVenta.grid.getData().iterator();
    while (iterador.hasNext()) {
        DetalleVentaProxy bean = iterador.next();
        montoTotalAfecto = montoTotalAfecto.add(bean.getMontoAfecto());
        montoTotalNoAfecto = montoTotalNoAfecto.add(bean.getMontoNoAfecto());
        montoTotalIgv = montoTotalIgv.add(bean.getMontoIgv());
        montoTotalPercepcion = montoTotalPercepcion.add(bean.getMontoPercepcion());
        montoTotalaPagar = montoTotalaPagar.add(bean.getTotalNeto());
        montoTotalPlan = bean.getPrecioPlan().multiply(bean.getCantidad()).add(montoTotalPlan);
        Iterator<ItemPlanProxy> iter = bean.getEquipos().iterator();
        while (iter.hasNext()) {
            montoTotalEquipos = montoTotalEquipos.add(iter.next().getTotal());
        }
    }
    uiDocMonto.txtAfecto.setText(NumberFormat.getFormat("#########.##").format(montoTotalAfecto));
    uiDocMonto.txtNoAfecto.setText(NumberFormat.getFormat("#########.##").format(montoTotalNoAfecto));
    uiDocMonto.txtIgv.setText(NumberFormat.getFormat("#########.##").format(montoTotalIgv));
    uiDocMonto.txtPercepcion.setText(NumberFormat.getFormat("#########.##").format(montoTotalPercepcion));
    uiDocMonto.txtTotal.setText(NumberFormat.getFormat("#########.##").format(montoTotalaPagar));
    uiDocMonto.txtTotalPlan.setText(NumberFormat.getFormat("#########.##").format(montoTotalPlan));
}

From source file:com.webgocommerce.client.view.uirvsalida.UIrvSalidaImpl.java

@Override
public void loadField() {
    uiSearchCliente.txtRucFacturacion.setText(formParent.getBeanCliente().getRuc());
    uiSearchCliente.txtDescripcionFacturacion.setText(formParent.getBeanCliente().getNombres());
    uiInfoDoc.lstTipoDoc.addItem(formParent.getBeanCorrelativo().getNombreDocumento());
    uiInfoDoc.lstSerieCorre.addItem(formParent.getBeanCorrelativo().getSerie());
    uiInfoDoc.txtPreImpreso.setText(formParent.getBeanCorrelativo().getPreimpreso());
    uiInfoMoneda.lstMoneda.setSelectedIndex(formParent.getUiInfoMoneda().lstMoneda.getSelectedIndex());
    txtPlan.setText(NumberFormat.getFormat("#########.##").format(formParent.getMontoTotalaPagar()));
    txtEquipos.setText(NumberFormat.getFormat("#########.##").format(formParent.getMontoTotalEquipos()));
}

From source file:com.webgocommerce.client.view.uivdentrada.UIvdEntrada.java

private void initListener() {
    btnAfectoIgv.addClickHandler(this);
    btnNoAfectoIgv.addClickHandler(this);
    uiSearchCliente.btnBuscar.addClickHandler(this);
    uiControlVenta.btnGenerar.addKeyUpHandler(this);
    uiControlVenta.btnGenerar.addClickHandler(this);
    uiControlVenta.btnAgregar.addKeyUpHandler(this);
    uiControlVenta.btnAgregar.addClickHandler(this);
    uiControlVenta.btnQuitar.addKeyUpHandler(this);
    uiControlVenta.btnNuevo.addKeyUpHandler(this);
    uiControlVenta.btnQuitar.addClickHandler(this);
    uiControlVenta.btnNuevo.addClickHandler(this);
    uiInfoDoc.lstTipoDoc.addChangeHandler(this);
    uiInfoDoc.lstTipoDoc.addBlurHandler(this);
    uiInfoDoc.lstTipoDoc.addKeyUpHandler(this);
    uiInfoDoc.lstSerieCorre.addChangeHandler(this);
    uiInfoDoc.lstSerieCorre.addKeyUpHandler(this);
    uiInfoDoc.lstSerieCorre.addBlurHandler(this);
    uiInfoMoneda.lstMoneda.addKeyUpHandler(this);
    uiSearchCliente.txtRucFacturacion.addKeyUpHandler(this);
    uiSearchCliente.txtRucFacturacion.addBlurHandler(this);
    uiControlVenta.txtPrecio.txtInputPrecio.addKeyUpHandler(this);
    uiControlVenta.txtPrecio.btnCombo.addClickHandler(this);
    uiControlVenta.txtCantidad.addKeyUpHandler(this);
    uiSearch.txtBuscar.addKeyUpHandler(this);
    uiSearch.btnRefrescar.addClickHandler(this);
    //uiStockItemAlm.getGridItem().addHandler(this, ClickEvent.getType());
    uiStockItemAlm.getGridItem().addHandler(this, KeyUpEvent.getType());
    uiGridDetalleVenta.grid.addHandler(this, KeyUpEvent.getType());
    uiControlVenta.txtPrecio.gridPrecioItem.addHandler(this, KeyUpEvent.getType());
    uiStockItemAlm.getGridAlmacen().addHandler(this, KeyUpEvent.getType());
    uiStockItemAlm.getGridItem().getSelectionModel()
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
                public void onSelectionChange(SelectionChangeEvent event) {
                    if (uiStockItemAlm.getGridItem().getSelectionModel().getSelectedObject() != null
                            || !uiStockItemAlm.getGridItem().getSelectionModel().getSelectedObject().getUbica()
                                    .isEmpty()
                            || uiStockItemAlm.getGridItem().getSelectionModel().getSelectedObject()
                                    .getUbica() != null) {
                        beanItem = uiStockItemAlm.getGridItem().getSelectionModel().getSelectedObject();
                        loadAlmacen();/*from   w  w w  .  j av  a2  s . c o  m*/
                        cleanPrecioCantidad();
                    }
                }
            });
    uiStockItemAlm.getGridAlmacen().getSelectionModel()
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
                public void onSelectionChange(SelectionChangeEvent event) {
                    if (uiStockItemAlm.getGridAlmacen().getSelectionModel().getSelectedObject() != null) {
                        beanAlmacen = uiStockItemAlm.getGridAlmacen().getSelectionModel().getSelectedObject();
                        uiControlVenta.txtCantidad.setFocus(true);
                        uiControlVenta.txtCantidad.selectAll();
                    }
                }
            });
    uiControlVenta.txtPrecio.gridPrecioItem.getSelectionModel()
            .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
                public void onSelectionChange(SelectionChangeEvent event) {
                    if (uiControlVenta.txtPrecio.gridPrecioItem.getSelectionModel()
                            .getSelectedObject() != null) {
                        beanPrecioItem = uiControlVenta.txtPrecio.gridPrecioItem.getSelectionModel()
                                .getSelectedObject();
                        uiControlVenta.txtPrecio.txtInputPrecio
                                .setText(beanPrecioItem.getDescripcion() + " | " + NumberFormat
                                        .getFormat("#########.##").format(beanPrecioItem.getPrecioVenta()));
                        uiControlVenta.txtPrecio.hidePopup();
                        uiControlVenta.txtPrecio.txtInputPrecio.setFocus(true);
                    }
                }
            });

}

From source file:com.webgocommerce.client.view.uivdentrada.UIvdEntradaImpl.java

@Override
public void calcularMontoTotales() {
    resetMontoTotales();//from w w  w .ja  va2 s. co m
    Iterator<DetalleVentaProxy> iterador = uiGridDetalleVenta.grid.getData().iterator();
    while (iterador.hasNext()) {
        DetalleVentaProxy bean = iterador.next();
        montoTotalAfecto = montoTotalAfecto.add(bean.getMontoAfecto());
        montoTotalNoAfecto = montoTotalNoAfecto.add(bean.getMontoNoAfecto());
        montoTotalIgv = montoTotalIgv.add(bean.getMontoIgv());
        montoTotalPercepcion = montoTotalPercepcion.add(bean.getMontoPercepcion());
        montoTotalaPagar = montoTotalaPagar.add(bean.getTotalNeto());
    }
    uiDocMonto.txtAfecto.setText(NumberFormat.getFormat("#########.##").format(montoTotalAfecto));
    uiDocMonto.txtNoAfecto.setText(NumberFormat.getFormat("#########.##").format(montoTotalNoAfecto));
    uiDocMonto.txtIgv.setText(NumberFormat.getFormat("#########.##").format(montoTotalIgv));
    uiDocMonto.txtPercepcion.setText(NumberFormat.getFormat("#########.##").format(montoTotalPercepcion));
    uiDocMonto.txtTotal.setText(NumberFormat.getFormat("#########.##").format(montoTotalaPagar));
}

From source file:com.webgocommerce.client.view.uivdsalida.UIvdSalidaImpl.java

@Override
public void loadField() {
    //uiSearchCliente.txtRucFacturacion.setText(formParent.getBeanCliente().getDni());
    if (formParent.getBeanCorrelativo().getIdDocumento().equalsIgnoreCase("01")
            || formParent.getBeanCorrelativo().getIdDocumento().equalsIgnoreCase("31")) {
        uiSearchCliente.txtRucFacturacion.setText(formParent.getBeanCliente().getRuc());
        uiSearchCliente.txtDescripcionFacturacion.setText(formParent.getBeanCliente().getNombres());
    } else {//from   w  ww  .j  ava  2s . c o  m
        uiSearchCliente.txtRucFacturacion.setText(formParent.getBeanCliente().getDni());
        uiSearchCliente.txtDescripcionFacturacion.setText(formParent.getBeanCliente().getNombres());
    }
    uiInfoDoc.lstTipoDoc.addItem(formParent.getBeanCorrelativo().getNombreDocumento());
    uiInfoDoc.lstSerieCorre.addItem(formParent.getBeanCorrelativo().getSerie());
    uiInfoDoc.txtPreImpreso.setText(formParent.getBeanCorrelativo().getPreimpreso());
    uiInfoMoneda.lstMoneda.setSelectedIndex(formParent.getUiInfoMoneda().lstMoneda.getSelectedIndex());
    txtAcobrar.setText(NumberFormat.getFormat("#########.##").format(formParent.getMontoTotalaPagar()));
    txtRecibido.setText(recibido.toString());
    txtVuelto.setText(NumberFormat.getFormat("#########.##").format(vuelto));
}

From source file:com.webgocommerce.client.view.uivdsalida.UIvdSalidaImpl.java

@Override
public void calcularVuelto() {
    recibido = BigDecimal.valueOf(Double.parseDouble(txtRecibido.getText()));
    BigDecimal aCobrar = formParent.getMontoTotalaPagar();
    vuelto = recibido.subtract(aCobrar);
    txtVuelto.setText(NumberFormat.getFormat("#########.##").format(vuelto));
    if (vuelto.compareTo(BigDecimal.ZERO) == -1) {
        txtVuelto.getElement().getStyle().setBackgroundColor("red");
        txtVuelto.getElement().getStyle().setColor("white");
    } else {/*from  w  w  w.j a v a  2 s  .com*/
        txtVuelto.getElement().getStyle().setBackgroundColor("green");
        txtVuelto.getElement().getStyle().setColor("white");
    }
}

From source file:com.xyz.customer.client.mvc.CusMainView.java

License:Open Source License

public CusMainView() {
    final NumberFormat currency = NumberFormat.getCurrencyFormat();
    final NumberFormat number = NumberFormat.getFormat("0.00");
    final NumberCellRenderer<Grid<CusModel>> numberRenderer = new NumberCellRenderer<Grid<CusModel>>(currency);

    msg = (CusMessages) Registry.get(Customer.MESSAGE);

    statusRen = new GridCellRenderer<CusModel>() {
        public String render(CusModel model, String property, ColumnData config, int rowIndex, int colIndex,
                ListStore<CusModel> store, Grid<CusModel> grid) {
            String val = (String) model.get(property);
            String sta = ZkbConstants.get().getStatus(val);
            return sta;
        }/*from  ww w.ja v  a2 s  . c  o  m*/
    };

    gridNumber = new GridCellRenderer<CusModel>() {
        public String render(CusModel model, String property, ColumnData config, int rowIndex, int colIndex,
                ListStore<CusModel> store, Grid<CusModel> grid) {
            return numberRenderer.render(null, property, model.get(property));
        }
    };

    panel = new ContentPanel();
    panel.setHeaderVisible(false);
}

From source file:com.xyz.stock.client.view.OnsaleItemView.java

License:Open Source License

public OnsaleItemView() {
    service = (ProductServiceAsync) Registry.get(Stock.PRODSERVICE);
    final NumberFormat currency = NumberFormat.getCurrencyFormat();
    final NumberFormat number = NumberFormat.getFormat("0.00");
    final NumberCellRenderer<Grid<BeanModel>> numberRenderer = new NumberCellRenderer<Grid<BeanModel>>(
            currency);/*from   w  w  w. j av  a 2  s  .c  o  m*/
    msg = (StockMessages) Registry.get(Stock.MESSAGE);

    statusRen = new GridCellRenderer<BeanModel>() {
        public String render(BeanModel model, String property, ColumnData config, int rowIndex, int colIndex,
                ListStore<BeanModel> store, Grid<BeanModel> grid) {
            String val = (String) model.get(property);
            String sta = ZkbConstants.get().getStatus(val);
            return sta;
        }
    };

    gridNumber = new GridCellRenderer<BeanModel>() {
        public String render(BeanModel model, String property, ColumnData config, int rowIndex, int colIndex,
                ListStore<BeanModel> store, Grid<BeanModel> grid) {
            return numberRenderer.render(null, property, model.get(property));
        }
    };

    panel = new ContentPanel();
    panel.setHeaderVisible(false);
    panel.setLayout(new RowLayout());
}