Package com.google.gwt.i18n.client

Examples of com.google.gwt.i18n.client.NumberFormat


    return panel;
  }

  private Grid<Stock> createGrid() {
    final NumberFormat currency = NumberFormat.getCurrencyFormat();
    final NumberFormat number = NumberFormat.getFormat("0.00");
    final NumberCellRenderer<Grid<Stock>> numberRenderer = new NumberCellRenderer<Grid<Stock>>(
        currency);

    GridCellRenderer<Stock> change = new GridCellRenderer<Stock>() {

      public String render(Stock model, String property, ColumnData config, int rowIndex,
          int colIndex, ListStore<Stock> store, Grid<Stock> grid) {
        Double val = (Double) model.get(property);
        if (val == null) {
          val = 0d;
        }
        String style = val < 0 ? "red" : "green";
        return "<span style='color:" + style + "'>" + number.format(val) + "</span>";
      }
    };

    GridCellRenderer<Stock> gridNumber = new GridCellRenderer<Stock>() {
      public String render(Stock model, String property, ColumnData config, int rowIndex,
View Full Code Here


   *
   * @param params
   * @return
   */
  protected String append(Object... params){
    NumberFormat numberFormat = NumberFormat.getFormat(Constants.NUMBER_FORMAT);
    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(Constants.DATE_FORMAT);
    String srcParam = "";
    for(Object param : params){
      if(param != null){
        if(param instanceof String){
          srcParam += param;
        }
        if(param instanceof Double){
          srcParam += numberFormat.format(((Double) param).doubleValue());
        }
        if(param instanceof Float){
          srcParam += numberFormat.format(((Float) param).floatValue());
        }
        if(param instanceof Date){
          srcParam += dateTimeFormat.format((Date)param);
        }
      } else{
View Full Code Here

    bus.addHandler(ExportFicheStEvent.TYPE, new ExportFicheStHandler() {
      @SuppressWarnings("unchecked")
      @Override
      public void onExport(ExportFicheStEvent event) {
        DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(Constants.DATE_FORMAT);
        NumberFormat numberFormat = NumberFormat.getFormat(Constants.NUMBER_FORMAT);
        // bus.fireEvent(new DeductionGridUpdateEvent(centerPanel.getDeductionDtoList()));
        // Information Generals
        String chainter = navigation.getContext().getCurrentChantier().getNom();
        ComponentManager componentManager = ComponentManager.get();
        TextField<String> societte = (TextField<String>) componentManager.get("INFORMATION_PANEL_SOCIETE_ID");
        TextField<String> lot = (TextField<String>) componentManager.get("INFORMATION_PANEL_LOT_ID");
        ComboBox<LotTypeDto> lotType = (ComboBox<LotTypeDto>) componentManager.get("INFORMATION_PANEL_LOT_TYPE_ID");
        TextField<String> sitravaux = (TextField<String>) componentManager.get("INFORMATION_PANEL_SITRAVAUX_ID");
        NumberField montant = (NumberField) componentManager.get("INFORMATION_PANEL_MONTANT_ID");
       
        // Conditions Particilifers
        ComboBox<SimpleDto> simpleDto = (ComboBox<SimpleDto>) componentManager.get("INFORMATION_PANEL_PAYMENT_ID");
        NumberField rg = (NumberField) componentManager.get("INFORMATIONAL_PANEL_RG_ID");
        ComboBox<SimpleDto> decennalenecessaire = (ComboBox<SimpleDto>) componentManager.get("INFORMATIONAL_PANEL_DECENNALENECESSAIRE_ID");
        ComboBox<SimpleDto> demandedagrement = (ComboBox<SimpleDto>) componentManager.get("INFORMATIONAL_PANEL_DEMANDEDAGREMENT_ID");
        ComboBox<SimpleDto> dgdpresente = (ComboBox<SimpleDto>) componentManager.get("INFORMATIONAL_PANEL_DGDPRESENTE_ID");
        DateField dgdpresentedate = (DateField) componentManager.get("INFORMATIONAL_PANEL_DGDPRESENTEDATE_ID");
        // Presation
        NumberField pilotage = (NumberField) componentManager.get("INFORMATIONAL_PANEL_PILOTAGE_ID");
        NumberField assurances = (NumberField) componentManager.get("INFORMATIONAL_PANEL_ASSURANCES_ID");
        NumberField prorata = (NumberField) componentManager.get("INFORMATIONAL_PANEL_PRORATE_ID");
        NumberField canto = (NumberField) componentManager.get("INFORMATIONAL_PANEL_CANTO_ID");
        NumberField badge = (NumberField) componentManager.get("INFORMATIONAL_PANEL_BADGE_ID");
        NumberField grue = (NumberField) componentManager.get("INFORMATIONAL_PANEL_GRUE_ID");
        NumberField lift = (NumberField) componentManager.get("INFORMATIONAL_PANEL_LIFT_ID");
        NumberField benne = (NumberField) componentManager.get("INFORMATIONAL_PANEL_BENNE_ID");
        NumberField netoyage = (NumberField) componentManager.get("INFORMATIONAL_PANEL_NETOYAGE_ID");
        // Information Commemlaires
        LabelField conducteur = (LabelField) componentManager.get("INFORMATIONAL_PANEL_CONDUCTEUR_ID");
        DateField dateOfMarket = (DateField) componentManager.get("INFORMATIONAL_PANEL_DATEOFMARKET_ID");
       
        List<NameValuePair> values = new ArrayList<NameValuePair>();
       
        // Add General Information
        String lotype = lotType.getValue() != null ? lotType.getValue().getName() : "";
        String generaleInformation = chainter + Constants.SEPRATE + lot.getValue() + Constants.SEPRATE + sitravaux.getValue() + Constants.SEPRATE + societte.getValue() + Constants.SEPRATE
            + lotype + Constants.SEPRATE + montant.getValue();
        values.add(new NameValuePair("generaleInformation", generaleInformation));
       
        // Add Conditions Particilifers
        String dgdpresentedate_ = dgdpresentedate.getValue() != null ? dateTimeFormat.format(dgdpresentedate.getValue()) : "null";
        String conditionsparticulieres = simpleDto.getValue().getLabel() + Constants.SEPRATE + rg.getValue() + Constants.SEPRATE + decennalenecessaire.getValue().getLabel()
            + Constants.SEPRATE + demandedagrement.getValue().getLabel() + Constants.SEPRATE + dgdpresente.getValue().getLabel() + Constants.SEPRATE + dgdpresentedate_;
       
        values.add(new NameValuePair("conditionsparticulieres", conditionsparticulieres));
        // Add Prestations
        String prestations = pilotage.getValue() + Constants.SEPRATE + assurances.getValue() + Constants.SEPRATE + prorata.getValue() + Constants.SEPRATE + canto.getValue()
            + Constants.SEPRATE + badge.getValue() + Constants.SEPRATE + grue.getValue() + Constants.SEPRATE + lift.getValue() + Constants.SEPRATE + benne.getValue() + Constants.SEPRATE
            + netoyage.getValue();
        values.add(new NameValuePair("prestations", prestations));
       
        // Add Informationa Complementaires
        String date_of_market = "null";
        if (dateOfMarket.getValue() != null) {
          date_of_market = dateTimeFormat.format(dateOfMarket.getValue());
        }
        String informationscomplementaires = conducteur.getValue() + Constants.SEPRATE + date_of_market;
        values.add(new NameValuePair("informationscomplementaires", informationscomplementaires));
       
        List<CautionFournieDto> listCautionFournieDto = centerPanel.getCautionFournieDtoList();
        String cautionFournies = "";
        String caution_date = "";
        for (CautionFournieDto cautionFournieDto : listCautionFournieDto) {
          caution_date = cautionFournieDto.getDate() != null ? dateTimeFormat.format(cautionFournieDto.getDate()) : "";
          cautionFournies += caution_date + Constants.SEPRATE + numberFormat.format(cautionFournieDto.getAmount()) + Constants.SEPRATE;
        }
        values.add(new NameValuePair("cautionFournies", cautionFournies));
       
        // Add Gestion
        List<GestionDto> listGestion = centerPanel.getGestionDtoList();
View Full Code Here

    DeductionDto deductionDto = null;
    String deductions = "";
    double amount = 0.0;
    // Grid 1
    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(Constants.DATE_FORMAT);
    NumberFormat numberFormat = NumberFormat.getFormat(Constants.NUMBER_FORMAT);
    for (int j = 0; j < listDeduction.size(); j++) {
      deductionDto = listDeduction.get(j);
      String deductionDate = deductionDto.getDate() != null ? dateTimeFormat.format(deductionDto.getDate()) : "";
      deductions += deductionDate + Constants.SEPRATE + numberFormat.format(deductionDto.getCanto()) + Constants.SEPRATE + numberFormat.format(deductionDto.getBadge()) + Constants.SEPRATE
          + numberFormat.format(deductionDto.getGrue()) + Constants.SEPRATE + numberFormat.format(deductionDto.getLift()) + Constants.SEPRATE + numberFormat.format(deductionDto.getBenne())
          + Constants.SEPRATE + numberFormat.format(deductionDto.getNettoyage()) + Constants.SEPRATE + numberFormat.format(deductionDto.getAutres()) + Constants.SEPRATE
          + numberFormat.format(deductionDto.getProrata()) + Constants.SEPRATE + numberFormat.format(deductionDto.getRefacturations()) + Constants.SEPRATE;
    }
    if (deductions != null && deductions.length() > 0)
      deductions = deductions.substring(0, deductions.length() - 1);
    values.add(new NameValuePair(ConstantClient.DEDUCTIONDTO_ID_STR, deductions.toString()));
   
View Full Code Here

    ProgressDto progressDto = null;
    String process = "";
    String totalsituation = "";
    // Grid 1
    DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(Constants.DATE_FORMAT);
    NumberFormat numberFormat = NumberFormat.getFormat(Constants.NUMBER_FORMAT);
    String process_date = "";
   
    for (int j = 0; j < list.size(); j++) {
      progressDto = list.get(j);
      process_date = progressDto.getDate() != null ? dateTimeFormat.format(progressDto.getDate()) : "";
      process += (j + 1) + Constants.SEPRATE + progressDto.getLabel() + Constants.SEPRATE + process_date + Constants.SEPRATE + numberFormat.format(progressDto.getCumule()) + Constants.SEPRATE
          + numberFormat.format(progressDto.getMois()) + Constants.SEPRATE + numberFormat.format(progressDto.getCumule2()) + Constants.SEPRATE + numberFormat.format(progressDto.getMois2())
          + Constants.SEPRATE;
    }
    if (process != null && process.length() > 0) {
      process = process.substring(0, process.length() - Constants.SEPRATE.length());
      values.add(new NameValuePair(ConstantClient.PROCESSDTO_ID_STR, process));
View Full Code Here

    private static final int MAX_PRECISION_DIGITS = 4;
    private static final String NULL_OR_NAN_FORMATTED_VALUE = MSG.view_measure_nan();

    private static NumberFormat getDefaultNumberFormat() {
        NumberFormat nf = NumberFormat.getFormat("0.0");

        return nf;
    }
View Full Code Here

        Set<String> existingStrings; // technically this *is* unused because
        int precisionDigits = 0;
        boolean scaleWithMorePrecision = true;
        String[] results = new String[values.length];
        NumberFormat nf = getDefaultNumberFormat();

        /*
         * we scale at most to MAX_PRECISION_DIGITS to allow for presentation limits
         *
         * increase the maxPrecisionDigits in the while condition
         * itself to ensure it gets done for every loop
         */
        while (scaleWithMorePrecision && (++precisionDigits <= MAX_PRECISION_DIGITS)) {
            /*
             * make the assumption that we no longer need to scale beyond this iteration
             */
            scaleWithMorePrecision = false;

            /*
             * we need to record the uniquely formatted values so we can determine
             */
            existingStrings = new HashSet<String>();
            nf = NumberFormat.getFormat(getFormat(0, precisionDigits));

            Double[] scaledValues = new Double[values.length];

            for (int i = 0; i < scaledValues.length; i++) {
                /*
                 *  For relative units apply the scale now, prior to the nf.format(), since we are not using format( Double...).
                 *  Otherwise, apply standard multi-unit scaling.
                 */
                if (MeasurementUnits.Family.RELATIVE == originalUnits.getFamily()) {
                    scaledValues[i] = MeasurementUnits.scaleUp(values[i], originalUnits);
                } else {
                    scaledValues[i] = scale(new MeasurementNumericValueAndUnits(values[i], originalUnits), targetUnits);
                }
            }

            for (int i = 0; i < results.length; i++) {
                /*
                 * JUST get the formatted value, specifically DON'T tack on the formatted units yet;
                 * we do this to see how many units we'll have to scale to afterwards (outside this
                 * while loop) to make the array of values passed to us unique
                 */
                String formatted = nf.format(scaledValues[i]);

                /*
                 * check whether formatted value was in the set or not; if it was, we have to
                 * loop, but only if we're not not already at our maximum precision
                 */
 
View Full Code Here

        // apply relative scale at presentation time
        if (targetUnits != null && MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) {
            value = MeasurementUnits.scaleUp(value, targetUnits);
        }

        NumberFormat numberFormat = NumberFormat.getFormat(getFormat(
            minimumFractionDigits != null ? minimumFractionDigits : 1,
            maximumFractionDigits != null ? maximumFractionDigits : 1));

        String formatted = numberFormat.format(value);

        return format(formatted, targetUnits);
    }
View Full Code Here

                    MSG.view_adminTopology_storageNodes_load_dataDiskUsedPercentageHover(),
                    KEY_DATA_DISK_SPACE_PERCENTAGE));

            if (loadComposite.getFreeDiskToDataSizeRatio() != null) {
                MeasurementAggregate aggregate = loadComposite.getFreeDiskToDataSizeRatio();
                NumberFormat nf = NumberFormat.getFormat("0.0");
                ListGridRecord record = new ListGridRecord();
                record.setAttribute("id", KEY_FREE_DISK_TO_DATA_SIZE_RATIO);
                record.setAttribute("name", MSG.view_adminTopology_storageNodes_load_freeDiskToDataSizeRatioName());
                record.setAttribute("hover", MSG.view_adminTopology_storageNodes_load_freeDiskToDataSizeRatioHover());
                record.setAttribute("min", nf.format(aggregate.getMin()));
                record.setAttribute("avg", nf.format(aggregate.getAvg()));
                record.setAttribute("avgFloat", aggregate.getAvg());
                record.setAttribute("max", nf.format(aggregate.getMax()));
                recordsList.add(record);
            }

            // other metrics
            recordsList.add(makeListGridRecord(loadComposite.getActuallyOwns(),
View Full Code Here

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(
        price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    Label changeWidget = (Label)stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");
View Full Code Here

TOP

Related Classes of com.google.gwt.i18n.client.NumberFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.