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:org.kie.workbench.common.forms.jbpm.client.rendering.util.DocumentSizeHelper.java

License:Apache License

public static String getFormattedDocumentSize(double size) {
    String result = "";

    int position;

    for (position = 0; position < SIZE_UNITS.length && size > 1024; position++) {
        size = size / 1024;//from   www  .ja va2s .  com
    }

    result = NumberFormat.getDecimalFormat().format(size) + " " + SIZE_UNITS[position];

    return result;
}

From source file:org.opencms.ade.upload.client.ui.A_CmsUploadDialog.java

License:Open Source License

/**
 * Formats a given bytes value (file size).<p>
 *  //from ww  w .  j  a v a  2  s . c  o  m
 * @param filesize the file size to format
 * 
 * @return the formated file size in KB
 */
protected String formatBytes(long filesize) {

    double kByte = Math.ceil(filesize / KILOBYTE);
    String formated = NumberFormat.getDecimalFormat().format(new Double(kByte));
    return formated + " KB";
}

From source file:org.opencms.gwt.client.ui.input.upload.CmsUploadButton.java

License:Open Source License

/**
 * Formats a given bytes value (file size).<p>
 *
 * @param filesize the file size to format
 *
 * @return the formated file size in KB//from  www.  ja  va2 s. c om
 */
public static String formatBytes(long filesize) {

    double kByte = Math.ceil(filesize / KILOBYTE);
    String formated = NumberFormat.getDecimalFormat().format(new Double(kByte));
    return formated + " KB";
}

From source file:org.openempi.webapp.client.mvc.configuration.MatchConfigurationParametersView.java

License:Apache License

private void initUI() {
    long time = new java.util.Date().getTime();
    GWT.log("Initializing the UI ", null);

    controller.handleEvent(new AppEvent(AppEvents.MatchConfigurationParametersRequest));

    container = new LayoutContainer();
    container.setLayout(new CenterLayout());

    ContentPanel cp = new ContentPanel();
    cp.setHeading("Match Parameter Settings");
    cp.setFrame(true);/*from  w  w  w.j  a v a 2 s  .  c  o m*/
    cp.setIcon(IconHelper.create("images/table_gear.png"));
    FormLayout formLayout = new FormLayout();
    formLayout.setLabelWidth(190);
    formLayout.setDefaultWidth(190);
    cp.setLayout(formLayout);
    //      cp.setLayout(new FillLayout());
    cp.setSize(400, 320);

    falseNegativeProbabilityEdit.setFieldLabel("False negative Prob.");
    falseNegativeProbabilityEdit.setAllowBlank(false);
    falseNegativeProbabilityEdit.setAllowNegative(false);
    falseNegativeProbabilityEdit.setMaxValue(1.0);
    falseNegativeProbabilityEdit.setFormat(NumberFormat.getDecimalFormat());
    cp.add(falseNegativeProbabilityEdit);

    falsePositiveProbabilityEdit.setFieldLabel("False positive Prob.");
    falsePositiveProbabilityEdit.setAllowBlank(false);
    falsePositiveProbabilityEdit.setAllowNegative(false);
    falsePositiveProbabilityEdit.setMaxValue(1.0);
    falsePositiveProbabilityEdit.setFormat(NumberFormat.getDecimalFormat());
    cp.add(falsePositiveProbabilityEdit);

    mInitialEdit.setFieldLabel("M Initial");
    mInitialEdit.setAllowBlank(false);
    mInitialEdit.setAllowNegative(false);
    mInitialEdit.setMaxValue(1.0);
    mInitialEdit.setFormat(NumberFormat.getDecimalFormat());
    cp.add(mInitialEdit);

    uInitialEdit.setFieldLabel("U Initial");
    uInitialEdit.setAllowBlank(false);
    uInitialEdit.setAllowNegative(false);
    uInitialEdit.setMaxValue(1.0);
    uInitialEdit.setFormat(NumberFormat.getDecimalFormat());
    cp.add(uInitialEdit);

    pInitialEdit.setFieldLabel("P Initial");
    pInitialEdit.setAllowBlank(false);
    pInitialEdit.setAllowNegative(false);
    pInitialEdit.setMaxValue(1.0);
    pInitialEdit.setFormat(NumberFormat.getDecimalFormat());
    cp.add(pInitialEdit);

    convergenceErrorEdit.setFieldLabel("Convergence Error");
    convergenceErrorEdit.setAllowBlank(false);
    convergenceErrorEdit.setAllowNegative(false);
    convergenceErrorEdit.setMaxValue(1.0);
    convergenceErrorEdit.setFormat(NumberFormat.getScientificFormat());
    cp.add(convergenceErrorEdit);

    maxIterationsEdit.setFieldLabel("Max Iterations");
    maxIterationsEdit.setAllowBlank(false);
    maxIterationsEdit.setAllowNegative(false);
    maxIterationsEdit.setMinValue(1);
    cp.add(maxIterationsEdit);

    maxTriesEdit.setFieldLabel("Max Tries");
    maxTriesEdit.setAllowBlank(false);
    maxTriesEdit.setAllowNegative(false);
    maxTriesEdit.setMinValue(1);
    cp.add(maxTriesEdit);

    LayoutContainer c = new LayoutContainer();
    HBoxLayout layout = new HBoxLayout();
    layout.setPadding(new Padding(5));
    layout.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
    layout.setPack(BoxLayoutPack.CENTER);
    c.setLayout(layout);

    HBoxLayoutData layoutData = new HBoxLayoutData(new Margins(0, 5, 0, 0));

    Integer wizardMode = (Integer) Registry.get(Constants.WIZARD_MODE);
    boolean inWizardMode = (wizardMode == Constants.RECORD_LINKAGE_WIZARD_MODE);
    AdminConfigurationWeb adminConfiguration = (AdminConfigurationWeb) Registry
            .get(Constants.ADMIN_CONFIGURATION);
    ComponentTypeWeb componentType = adminConfiguration.getComponentMode();

    if (inWizardMode) {
        Button previousButton = new Button(Constants.PREVIOUS_PAGE_WIZARD_BUTTON_TEXT,
                IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() {
                    @Override
                    public void componentSelected(ButtonEvent ce) {
                        Button sourceButton = ce.getButton();
                        MatchConfigurationParametersView matchConfigurationParametersView = (MatchConfigurationParametersView) sourceButton
                                .getData("this");
                        matchConfigurationParametersView.saveConfiguration();
                        Boolean inWizard = (Boolean) sourceButton.getData("inWizardMode");
                        if (inWizard)
                            Dispatcher.get().dispatch(AppEvents.MatchFieldConfigurationView);
                    }
                });
        previousButton.setData("this", this);
        previousButton.setData("inWizardMode", inWizardMode);
        c.add(previousButton, layoutData);
    }

    Button saveButton = new Button(
            inWizardMode ? Constants.NEXT_PAGE_WIZARD_BUTTON_TEXT : Constants.SAVE_BUTTON_TEXT,
            IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() {
                @Override
                public void componentSelected(ButtonEvent ce) {
                    Button sourceButton = ce.getButton();
                    MatchConfigurationParametersView matchConfigurationParametersView = (MatchConfigurationParametersView) sourceButton
                            .getData("this");
                    matchConfigurationParametersView.saveConfiguration();
                    Boolean inWizard = (Boolean) sourceButton.getData("inWizardMode");
                    ComponentTypeWeb componentTyp = (ComponentTypeWeb) sourceButton.getData("componentType");
                    if (inWizard) {
                        if (componentTyp == AdminConfigurationWeb.ComponentTypeWeb.DATA_INTEGRATOR_MODE)
                            Dispatcher.get().dispatch(AppEvents.MatchView);
                        else if (componentTyp == AdminConfigurationWeb.ComponentTypeWeb.DATA_PROVIDER_MODE)
                            Dispatcher.get().dispatch(AppEvents.DatasetListView);
                    }
                }
            });
    saveButton.setData("this", this);
    saveButton.setData("inWizardMode", inWizardMode);
    saveButton.setData("componentType", componentType);
    c.add(saveButton, layoutData);

    if (inWizardMode) {
        Button exitButton = new Button(Constants.EXIT_WIZARD_BUTTON_TEXT,
                IconHelper.create("images/folder_delete.png"), new SelectionListener<ButtonEvent>() {
                    @Override
                    public void componentSelected(ButtonEvent ce) {
                        Dispatcher.get().dispatch(AppEvents.ExitWizardSelected);
                    }
                });
        exitButton.setData("this", this);
        c.add(exitButton, layoutData);
    }

    cp.setBottomComponent(c);

    container.add(cp);

    LayoutContainer wrapper = (LayoutContainer) Registry.get(Constants.CENTER_PANEL);
    wrapper.removeAll();
    wrapper.add(container);
    wrapper.layout();
    GWT.log("Done Initializing the UI in " + (new java.util.Date().getTime() - time), null);
}

From source file:org.openempi.webapp.client.mvc.configuration.MatchFieldConfigurationView.java

License:Apache License

@SuppressWarnings("unchecked")
private void initUI() {
    long time = new java.util.Date().getTime();
    GWT.log("Initializing the UI ", null);

    controller.handleEvent(new AppEvent(AppEvents.MatchFieldConfigurationRequest));

    buildAddEditFieldDialog();/*from   w w  w  . jav  a 2 s  .  c om*/
    functionParameterDialog = new FunctionParametersDialog(controller);
    container = new LayoutContainer();
    container.setLayout(new BorderLayout());

    FormPanel panel = new FormPanel();
    panel.setFrame(true);
    panel.setHeaderVisible(false);
    panel.setLabelAlign(LabelAlign.TOP);
    panel.setButtonAlign(HorizontalAlignment.CENTER);
    panel.setBorders(true);

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

    List<String> leftAttributeNames = (List<String>) Registry.get(Constants.LEFT_TABLE_FIELD_NAMES);
    if (leftAttributeNames != null) {
        if (leftAttributeNames.size() > 0) {
            leftAttributeNameInPlaceCombo.add(leftAttributeNames);
        }
    }
    CellEditor leftAttributeNameInPlaceComboCellEditor = new CellEditor(leftAttributeNameInPlaceCombo) {
        @Override
        public Object preProcessValue(Object value) {
            if (value == null) {
                return value;
            }
            return leftAttributeNameInPlaceCombo.findModel(value.toString());
        }

        @Override
        public Object postProcessValue(Object value) {
            if (value == null) {
                return value;
            }
            return ((ModelData) value).get("value");
        }
    };
    ColumnConfig column = new ColumnConfig();
    column.setId(MatchFieldWeb.LEFT_FIELD_NAME);
    column.setHeader("Left Field Name");
    column.setWidth(130);
    column.setEditor(leftAttributeNameInPlaceComboCellEditor);
    configs.add(column);

    List<String> rightAttributeNames = (List<String>) Registry.get(Constants.RIGHT_TABLE_FIELD_NAMES);
    if (rightAttributeNames != null) {
        if (rightAttributeNames.size() > 0) {
            rightAttributeNameInPlaceCombo.add(rightAttributeNames);
        }
    }
    CellEditor rightAttributeNameInPlaceComboCellEditor = new CellEditor(rightAttributeNameInPlaceCombo) {
        @Override
        public Object preProcessValue(Object value) {
            if (value == null) {
                return value;
            }
            return rightAttributeNameInPlaceCombo.findModel(value.toString());
        }

        @Override
        public Object postProcessValue(Object value) {
            if (value == null) {
                return value;
            }
            return ((ModelData) value).get("value");
        }
    };
    column = new ColumnConfig();
    column.setId(MatchFieldWeb.RIGHT_FIELD_NAME);
    column.setHeader("Right Field Name");
    column.setWidth(130);
    column.setEditor(rightAttributeNameInPlaceComboCellEditor);
    configs.add(column);

    agreementProbabilityEdit.setAllowBlank(false);
    agreementProbabilityEdit.setAllowNegative(false);
    agreementProbabilityEdit.setMaxValue(1.0);
    agreementProbabilityEdit.setFormat(NumberFormat.getDecimalFormat());
    agreementProbabilityInPlaceEdit.setAllowBlank(false);
    agreementProbabilityInPlaceEdit.setAllowNegative(false);
    agreementProbabilityInPlaceEdit.setMaxValue(1.0);
    agreementProbabilityInPlaceEdit.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig();
    column.setId(MatchFieldWeb.AGREEMENT_PROBABILITY);
    column.setHeader("Agr.Prob.");
    column.setWidth(80);
    column.setEditor(new CellEditor(agreementProbabilityInPlaceEdit));
    column.setNumberFormat(NumberFormat.getScientificFormat());
    configs.add(column);

    disagreementProbabilityEdit.setAllowBlank(false);
    disagreementProbabilityEdit.setAllowNegative(false);
    disagreementProbabilityEdit.setMaxValue(1.0);
    disagreementProbabilityEdit.setFormat(NumberFormat.getDecimalFormat());
    disagreementProbabilityInPlaceEdit.setAllowBlank(false);
    disagreementProbabilityInPlaceEdit.setAllowNegative(false);
    disagreementProbabilityInPlaceEdit.setMaxValue(1.0);
    disagreementProbabilityInPlaceEdit.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig();
    column.setId(MatchFieldWeb.DISAGREEMENT_PROBABILITY);
    column.setHeader("Disagr.Prob.");
    column.setWidth(80);
    column.setEditor(new CellEditor(disagreementProbabilityInPlaceEdit));
    column.setNumberFormat(NumberFormat.getScientificFormat());
    configs.add(column);

    comparatorFuncNameInPlaceCombo.setForceSelection(true);
    comparatorFuncNameInPlaceCombo.setTriggerAction(TriggerAction.ALL);
    List<String> comparatorFuncNames = (List<String>) Registry
            .get(Constants.COMPARATOR_FUNCTION_NAME_SIMPLE_VALUE_LIST);
    comparatorFuncNameInPlaceCombo.add(comparatorFuncNames);
    CellEditor comparatorFuncNameInPlaceComboCellEditor = new CellEditor(comparatorFuncNameInPlaceCombo) {
        @Override
        public Object preProcessValue(Object value) {
            if (value == null) {
                return value;
            }
            return comparatorFuncNameInPlaceCombo.findModel(value.toString());
        }

        @Override
        public Object postProcessValue(Object value) {
            if (value == null) {
                return value;
            }
            return ((ModelData) value).get("value");
        }
    };
    column = new ColumnConfig();
    column.setId(MatchFieldWeb.COMPARATOR_FUNCTION_NAME);
    column.setHeader("Comp.Func.Name");
    column.setWidth(170);
    column.setEditor(comparatorFuncNameInPlaceComboCellEditor);
    configs.add(column);

    matchThresholdEdit.setAllowBlank(false);
    matchThresholdEdit.setAllowNegative(false);
    matchThresholdEdit.setMaxValue(1.0);
    matchThresholdEdit.setFormat(NumberFormat.getDecimalFormat());
    matchThresholdInPlaceEdit.setAllowBlank(false);
    matchThresholdInPlaceEdit.setAllowNegative(false);
    matchThresholdInPlaceEdit.setMaxValue(1.0);
    matchThresholdInPlaceEdit.setFormat(NumberFormat.getDecimalFormat());
    column = new ColumnConfig();
    column.setId(MatchFieldWeb.MATCH_THRESHOLD);
    column.setHeader("Match Threshold");
    column.setWidth(80);
    column.setEditor(new CellEditor(matchThresholdInPlaceEdit));
    column.setNumberFormat(NumberFormat.getScientificFormat());
    configs.add(column);

    GridCellRenderer<MatchFieldWeb> buttonRenderer = new GridCellRenderer<MatchFieldWeb>() {
        private boolean init;

        public Object render(final MatchFieldWeb editedFieldParam, String property, ColumnData config,
                final int rowIndex, final int colIndex, ListStore<MatchFieldWeb> store,
                final Grid<MatchFieldWeb> gridParam) {
            if (!init) {
                init = true;
                gridParam.addListener(Events.ColumnResize, new Listener<GridEvent<MatchFieldWeb>>() {
                    public void handleEvent(GridEvent<MatchFieldWeb> be) {
                        for (int i = 0; i < be.getGrid().getStore().getCount(); i++) {
                            if (be.getGrid().getView().getWidget(i, be.getColIndex()) != null && be.getGrid()
                                    .getView().getWidget(i, be.getColIndex()) instanceof BoxComponent) {
                                ((BoxComponent) be.getGrid().getView().getWidget(i, be.getColIndex()))
                                        .setWidth(be.getWidth() - 10);
                            }
                        }
                    }
                });
            }

            Button b = null;
            if (property.equals(MatchFieldWeb.ADD_BUTTON)) {
                b = new Button("", IconHelper.create("images/table_row_insert.png"),
                        new SelectionListener<ButtonEvent>() {
                            @Override
                            public void componentSelected(ButtonEvent ce) {
                                // Make sure we are starting with a clean slate
                                addOrEditFieldMode = true;
                                addEditMatchFieldDialog.show();

                                leftAttributeNameCombo.clearSelections();
                                rightAttributeNameCombo.clearSelections();
                                agreementProbabilityEdit.clear();
                                disagreementProbabilityEdit.clear();
                                comparatorFuncNameCombo.clearSelections();
                                matchThresholdEdit.clear();
                            }
                        });
                b.setToolTip("Add row to Grid");
            } else if (property.equals(MatchFieldWeb.EDIT_BUTTON)) {
                b = new Button("", IconHelper.create("images/table_edit.png"),
                        new SelectionListener<ButtonEvent>() {
                            @Override
                            public void componentSelected(ButtonEvent ce) {
                                addOrEditFieldMode = false;
                                if (editedFieldParam == null) {
                                    Info.display("Information", "Cannot determine which field to edit.");
                                    return;
                                }
                                addEditMatchFieldDialog.show();
                                editedFieldIndex = rowIndex;
                                editedField = editedFieldParam;

                                leftAttributeNameCombo
                                        .setValue(new ModelPropertyWeb(editedFieldParam.getLeftFieldName()));
                                rightAttributeNameCombo
                                        .setValue(new ModelPropertyWeb(editedFieldParam.getRightFieldName()));
                                agreementProbabilityEdit.setValue(editedFieldParam.getAgreementProbability());
                                disagreementProbabilityEdit
                                        .setValue(editedFieldParam.getDisagreementProbability());
                                comparatorFuncNameCombo.setValue(new ModelPropertyWeb(
                                        editedFieldParam.getComparatorFunction().getFunctionName()));
                                matchThresholdEdit.setValue(editedFieldParam.getMatchThreshold());
                            }
                        });
                b.setToolTip("Edit row details in a separate form");
            } else if (property.equals(MatchFieldWeb.DELETE_BUTTON)) {
                b = new Button("", IconHelper.create("images/table_row_delete.png"),
                        new SelectionListener<ButtonEvent>() {
                            @Override
                            public void componentSelected(ButtonEvent ce) {
                                if (editedFieldParam == null) {
                                    Info.display("Information",
                                            "You must first select a field to be deleted before pressing the \"Remove\" button.");
                                    return;
                                }
                                gridParam.getStore().remove(editedFieldParam);
                            }
                        });
                b.setToolTip("Delete row from Grid");
            } else if (property.equals(MatchFieldWeb.DND_IMAGE)) {
                return "<img src='images/mouse.png'></img>";
            }

            if (b != null)
                b.setWidth(gridParam.getColumnModel().getColumnWidth(colIndex) - 10);

            return b;
        }
    };

    column = new ColumnConfig();
    column.setId(MatchFieldWeb.ADD_BUTTON);
    column.setHeader("Add");
    column.setWidth(30);
    column.setRenderer(buttonRenderer);
    configs.add(column);

    column = new ColumnConfig();
    column.setId(MatchFieldWeb.EDIT_BUTTON);
    column.setHeader("Edt");
    column.setWidth(30);
    column.setRenderer(buttonRenderer);
    configs.add(column);

    column = new ColumnConfig();
    column.setId(MatchFieldWeb.DELETE_BUTTON);
    column.setHeader("Del");
    column.setWidth(30);
    column.setRenderer(buttonRenderer);
    configs.add(column);

    column = new ColumnConfig();
    column.setId(MatchFieldWeb.DND_IMAGE);
    column.setHeader("DnD");
    column.setWidth(30);
    column.setToolTip("Drag&Drop row");
    column.setRenderer(buttonRenderer);
    configs.add(column);

    final ColumnModel cm = new ColumnModel(configs);

    final RowEditor<MatchFieldWeb> rowEditor = new RowEditor<MatchFieldWeb>();
    grid = new Grid<MatchFieldWeb>(store, cm);
    grid.setStyleAttribute("borderTop", "none");
    grid.setBorders(true);
    grid.setStripeRows(true);
    grid.addPlugin(rowEditor);

    ContentPanel cpGrid = new ContentPanel();
    cpGrid.setHeading("Match Fields");
    cpGrid.setFrame(false);
    cpGrid.setLayout(new FitLayout());

    ToolBar toolBar = new ToolBar();
    Button applyGridChanges = new Button("Apply grid changes", IconHelper.create("images/table_save.png"));
    applyGridChanges.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            store.commitChanges();
        }
    });
    toolBar.add(applyGridChanges);
    Button cancelGridChanges = new Button("Cancel grid changes", IconHelper.create("images/table_delete.png"));
    cancelGridChanges.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            store.rejectChanges();
        }
    });
    toolBar.add(cancelGridChanges);
    toolBar.add(new SeparatorToolItem());
    Button addFieldButton = new Button("Add Match Field", IconHelper.create("images/table_row_insert.png"));
    addFieldButton.addSelectionListener(new SelectionListener<ButtonEvent>() {
        @Override
        public void componentSelected(ButtonEvent ce) {
            // Make sure we are starting with a clean slate
            addOrEditFieldMode = true;
            addEditMatchFieldDialog.show();

            leftAttributeNameCombo.clearSelections();
            rightAttributeNameCombo.clearSelections();
            agreementProbabilityEdit.clear();
            disagreementProbabilityEdit.clear();
            comparatorFuncNameCombo.clearSelections();
            matchThresholdEdit.clear();
        }
    });
    toolBar.add(addFieldButton);

    new GridDragSource(grid);

    GridDropTarget target = new GridDropTarget(grid);
    target.setAllowSelfAsSource(true);
    target.setFeedback(Feedback.INSERT);

    LayoutContainer main = new LayoutContainer();
    main.setLayout(new ColumnLayout());

    panel.add(main, new FormData("20%"));

    Integer wizardMode = (Integer) Registry.get(Constants.WIZARD_MODE);
    boolean inWizardMode = (wizardMode == Constants.RECORD_LINKAGE_WIZARD_MODE);

    if (inWizardMode) {
        Button previousButton = new Button(Constants.PREVIOUS_PAGE_WIZARD_BUTTON_TEXT,
                IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() {
                    @Override
                    public void componentSelected(ButtonEvent ce) {
                        Button sourceButton = ce.getButton();
                        MatchFieldConfigurationView matchFieldConfigurationView = (MatchFieldConfigurationView) sourceButton
                                .getData("this");
                        matchFieldConfigurationView.saveConfiguration();
                        Boolean inWizard = (Boolean) sourceButton.getData("inWizardMode");
                        if (inWizard)
                            Dispatcher.get().dispatch(AppEvents.PrivacyPreservingBlockingConfigurationView);
                    }
                });
        previousButton.setData("this", this);
        previousButton.setData("inWizardMode", inWizardMode);
        panel.getButtonBar().add(previousButton);
    }

    Button saveButton = new Button(
            inWizardMode ? Constants.NEXT_PAGE_WIZARD_BUTTON_TEXT : Constants.SAVE_BUTTON_TEXT,
            IconHelper.create("images/folder_go.png"), new SelectionListener<ButtonEvent>() {
                @Override
                public void componentSelected(ButtonEvent ce) {
                    Button sourceButton = ce.getButton();
                    MatchFieldConfigurationView matchFieldConfigurationView = (MatchFieldConfigurationView) sourceButton
                            .getData("this");
                    matchFieldConfigurationView.saveConfiguration();
                    Boolean inWizard = (Boolean) sourceButton.getData("inWizardMode");
                    if (inWizard) {
                        Dispatcher.get().dispatch(AppEvents.MatchConfigurationParametersView);
                    }
                }
            });
    saveButton.setData("this", this);
    saveButton.setData("inWizardMode", inWizardMode);
    panel.getButtonBar().add(saveButton);

    if (inWizardMode) {
        Button exitButton = new Button(Constants.EXIT_WIZARD_BUTTON_TEXT,
                IconHelper.create("images/folder_delete.png"), new SelectionListener<ButtonEvent>() {
                    @Override
                    public void componentSelected(ButtonEvent ce) {
                        Dispatcher.get().dispatch(AppEvents.ExitWizardSelected);
                    }
                });
        exitButton.setData("this", this);
        panel.getButtonBar().add(exitButton);
    }

    container.add(panel, new BorderLayoutData(LayoutRegion.NORTH, 60));

    gridContainer = new LayoutContainer();
    gridContainer.setBorders(true);
    gridContainer.setLayout(new FitLayout());

    cpGrid.setTopComponent(toolBar);
    cpGrid.add(grid);
    gridContainer.add(cpGrid);

    BorderLayoutData data = new BorderLayoutData(LayoutRegion.CENTER);
    data.setMargins(new Margins(55, 2, 2, 2));
    container.add(gridContainer, data);

    LayoutContainer wrapper = (LayoutContainer) Registry.get(Constants.CENTER_PANEL);
    wrapper.removeAll();
    wrapper.add(container);
    wrapper.layout();
    GWT.log("Done Initializing the UI in " + (new java.util.Date().getTime() - time), null);
}

From source file:org.pentaho.mantle.client.solutionbrowser.fileproperties.GeneralPanel.java

License:Open Source License

/**
 *
 *///  ww w  .j  a v  a2 s .c  o m
public void init() {
    nameLabel.setText(fileSummary.getTitle());
    typeLabel.setText(fileSummary.isFolder() ? Messages.getString("folder") //$NON-NLS-1$
            : fileSummary.getName().substring(fileSummary.getName().lastIndexOf("."))); //$NON-NLS-1$
    sourceLabel.setText(isInTrash ? Messages.getString("recycleBin") : fileSummary.getPath()); //$NON-NLS-1$//$NON-NLS-2$
    locationLabel.setText(isInTrash ? Messages.getString("recycleBin") //$NON-NLS-1$
            : fileSummary.getPath().substring(0, fileSummary.getPath().lastIndexOf("/"))); //$NON-NLS-1$
    sizeLabel.setText(NumberFormat.getDecimalFormat().format(fileSummary.getFileSize() / 1000.00) + " " //$NON-NLS-1$
            + Messages.getString("kiloBytes")); //$NON-NLS-1$\
    DateTimeFormat df = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_FULL);
    createdLabel.setText(df.format(fileSummary.getCreatedDate()));
    lastModifiedDateLabel
            .setText(fileSummary.getLastModifiedDate() == null ? df.format(fileSummary.getCreatedDate())
                    : df.format(fileSummary.getLastModifiedDate()));
    deletedDateLabel
            .setText(fileSummary.getDeletedDate() == null ? "" : fileSummary.getDeletedDate().toString()); //$NON-NLS-1$
    originalLocationLabel.setText(fileSummary.getOriginalParentFolderPath());
}

From source file:org.primaresearch.shared.variable.GwtDecimalFormatter.java

License:Apache License

/**
 * Constructor//from w w w  . ja v  a 2s . c o  m
 * @param pattern The format pattern (see {@link com.google.gwt.i18n.client.NumberFormat NumberFormat} for syntax).
 */
public GwtDecimalFormatter(String pattern) {
    format = NumberFormat.getDecimalFormat();
}

From source file:org.rhq.coregui.client.util.measurement.MeasurementParser.java

License:Open Source License

public static MeasurementNumericValueAndUnits parse(String input, MeasurementUnits targetUnits)
        throws MeasurementConversionException {

    if (input == null) {
        return new MeasurementNumericValueAndUnits(Double.valueOf(0.0), targetUnits);
    }//from ww  w .  j av a2 s  .  com

    input = input.trim();

    if (input.length() == 0) {
        return new MeasurementNumericValueAndUnits(Double.valueOf(0.0), targetUnits);
    }

    int i = 0;

    // skip over the sign, we'll deal with that later
    if (input.startsWith("+") || input.startsWith("-")) {
        i = 1;
    }

    // find the end of the magnitude (i.e. the number itself)
    // note we allow for decimals - and we allow for either "." or "," as the decimal point for i18n purposes
    for (; i < input.length(); i++) {
        char ch = input.charAt(i);
        if (!(Character.isDigit(ch) || ch == '.' || ch == ',')) {
            break;
        }
    }

    String magnitude = input.substring(0, i);
    String units = "";

    if (i <= input.length()) {
        // gobble everything after the magnitude and consider it the units
        units = input.substring(i);
        units = units.trim();
    }

    MeasurementUnits fromUnits;
    if (units.equals("")) {
        /*
         * no units is valid, and we assume the passed targetUnits; however, we will
         * still need to check that the number is well-formed, so continue processing.
         */
        fromUnits = targetUnits;
    } else {
        fromUnits = MeasurementUnits.getUsingDisplayUnits(units, targetUnits.getFamily());

        if ((fromUnits == null) || (!fromUnits.isComparableTo(targetUnits))) {
            throw new MeasurementConversionException("The units in '" + input + "' were not valid, "
                    + "expected '" + targetUnits.getFamily() + "' units, received '" + units + "' units");
        }
    }

    try {
        if (magnitude.startsWith("+")) {
            magnitude = magnitude.substring(1);
        }

        Number convertedMagnitude = NumberFormat.getDecimalFormat().parse(magnitude);
        Double scaledMagnitude;

        // apply relative scale if applicable, otherwise perform standard scaling
        if (MeasurementUnits.Family.RELATIVE == targetUnits.getFamily()) {
            scaledMagnitude = MeasurementUnits.scaleDown(convertedMagnitude.doubleValue(), targetUnits);
        } else {
            MeasurementNumericValueAndUnits valueAndUnits = new MeasurementNumericValueAndUnits(
                    convertedMagnitude.doubleValue(), fromUnits);
            scaledMagnitude = MeasurementConverterClient.scale(valueAndUnits, targetUnits);
        }

        return new MeasurementNumericValueAndUnits(scaledMagnitude, targetUnits);
    } catch (Exception e) {
        throw new MeasurementConversionException("The magnitude in '" + input + "' did not parse correctly "
                + "as a valid, localized, stringified number ");
    }

}

From source file:org.sakaiproject.gradebook.gwt.client.DataTypeConversionUtil.java

License:Educational Community License

public static String formatDoubleAsPercentString(Double d) {
    if (d == null)
        return "0.0";

    return NumberFormat.getDecimalFormat().format(d);
}

From source file:org.sakaiproject.gradebook.gwt.client.DataTypeConversionUtil.java

License:Educational Community License

public static String formatDoubleAsPointsString(Double d) {
    if (d == null)
        return "0.0";

    return NumberFormat.getDecimalFormat().format(d);
}