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:no.ovitas.compass2.web.client.components.ImportRelationTypeEditWindow.java

License:Open Source License

@Override
protected void buildGui() {

    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig(Compass2Constans.RELATION_NAME,
            Compass2Main.i18n.columnRelationName(), 180);
    configs.add(column);// ww w .  ja  va2 s . c  om

    column = new ColumnConfig(Compass2Constans.REF, Compass2Main.i18n.columnRef(), 50);
    configs.add(column);

    NumberField weightAheadField = new NumberField();
    weightAheadField.setPropertyEditorType(Double.class);
    weightAheadField.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig(Compass2Constans.WEIGHT_AHEAD, Compass2Main.i18n.columnWeightAhead(), 80);
    column.setNumberFormat(NumberFormat.getDecimalFormat());
    column.setEditor(new CellEditor(weightAheadField));
    configs.add(column);

    NumberField weightAbackField = new NumberField();
    weightAbackField.setPropertyEditorType(Double.class);
    weightAbackField.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig(Compass2Constans.WEIGHT_ABACK, Compass2Main.i18n.columnWeightAback(), 80);
    column.setNumberFormat(NumberFormat.getDecimalFormat());
    column.setEditor(new CellEditor(weightAbackField));
    configs.add(column);

    ColumnModel columnModel = new ColumnModel(configs);

    grid = new EditorGrid<RelationTypesModel>(listStore, columnModel);
    grid.setAutoExpandColumn(Compass2Constans.RELATION_NAME);
    grid.setHeight(500);
    grid.setBorders(true);
    grid.setLoadMask(true);

    listLoader.load();

    formPanel.add(grid, new FormData("100%"));

    contentPanel.add(formPanel);

    contentPanel.setButtonAlign(HorizontalAlignment.CENTER);

    finishButton = new Button(Compass2Main.i18n.buttonFinish());
    finishButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            formPanel.mask(Compass2Main.i18n.messageUpload());
            finishButton.disable();
            List<RelationTypesModel> modifiedRelationTypes = new ArrayList<RelationTypesModel>();
            for (Record r : listStore.getModifiedRecords()) {
                modifiedRelationTypes.add((RelationTypesModel) r.getModel());
            }
            compass2Service.uploadRelationTypes(modifiedRelationTypes, new AsyncCallback<Void>() {

                @Override
                public void onSuccess(Void v) {
                    formPanel.unmask();
                    hide();
                    fireWindowAccepted();
                }

                @Override
                public void onFailure(Throwable t) {
                    if (t instanceof BackEndException)
                        Compass2Main.errorMessage((BackEndException) t);
                    else
                        Compass2Main.errorMessage(t);
                }
            });

        }

    });

    contentPanel.addButton(finishButton);

    Button cancelButton = new Button(Compass2Main.i18n.buttonCancel());
    cancelButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            hide();
        }
    });

    contentPanel.addButton(cancelButton);

    add(contentPanel);
}

From source file:no.ovitas.compass2.web.client.components.RelationTypesGrid.java

License:Open Source License

protected void createGui() {
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig(Compass2Constans.EXTERNAL_ID, Compass2Main.i18n.columnId(), 90);
    configs.add(column);//  w ww .j av  a  2  s.c o  m

    column = new ColumnConfig(Compass2Constans.RELATION_NAME, Compass2Main.i18n.columnRelationName(), 280);
    configs.add(column);

    column = new ColumnConfig(Compass2Constans.REF, Compass2Main.i18n.columnRef(), 50);
    configs.add(column);

    NumberField weightAheadField = new NumberField();
    weightAheadField.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig(Compass2Constans.WEIGHT_AHEAD, Compass2Main.i18n.columnWeightAhead(), 80);
    column.setNumberFormat(NumberFormat.getDecimalFormat());
    column.setEditor(new CellEditor(weightAheadField));
    configs.add(column);

    NumberField weightAbackField = new NumberField();
    weightAbackField.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig(Compass2Constans.WEIGHT_ABACK, Compass2Main.i18n.columnWeightAback(), 80);
    column.setNumberFormat(NumberFormat.getDecimalFormat());
    column.setEditor(new CellEditor(weightAbackField));
    configs.add(column);

    ColumnModel columnModel = new ColumnModel(configs);

    grid = new EditorGrid<RelationTypesModel>(listStore, columnModel);
    grid.setAutoExpandColumn(Compass2Constans.RELATION_NAME);
    grid.setAutoExpandMax(1000);
    grid.setAutoHeight(true);
    grid.setAutoWidth(true);
    grid.setBorders(false);

    contentPanel = new ContentPanel();
    contentPanel.setHeaderVisible(false);
    contentPanel.setButtonAlign(HorizontalAlignment.CENTER);
    contentPanel.setBorders(false);
    contentPanel.setBodyBorder(false);
    contentPanel.add(grid);

    contentPanel.addButton(new Button(Compass2Main.i18n.buttonReset(), new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            listStore.rejectChanges();
        }
    }));

    contentPanel.addButton(new Button(Compass2Main.i18n.buttonSave(), new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            contentPanel.mask(Compass2Main.i18n.messageSave());
            List<Record> records = listStore.getModifiedRecords();
            List<RelationTypesModel> relationTypesModified = new ArrayList<RelationTypesModel>();
            for (Record record : records) {
                relationTypesModified.add((RelationTypesModel) record.getModel());
            }
            if (relationTypesModified.size() > 0) {
                compass2Service.updateRelationTypes(relationTypesModified, knowledgeBase,
                        new AsyncCallback<Void>() {

                            @Override
                            public void onFailure(Throwable arg0) {
                                if (arg0 instanceof BackEndException)
                                    Compass2Main.errorMessage((BackEndException) arg0);
                                else
                                    Compass2Main.errorMessage(arg0);
                                contentPanel.unmask();
                            }

                            @Override
                            public void onSuccess(Void arg0) {
                                contentPanel.unmask();
                            }

                        });
            }
            listStore.commitChanges();
        }
    }));

    add(contentPanel);

}

From source file:no.ovitas.compass2.web.client.components.SearchResultGrid.java

License:Open Source License

protected void createGui() {
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

    ColumnConfig column = new ColumnConfig(Compass2Constans.TITLE, Compass2Main.i18n.columnTitle(), 550);
    GridCellRenderer<ResultModel> titleRenderer = new GridCellRenderer<ResultModel>() {

        @Override/*w w  w .  ja v a  2 s . co  m*/
        public Object render(ResultModel model, String property, ColumnData config, int rowIndex, int colIndex,
                ListStore<ResultModel> store, Grid<ResultModel> grid) {
            Html html = new Html(
                    "<a target=\"_blank\" href=\"" + model.getHtmlLink() + "\">" + model.getTitle() + "</a>");
            return html;
        }
    };
    column.setRenderer(titleRenderer);
    configs.add(column);

    column = new ColumnConfig(Compass2Constans.SCORE, Compass2Main.i18n.columnScore(), 50);
    column.setNumberFormat(NumberFormat.getDecimalFormat());
    configs.add(column);

    ColumnModel columnModel = new ColumnModel(configs);

    Grid<ResultModel> grid = new Grid<ResultModel>(listStore, columnModel);
    // grid.setAutoExpandColumn(Compass2Constans.TITLE);
    grid.setAutoExpandMax(2000);
    grid.getView().setAutoFill(true);
    grid.getView().setForceFit(true);
    grid.setBorders(false);
    grid.setAutoHeight(true);
    // grid.setAutoWidth(true);
    add(grid);

}

From source file:org.broadleafcommerce.openadmin.client.BLCMain.java

License:Apache License

@Override
public void onModuleLoad() {

    NumericTypeFactory.registerNumericSimpleType("localDecimal", NumberFormat.getDecimalFormat(),
            SupportedFieldType.DECIMAL);
    NumericTypeFactory.registerNumericSimpleType("localMoneyDecimal", NumberFormat.getDecimalFormat(),
            SupportedFieldType.MONEY);//from  ww w .j  av  a2s  . c o  m
    NumericTypeFactory.registerNumericSimpleType("localCurrency", NumberFormat.getCurrencyFormat(),
            SupportedFieldType.MONEY);

    addPreProcessor(new UrlStructurePreProcessor());
    addPreProcessor(new UserSecurityPreProcessor());
    addPreProcessor(new EJB3ConfigurationPreProcessor());
    addPreProcessor(new WorkflowEnabledPreProcessor());
}

From source file:org.cruxframework.crux.gwt.client.NumberFormatUtil.java

License:Apache License

/**
 * Gets a NumberFormat object based on the patternString parameter. 
 * @param patternString//from  w  ww. j  a va 2  s.c o m
 * @return
 */
public static NumberFormat getNumberFormat(String patternString) {
    NumberFormat result;

    if (DECIMAL_PATTERN.equals(patternString)) {
        result = NumberFormat.getDecimalFormat();
    } else if (CURRENCY_PATTERN.equals(patternString)) {
        result = NumberFormat.getCurrencyFormat();
    } else if (PERCENT_PATTERN.equals(patternString)) {
        result = NumberFormat.getPercentFormat();
    } else if (SCIENTIFIC_PATTERN.equals(patternString)) {
        result = NumberFormat.getScientificFormat();
    } else {
        result = NumberFormat.getFormat(patternString);
    }

    return result;
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ConsumerView.java

License:Open Source License

/**
 * Sets the metric.// w  ww  .  j a va2s.c  om
 * 
 * @param m
 *            the m
 * @param result
 *            the result
 * @see org.ebayopensource.turmeric.monitoring.client.presenter.ConsumerPresenter.Display#setMetric(org.ebayopensource.turmeric.monitoring.client.model.ConsumerMetric,
 *      org.ebayopensource.turmeric.monitoring.client.model.MetricData)
 */
public void setMetric(ConsumerMetric m, MetricData result) {

    // Fill in the appropriate table with the results
    SummaryPanel panel = null;
    String date1Header = "";
    String date2Header = "";

    if (result != null) {
        String d1 = ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date1));
        String d2 = ConsoleUtil.timeFormat.format(new Date(result.getMetricCriteria().date2));
        date1Header = d1 + " + " + (result.getMetricCriteria().durationSec / (60 * 60))
                + ConsoleUtil.constants.hr();
        date2Header = d2 + " + " + (result.getMetricCriteria().durationSec / (60 * 60))
                + ConsoleUtil.constants.hr();
    }

    switch (m) {
    /* Start tables for all consumers */
    case CallVolume: {
        String[] columns = { ConsoleUtil.constants.consumers(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                rowData[0] = new Label(rd.getCriteriaInfo().getConsumerName());
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(callVolumeTable, columns, rows);
        for (int i = 1; i < callVolumeTable.getRowCount(); i++) {
            Widget w = callVolumeTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = callVolumePanel;
        break;
    }
    case Performance: {
        String[] columns = { ConsoleUtil.constants.consumers(),
                (result == null ? ConsoleUtil.constants.average()
                        : date1Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                (result == null ? ConsoleUtil.constants.average()
                        : date2Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                "% " + ConsoleUtil.constants.change() };
        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                rowData[0] = new Label(rd.getCriteriaInfo().getConsumerName());
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(performanceTable, columns, rows);
        for (int i = 1; i < performanceTable.getRowCount(); i++) {
            Widget w = performanceTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = performancePanel;
        break;
    }
    case Errors: {
        String[] columns = { ConsoleUtil.constants.consumers(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                rowData[0] = new Label(rd.getCriteriaInfo().getConsumerName());
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(errorsTable, columns, rows);
        for (int i = 1; i < errorsTable.getRowCount(); i++) {
            Widget w = errorsTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = errorsPanel;
        break;
    }
    /* End tables for all consumers */
    /* Start tables for a particular consumer */
    case TopVolume: {
        // column 0 will either be Services or Operations of a Service
        String col0 = ConsoleUtil.constants.services();
        if (result != null
                && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
            col0 = ConsoleUtil.constants.operations();
        String[] columns = { col0,
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))
                    rowData[0] = new Label(rd.getCriteriaInfo().getServiceName());
                else if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
                    rowData[0] = new Label(rd.getCriteriaInfo().getOperationName());

                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(topVolumeTable, columns, rows);
        // style the column with the names of the consumers in it
        for (int i = 1; i < topVolumeTable.getRowCount(); i++) {
            Widget w = topVolumeTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = topVolumePanel;
        break;
    }
    case LeastPerformance: {
        // column 0 will either be Services or Operations of a Service
        String col0 = ConsoleUtil.constants.services();
        if (result != null
                && result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
            col0 = ConsoleUtil.constants.operations();
        String[] columns = { col0,
                (result == null ? ConsoleUtil.constants.average()
                        : date1Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                (result == null ? ConsoleUtil.constants.average()
                        : date2Header + " " + ConsoleUtil.constants.average() + " \u00B5s"),
                "% " + ConsoleUtil.constants.change() };
        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);
                Widget[] rowData = new Widget[4];
                if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Service))
                    rowData[0] = new Label(rd.getCriteriaInfo().getServiceName());
                else if (result.getMetricResourceCriteria().resourceEntityResponseType.equals(Entity.Operation))
                    rowData[0] = new Label(rd.getCriteriaInfo().getOperationName());

                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(leastPerformanceTable, columns, rows);
        // style the column with the names of the consumers in it
        for (int i = 1; i < leastPerformanceTable.getRowCount(); i++) {
            Widget w = leastPerformanceTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = leastPerformancePanel;
        break;
    }
    case TopServiceErrors: {
        boolean isOperation = false;
        if (result != null && result.getMetricResourceCriteria() != null
                && result.getMetricResourceCriteria().resourceEntityRequests != null) {
            for (ResourceEntityRequest r : result.getMetricResourceCriteria().resourceEntityRequests) {
                if (r.resourceEntityType == Entity.Operation)
                    isOperation = true;
            }
        }
        String col0 = ConsoleUtil.constants.services();
        if (isOperation)
            col0 = ConsoleUtil.constants.operations();
        String[] columns = { col0, ConsoleUtil.constants.errors(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };
        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);

                Widget[] rowData = new Widget[5];

                if (isOperation) {
                    rowData[0] = new Label(rd.getCriteriaInfo().getOperationName());
                } else {
                    rowData[0] = new Label(rd.getCriteriaInfo().getServiceName());
                }
                String label = "undefined";
                label = (String) ConsoleUtil.constants.metricDefNamesMap()
                        .get(rd.getCriteriaInfo().getMetricName());
                rowData[1] = new Label(label);

                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[3] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[4] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(topServiceErrorsTable, columns, rows);
        // style the column with the names of the consumers in it
        for (int i = 1; i < topServiceErrorsTable.getRowCount(); i++) {
            Widget w = topServiceErrorsTable.getWidget(i, 0);
            w.addStyleName("clickable");
        }
        panel = topServiceErrorsPanel;
        break;
    }
    case TopConsumerErrors: {
        String[] columns = { ConsoleUtil.constants.errors(),
                (result == null ? ConsoleUtil.constants.count()
                        : date1Header + " " + ConsoleUtil.constants.count()),
                (result == null ? ConsoleUtil.constants.count()
                        : date2Header + " " + ConsoleUtil.constants.count()),
                "% " + ConsoleUtil.constants.change() };

        List<Widget[]> rows = new ArrayList<Widget[]>();
        if (result != null) {
            for (int i = 0; i < result.getReturnData().size(); i++) {
                MetricGroupData rd = result.getReturnData().get(i);

                Widget[] rowData = new Widget[4];
                String label = "undefined";
                label = (String) ConsoleUtil.constants.metricDefNamesMap()
                        .get(rd.getCriteriaInfo().getMetricName());

                rowData[0] = new Label(label);
                rowData[1] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount1())));
                rowData[2] = new Label(
                        NumberFormat.getDecimalFormat().format(Double.parseDouble(rd.getCount2())));
                rowData[3] = new Label(rd.getDiff());
                rows.add(rowData);
            }
        }

        setTabularData(topConsumerErrorsTable, columns, rows);
        panel = topConsumerErrorsPanel;
        break;
    }
    /* End tables for particular Consumer */
    }
    if (result != null && result.getReturnData() != null && panel != null) {
        int rows = result.getReturnData().size() + 1;
        double height = 0;
        if (rows > 10)
            height = 10 * 2.5;
        else
            height = rows * 2.5;
        panel.setContentContainerHeight(String.valueOf(height) + "em");
    }

    if (panel != null) {
        if (result != null)
            panel.setInfo(result.getRestUrl());
        show(panel);
    }
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ErrorView.java

License:Open Source License

/**
 * @param errorData/*  ww w  .  j  a v a 2 s  . c  om*/
 */
private void setErrorTableData(FlexTable table, ErrorMetricData errorData) {
    /*
     * Columns: error Id, error Name, Error Count: date1, date2 Error to Call Ratio: date1, date2
     */
    if (errorData == null)
        return;

    String d1 = formatDateAndDuration(errorData.getMetricCriteria().date1,
            errorData.getMetricCriteria().durationSec);
    String d2 = formatDateAndDuration(errorData.getMetricCriteria().date2,
            errorData.getMetricCriteria().durationSec);

    table.clear();
    table.removeAllRows();
    table.setWidget(0, 2, new Label(ConsoleUtil.constants.count()));
    table.getFlexCellFormatter().setColSpan(0, 2, 2);
    table.getRowFormatter().addStyleName(0, "tbl-header1");
    table.setWidget(0, 3, new Label(ConsoleUtil.constants.errorsToCalls()));
    table.getFlexCellFormatter().setColSpan(0, 3, 2);
    table.setWidget(1, 0, new Label(ConsoleUtil.constants.error()));
    table.setWidget(1, 1, new Label(ConsoleUtil.constants.name()));
    table.setWidget(1, 2, new Label(d1));
    table.setWidget(1, 3, new Label(d2));
    table.setWidget(1, 4, new Label(d1));
    table.setWidget(1, 5, new Label(d2));
    table.getRowFormatter().addStyleName(1, "tbl-header1");

    if (errorData.getReturnData() == null)
        return;
    int i = 2;
    for (ErrorViewData evd : errorData.getReturnData()) {
        Label id = new Label(evd.getErrorId());
        id.addStyleName("clickable");
        table.setWidget(i, 0, id);
        Label name = new Label(evd.getErrorName());
        name.addStyleName("clickable");
        table.setWidget(i, 1, name);
        try {
            table.setWidget(i, 2,
                    new Label(NumberFormat.getDecimalFormat().format(Long.valueOf(evd.getErrorCount1()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 2, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 3,
                    new Label(NumberFormat.getDecimalFormat().format(Long.valueOf(evd.getErrorCount2()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 3, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 4, new Label(
                    NumberFormat.getDecimalFormat().format(Double.valueOf(evd.getErrorCallRatio1()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 4, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 5, new Label(
                    NumberFormat.getDecimalFormat().format(Double.valueOf(evd.getErrorCallRatio2()))));
        } catch (NumberFormatException e) {
            table.setWidget(i, 5, new Label(ConsoleUtil.constants.error()));
        }
        i++;
    }
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ErrorView.java

License:Open Source License

private void setErrorDetailTableData(FlexTable table, ErrorMetricData errorData) {
    /*/*from w  w w.  ja  v a  2s .co  m*/
     * Columns: Consumer Name, Error Count: date1, date2 Error to Call Ratio: date1, date2
     */
    if (errorData == null)
        return;

    String d1 = formatDateAndDuration(errorData.getMetricCriteria().date1,
            errorData.getMetricCriteria().durationSec);
    String d2 = formatDateAndDuration(errorData.getMetricCriteria().date2,
            errorData.getMetricCriteria().durationSec);
    table.clear();
    table.setWidget(0, 1, new Label(ConsoleUtil.constants.count()));
    table.getFlexCellFormatter().setColSpan(0, 1, 2);
    table.setWidget(0, 2, new Label(ConsoleUtil.constants.errorsToCalls()));
    table.getRowFormatter().addStyleName(0, "tbl-header1");
    table.getFlexCellFormatter().setColSpan(0, 2, 2);
    table.setWidget(1, 0, new Label(ConsoleUtil.constants.consumers()));
    table.setWidget(1, 1, new Label(d1));
    table.setWidget(1, 2, new Label(d2));
    table.setWidget(1, 3, new Label(d1));
    table.setWidget(1, 4, new Label(d2));
    table.getRowFormatter().addStyleName(1, "tbl-header1");
    if (errorData.getReturnData() == null)
        return;

    int i = 2;
    for (ErrorViewData evd : errorData.getReturnData()) {
        Label str = new Label(evd.getConsumer());
        str.addStyleName("clickable");
        table.setWidget(i, 0, str);

        try {
            table.setWidget(i, 1, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCount1())));
        } catch (NumberFormatException e) {
            table.setWidget(i, 1, new Label(ConsoleUtil.constants.error()));
        }

        try {
            table.setWidget(i, 2, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCount2())));
        } catch (NumberFormatException e) {
            table.setWidget(i, 2, new Label(ConsoleUtil.constants.error()));
        }

        try {
            table.setWidget(i, 3, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCallRatio1())));
        } catch (NumberFormatException e) {
            table.setWidget(i, 3, new Label(ConsoleUtil.constants.error()));
        }
        try {
            table.setWidget(i, 4, new Label(NumberFormat.getDecimalFormat().format(evd.getErrorCallRatio2())));
        } catch (NumberFormatException e) {
            table.setWidget(i, 4, new Label(ConsoleUtil.constants.error()));
        }
        i++;
    }
}

From source file:org.ebayopensource.turmeric.monitoring.client.view.ServiceView.java

License:Open Source License

/**
 * Sets the tabular data./*from   www  .jav  a 2  s  .co m*/
 * 
 * @param table
 *            the table
 * @param cols
 *            the cols
 * @param rows
 *            the rows
 * @param rowStyles
 *            the row styles
 */
protected void setTabularData(FlexTable table, String[] cols, List<String[]> rows, String[] rowStyles) {
    table.removeAllRows();
    table.setText(0, 0, cols[0]);
    table.setText(0, 1, cols[1]);// flip flop dates - this is needed to fix
                                 // the % change sign error!!!
    table.setText(0, 2, cols[2]);// flip flop dates - this is needed to fix
                                 // the % change sign error!!!
    table.setText(0, 3, cols[3]);
    table.getRowFormatter().addStyleName(0, "tbl-header1");

    if (rows != null) {
        int i = 0;
        for (String[] row : rows) {
            i++;
            Label l = new Label(row[0]);
            table.setWidget(i, 0, l);
            // table.getCellFormatter().setWidth(i, 0, "30%");
            if (rowStyles != null && 0 < rowStyles.length && rowStyles[0] != null)
                l.addStyleName(rowStyles[0]);

            l = new Label(NumberFormat.getDecimalFormat().format(new Double(row[1])));
            table.setWidget(i, 1, l);
            table.getCellFormatter().setWidth(i, 1, "25%");
            if (rowStyles != null && 1 < rowStyles.length && rowStyles[1] != null)
                l.addStyleName(rowStyles[1]);

            l = new Label(NumberFormat.getDecimalFormat().format(new Double(row[2])));
            table.setWidget(i, 2, l);
            table.getCellFormatter().setWidth(i, 2, "25%");
            if (rowStyles != null && 2 < rowStyles.length && rowStyles[2] != null)
                l.addStyleName(rowStyles[2]);
            l = new Label(row[3]);
            table.setWidget(i, 3, l);
            table.getCellFormatter().setWidth(i, 3, "15%");
            if (rowStyles != null && 3 < rowStyles.length && rowStyles[3] != null)
                l.addStyleName(rowStyles[3]);
        }

    }
}

From source file:org.eclipse.che.ide.extension.builder.client.build.BuildController.java

License:Open Source License

/** Returns waitingTimeLimit {@link BuilderMetric}. */
@Nullable/* www . j  a  v a  2  s  . c  o  m*/
public BuilderMetric getLastBuildTimeoutThreshold() {
    if (lastBuildTaskDescriptor == null) {
        return null;
    }
    BuilderMetric waitingTimeLimit = getBuilderMetric(BuilderMetric.TERMINATION_TIME);
    if (waitingTimeLimit != null) {
        double terminationTime = NumberFormat.getDecimalFormat().parse(waitingTimeLimit.getValue());
        final double terminationTimeout = terminationTime - System.currentTimeMillis();
        if (terminationTimeout < 0) {
            return null;
        }
        final String value = StringUtils.timeMlsToHumanReadable((long) terminationTimeout);
        return dtoFactory.createDto(BuilderMetric.class).withDescription(waitingTimeLimit.getDescription())
                .withName(waitingTimeLimit.getName()).withValue(value);
    }
    return null;
}