• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Formatter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getFormatter

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


示例17: setFormatter

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


示例18: addColumn

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

    Object columnId = column.getId();
    component.addContainerProperty(columnId, column.getType(), null);
    if (StringUtils.isNotBlank(column.getDescription())) {
        component.setColumnDescription(columnId, column.getDescription());
    }

    if (StringUtils.isNotBlank(column.getValueDescription())) {
        component.setAggregationDescription(columnId, column.getValueDescription());
    } else if (column.getAggregation() != null
            && column.getAggregation().getType() != AggregationInfo.Type.CUSTOM) {
        Messages messages = AppBeans.get(Messages.NAME);
        String aggregationTypeLabel;

        switch (column.getAggregation().getType()) {
            case AVG:
                aggregationTypeLabel = "aggreagtion.avg";
                break;
            case COUNT:
                aggregationTypeLabel = "aggreagtion.count";
                break;
            case SUM:
                aggregationTypeLabel = "aggreagtion.sum";
                break;
            case MIN:
                aggregationTypeLabel = "aggreagtion.min";
                break;
            case MAX:
                aggregationTypeLabel = "aggreagtion.max";
                break;
            default:
                throw new IllegalArgumentException(
                        String.format("AggregationType %s is not supported",
                                column.getAggregation().getType().toString()));
        }

        component.setAggregationDescription(columnId, messages.getMainMessage(aggregationTypeLabel));
    }

    if (!column.isSortable()) {
        component.setColumnSortable(columnId, column.isSortable());
    }

    columns.put(columnId, column);
    columnsOrder.add(column);
    if (column.getWidth() != null) {
        component.setColumnWidth(columnId, column.getWidth());
    }
    if (column.getAlignment() != null) {
        component.setColumnAlignment(columnId,
                WebComponentsHelper.convertColumnAlignment(column.getAlignment()));
    }

    final String caption = getColumnCaption(columnId, column);
    setColumnHeader(columnId, caption);

    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,代码行数:71,代码来源:WebAbstractTable.java


示例19: CalculatablePropertyValueChangeListener

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


示例20: getTargetFormatter

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AndExpr类代码示例发布时间:2022-05-23
下一篇:
Java TabSet类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap