Search in sources :

Example 1 with NumberField

use of com.extjs.gxt.ui.client.widget.form.NumberField in project activityinfo by bedatadriven.

the class TargetIndicatorView method setValidatorForCellBeforeEdit.

private void setValidatorForCellBeforeEdit(TargetValueDTO targetValueDTO, int column) {
    TextField field = new TextField<String>();
    field.setAllowBlank(true);
    IndicatorDTO indicatorById = presenter.getIndicatorById(targetValueDTO.getIndicatorId());
    FieldTypeClass type = indicatorById.getType();
    if (type == FieldTypeClass.QUANTITY) {
        field = new NumberField();
        ((NumberField) field).setFormat(IndicatorNumberFormat.INSTANCE);
        field.setAllowBlank(true);
    }
    tree.getColumnModel().getColumn(column).setEditor(new CellEditor(field));
}
Also used : TextField(com.extjs.gxt.ui.client.widget.form.TextField) FieldTypeClass(org.activityinfo.model.type.FieldTypeClass) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField)

Example 2 with NumberField

use of com.extjs.gxt.ui.client.widget.form.NumberField in project activityinfo by bedatadriven.

the class IndicatorSection method createQuantityField.

private NumberField createQuantityField() {
    NumberField numberField = new NumberField();
    numberField.setFormat(IndicatorNumberFormat.INSTANCE);
    numberField.setWidth(NUMBER_FIELD_WIDTH);
    numberField.setStyleAttribute("textAlign", "right");
    return numberField;
}
Also used : NumberField(com.extjs.gxt.ui.client.widget.form.NumberField)

Example 3 with NumberField

use of com.extjs.gxt.ui.client.widget.form.NumberField in project activityinfo by bedatadriven.

the class MonthlyGrid method createColumnModel.

private static ColumnModel createColumnModel() {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig indicator = new ColumnConfig("indicatorName", I18N.CONSTANTS.indicators(), ROW_HEADER_WIDTH);
    indicator.setSortable(false);
    indicator.setMenuDisabled(true);
    columns.add(indicator);
    for (int i = 0; i != MONTHS_TO_SHOW; ++i) {
        NumberField indicatorField = new NumberField();
        indicatorField.getPropertyEditor().setFormat(IndicatorNumberFormat.INSTANCE);
        ColumnConfig valueColumn = new ColumnConfig("month" + i, "", MONTH_COLUMN_WIDTH);
        valueColumn.setNumberFormat(IndicatorNumberFormat.INSTANCE);
        valueColumn.setEditor(new CellEditor(indicatorField));
        valueColumn.setSortable(false);
        valueColumn.setMenuDisabled(true);
        columns.add(valueColumn);
    }
    return new ColumnModel(columns);
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) CellEditor(com.extjs.gxt.ui.client.widget.grid.CellEditor) ArrayList(java.util.ArrayList) ColumnModel(com.extjs.gxt.ui.client.widget.grid.ColumnModel) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField)

Example 4 with NumberField

use of com.extjs.gxt.ui.client.widget.form.NumberField in project activityinfo by bedatadriven.

the class ColumnModelBuilder method createIndicatorColumn.

public ColumnConfig createIndicatorColumn(IndicatorDTO indicator, String header) {
    NumberField indicatorField = new NumberField();
    indicatorField.getPropertyEditor().setFormat(IndicatorNumberFormat.INSTANCE);
    ColumnConfig indicatorColumn = new ColumnConfig(indicator.getPropertyName(), header, 50);
    indicatorColumn.setToolTip(indicator.getName());
    indicatorColumn.setNumberFormat(IndicatorNumberFormat.INSTANCE);
    indicatorColumn.setEditor(new CellEditor(indicatorField));
    indicatorColumn.setAlignment(Style.HorizontalAlignment.RIGHT);
    if (indicator.getType() == FieldTypeClass.QUANTITY) {
        // (it looks better if we don't)
        if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SUM) {
            indicatorColumn.setRenderer(new QuantityCellRenderer());
        } else if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SITE_COUNT) {
            indicatorColumn.setRenderer(new SiteCountCellRenderer());
        }
    } else if (indicator.getType() == FieldTypeClass.FREE_TEXT || indicator.getType() == FieldTypeClass.NARRATIVE) {
        indicatorColumn.setRenderer(new TextIndicatorCellRenderer());
    }
    return indicatorColumn;
}
Also used : ColumnConfig(com.extjs.gxt.ui.client.widget.grid.ColumnConfig) CellEditor(com.extjs.gxt.ui.client.widget.grid.CellEditor) NumberField(com.extjs.gxt.ui.client.widget.form.NumberField)

Aggregations

NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)4 CellEditor (com.extjs.gxt.ui.client.widget.grid.CellEditor)2 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)2 TextField (com.extjs.gxt.ui.client.widget.form.TextField)1 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)1 ArrayList (java.util.ArrayList)1 FieldTypeClass (org.activityinfo.model.type.FieldTypeClass)1