当前位置: 首页>>代码示例>>Java>>正文


Java Formatter类代码示例

本文整理汇总了Java中com.haulmont.cuba.gui.components.Formatter的典型用法代码示例。如果您正苦于以下问题:Java Formatter类的具体用法?Java Formatter怎么用?Java Formatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Formatter类属于com.haulmont.cuba.gui.components包,在下文中一共展示了Formatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFormattedValue

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
protected String getFormattedValue(Column column, Object value) {
    String cellText;
    if (value == null) {
        cellText = "";
    } else {
        if (value instanceof String) {
            cellText = (String) value;
        } else {
            Formatter formatter = column.getFormatter();
            if (formatter != null) {
                //noinspection unchecked
                cellText = formatter.format(value);
            } else {
                Datatype datatype = Datatypes.get(value.getClass());
                if (datatype != null) {
                    UserSessionSource sessionSource = AppBeans.get(UserSessionSource.NAME);
                    cellText = datatype.format(value, sessionSource.getLocale());
                } else {
                    cellText = value.toString();
                }
            }
        }
    }
    return cellText;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:26,代码来源:WebAbstractTable.java

示例2: generateCell

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
protected com.vaadin.ui.Component generateCell(AbstractSelect source, Object itemId, Object columnId) {
    CollectionDatasource ds = WebAbstractTable.this.getDatasource();
    MetaPropertyPath propertyPath = ds.getMetaClass().getPropertyPath(columnId.toString());

    PropertyWrapper propertyWrapper = (PropertyWrapper) source.getContainerProperty(itemId, propertyPath);

    com.haulmont.cuba.gui.components.Formatter formatter = null;
    Table.Column column = WebAbstractTable.this.getColumn(columnId.toString());
    if (column != null) {
        formatter = column.getFormatter();
    }

    final com.vaadin.ui.Label label = new com.vaadin.ui.Label();
    WebComponentsHelper.setLabelText(label, propertyWrapper.getValue(), formatter);
    label.setWidth("-1px");

    //add property change listener that will update a label value
    propertyWrapper.addListener(new CalculatablePropertyValueChangeListener(label, formatter));

    return label;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:WebAbstractTable.java

示例3: setFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
@Override
public void setFormatter(Formatter formatter) {
    this.formatter = formatter;
    if (gridColumn != null) {
        if (formatter != null) {
            com.vaadin.data.util.converter.Converter converter = gridColumn.getConverter();
            if (converter instanceof FormatterBasedConverter) {
                ((FormatterBasedConverter) converter).setFormatter(formatter);
            } else {
                gridColumn.setConverter(new FormatterBasedConverter(formatter));
            }
        } else {
            if (converter != null) {
                gridColumn.setConverter(createConverterWrapper(converter));
            } else {
                owner.setDefaultConverter(gridColumn, getMetaProperty(), type);
            }
        }
        owner.repaint();
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:22,代码来源:WebDataGrid.java

示例4: createParameter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
protected PerformanceParameter createParameter(String paramGroup, String paramName, boolean showRecent,
                                               Formatter<Double> formatter) {
    PerformanceParameter param = new PerformanceParameter();
    param.setParameterName(paramName);
    param.setParameterGroup(paramGroup);
    param.setShowRecent(showRecent);
    param.setFormatter(formatter);

    data.put(param.getId(), param);
    attachListener(param);
    return param;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:13,代码来源:StatisticsDatasource.java

示例5: setLabelText

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
public static void setLabelText(com.vaadin.ui.Label label, Object value, Formatter formatter) {
    label.setValue(value == null
            ? "" : String.class.isInstance(value)
                    ? (String) value : formatter != null
                            ? formatter.format(value) : value.toString()
    );
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:WebComponentsHelper.java

示例6: getFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
@Override
public Formatter getFormatter() {
    if (component instanceof HasFormatter) {
        return ((HasFormatter) component).getFormatter();
    }
    return targetFormatter;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:8,代码来源:WebFieldGroup.java

示例7: setFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
@Override
public void setFormatter(Formatter formatter) {
    if (component instanceof HasFormatter) {
        ((HasFormatter) component).setFormatter(formatter);
    } else {
        this.targetFormatter = formatter;
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:9,代码来源:WebFieldGroup.java

示例8: initFieldConverter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
@Override
protected void initFieldConverter() {
    if (metaProperty != null) {
        switch (metaProperty.getType()) {
            case ASSOCIATION:
                component.setConverter(new StringToEntityConverter() {
                    @Override
                    public Formatter getFormatter() {
                        return WebAbstractTextField.this.getFormatter();
                    }
                });
                break;

            case DATATYPE:
                component.setConverter(new TextFieldStringToDatatypeConverter(metaProperty.getRange().asDatatype()));
                break;

            case ENUM:
                //noinspection unchecked
                component.setConverter(new StringToEnumConverter((Class<Enum>) metaProperty.getJavaType()){
                    @Override
                    public Formatter getFormatter() {
                        return WebAbstractTextField.this.getFormatter();
                    }

                    @Override
                    public boolean isTrimming() {
                        return WebAbstractTextField.this.isTrimming();
                    }
                });
                break;

            default:
                component.setConverter(new TextFieldStringToDatatypeConverter(Datatypes.getNN(String.class)));
                break;
        }
    } else {
        component.setConverter(new TextFieldStringToDatatypeConverter(Datatypes.getNN(String.class)));
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:41,代码来源:WebAbstractTextField.java

示例9: addColumn

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
@Override
public void addColumn(Column column) {
    checkNotNullArgument(column, "Column must be non null");

    Object columnId = column.getId();
    columns.put(columnId, column);
    columnsOrder.add(column);

    if (tableModel != null) {
        tableModel.addColumn(column);
    }

    if (datasource != null && column.isEditable() && columnId instanceof MetaPropertyPath) {
        if (!editableColumns.contains(columnId)) {
            editableColumns.add((MetaPropertyPath) columnId);
        }
    }

    setColumnIdentifiers();
    refresh();

    column.setOwner(this);

    if (column.getFormatter() == null && columnId instanceof MetaPropertyPath) {
        MetaProperty metaProperty = ((MetaPropertyPath) columnId).getMetaProperty();

        if (Collection.class.isAssignableFrom(metaProperty.getJavaType())) {
            final Formatter collectionFormatter = new CollectionFormatter();
            column.setFormatter(collectionFormatter);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:33,代码来源:DesktopAbstractTable.java

示例10: getFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
public Formatter<Double> getFormatter() {
    return formatter;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:4,代码来源:PerformanceParameter.java

示例11: setFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
public void setFormatter(Formatter<Double> formatter) {
    this.formatter = formatter;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:4,代码来源:PerformanceParameter.java

示例12: getFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
public Formatter getFormatter() {
    return formatter;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:4,代码来源:StringToEntityConverter.java

示例13: setFormatter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
public void setFormatter(Formatter formatter) {
    this.formatter = formatter;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:4,代码来源:StringToEntityConverter.java

示例14: FormatterBasedConverter

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
public FormatterBasedConverter(Formatter formatter) {
    this.formatter = formatter;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:4,代码来源:FormatterBasedConverter.java

示例15: setDatasource

import com.haulmont.cuba.gui.components.Formatter; //导入依赖的package包/类
@Override
public void setDatasource(Datasource datasource, String property) {
    if ((datasource == null && property != null) || (datasource != null && property == null))
        throw new IllegalArgumentException("Datasource and property should be either null or not null at the same time");

    if (datasource == this.datasource && metaPropertyPath != null && metaPropertyPath.toString().equals(property))
        return;

    if (this.datasource != null)
        unsubscribeDatasource();

    if (datasource != null) {
        // noinspection unchecked
        this.datasource = datasource;
        this.metaPropertyPath = resolveMetaPropertyPath(datasource.getMetaClass(), property);
        this.metaProperty = metaPropertyPath.getMetaProperty();

        switch (metaProperty.getType()) {
            case ASSOCIATION:
                component.setConverter(new StringToEntityConverter() {
                    @Override
                    public Formatter getFormatter() {
                        return WebLabel.this.formatter;
                    }
                });
                break;

            case DATATYPE:
                component.setConverter(new StringToDatatypeConverter(metaProperty.getRange().asDatatype()) {
                    @Override
                    public Formatter getFormatter() {
                        return WebLabel.this.formatter;
                    }
                });
                break;

            case ENUM:
                //noinspection unchecked
                component.setConverter(new StringToEnumConverter((Class<Enum>) metaProperty.getJavaType()) {
                    @Override
                    public Formatter getFormatter() {
                        return WebLabel.this.formatter;
                    }
                });
                break;

            default:
                component.setConverter(new StringToDatatypeConverter(Datatypes.getNN(String.class)) {
                    @Override
                    public Formatter getFormatter() {
                        return WebLabel.this.formatter;
                    }
                });
                break;
        }

        itemWrapper = createDatasourceWrapper(datasource, Collections.singleton(this.metaPropertyPath));
        component.setPropertyDataSource(itemWrapper.getItemProperty(this.metaPropertyPath));
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:61,代码来源:WebLabel.java


注:本文中的com.haulmont.cuba.gui.components.Formatter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。