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


Java StringToIntegerConverter类代码示例

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


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

示例1: RequiredIntegerField

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
/**
 * Constructeur
 */
public RequiredIntegerField() {
	super();		
	setConverter(new StringToIntegerConverter() {
           private static final long serialVersionUID = -1725520453911073564L;

           @Override
           protected NumberFormat getFormat(Locale locale) {
               return new DecimalFormat("#");
           }
       });
	addValidator(value->{
		if (value==null){
			return;
		}
		Integer integerValue = null;
		try{
			integerValue = Integer.valueOf(value.toString());				
		}catch (Exception e){
			throw new InvalidValueException(getConversionError());
		}
		if (value!=null && integerValue<0){
			throw new InvalidValueException(getConversionError());
		}
	});
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:29,代码来源:RequiredIntegerField.java

示例2: NumberField

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
public NumberField() {
    // Mark the field as numeric.
    // This affects the virtual keyboard shown on mobile devices.
    AttributeExtension ae = new AttributeExtension();
    ae.extend(this);
    ae.setAttribute("type", "number");

    setConverter(new StringToIntegerConverter() {
        @Override
        protected NumberFormat getFormat(Locale locale) {
            // do not use a thousands separator, as HTML5 input type
            // number expects a fixed wire/DOM number format regardless
            // of how the browser presents it to the user (which could
            // depend on the browser locale)
            DecimalFormat format = new DecimalFormat();
            format.setMaximumFractionDigits(0);
            format.setDecimalSeparatorAlwaysShown(false);
            format.setParseIntegerOnly(true);
            format.setGroupingUsed(false);
            return format;
        }
    });
}
 
开发者ID:jvalenciag,项目名称:VaadinSpringShiroMongoDB,代码行数:24,代码来源:NumberField.java

示例3: createIntegerTextField

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
private TextField createIntegerTextField(final String in18Key, final String id) {
    final TextField textField = createTextField(in18Key, id);
    textField.setNullRepresentation("");
    textField.setConverter(new StringToIntegerConverter());
    textField.setConversionError(i18n.getMessage(MESSAGE_ENTER_NUMBER));
    textField.setSizeUndefined();
    return textField;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:9,代码来源:AddUpdateRolloutWindowLayout.java

示例4: createPercentageField

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
private TextField createPercentageField(final String in18Key, final String id) {
    final TextField textField = new TextFieldBuilder().prompt(i18n.getMessage(in18Key)).immediate(true).id(id)
            .buildTextComponent();
    textField.setWidth(80, Unit.PIXELS);
    textField.setNullRepresentation("");
    textField.setConverter(new StringToIntegerConverter());
    textField.addValidator(this::validateMandatoryPercentage);
    return textField;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:10,代码来源:DefineGroupsLayout.java

示例5: buildGeneratedCountField

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
private void buildGeneratedCountField() {
	if (generatedCountField == null) {
		generatedCountField = new TextField();
		generatedCountField.setConverter(new StringToIntegerConverter());
		generatedCountField.setConversionError(Messages.getString("Message.Error.GeneratedCountInteger", 1, 999));
		generatedCountField.setMaxLength(3);
		generatedCountField.setNullRepresentation("");
		generatedCountField.setWidth(3, Unit.EM);
		generatedCountField.setRequired(true);
		generatedCountField.setRequiredError(Messages.getString("Message.Error.GeneratedCountRequired"));
		generatedCountField.addValidator(new IntegerRangeValidator(
				Messages.getString("Message.Error.GeneratedCountInteger", 1, 999), 1, 999));
	}
}
 
开发者ID:tilioteo,项目名称:hypothesis,代码行数:15,代码来源:UserWindowPresenterImpl.java

示例6: ChartConfigureLayout

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
public ChartConfigureLayout(BeanFieldGroup<DiagrammePreference> preferences) {
    super(preferences);

    setCaption("Configuration");
    setMargin(false);
    setSpacing(true);
    refresh.setConverter(new StringToIntegerConverter());
    refresh.setStyleName(ValoTheme.TEXTFIELD_SMALL);
    horizontalLayout.setExpandRatio(verticalLayout, 1f);

    verticalLayout.setSpacing(true);

    firstColumnChoice.setWidth(100, Sizeable.Unit.PERCENTAGE);
    firstColumnChoice.setRequired(true);
    firstColumnChoice.setStyleName(ValoTheme.COMBOBOX_SMALL);

    firstColumnChoice.setFilteringMode(FilteringMode.CONTAINS);
    firstColumnChoice.setNullSelectionAllowed(false);
    firstColumnChoice.setNewItemsAllowed(false);
    firstColumnChoice.setImmediate(true);
    firstColumnChoice.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    firstColumnChoice.setItemCaptionPropertyId("name");

    firstColumnSortOrder.setWidth(100, Unit.PERCENTAGE);
    firstColumnSortOrder.setRequired(false);
    firstColumnSortOrder.setFilteringMode(FilteringMode.CONTAINS);
    firstColumnSortOrder.setNewItemsAllowed(false);
    firstColumnSortOrder.setImmediate(true);
    firstColumnSortOrder.setNullSelectionAllowed(true);
    firstColumnSortOrder.setStyleName(ValoTheme.COMBOBOX_SMALL);

    firstColumnAndSortLayout.addComponent(firstColumnChoice);
    firstColumnAndSortLayout.addComponent(firstColumnSortOrder);
    firstColumnAndSortLayout.setExpandRatio(firstColumnChoice, 0.8f);
    firstColumnAndSortLayout.setExpandRatio(firstColumnSortOrder, 0.2f);
    firstColumnAndSortLayout.setSpacing(true);
    firstColumnAndSortLayout.setSizeFull();
    firstColumnAndSortLayout.setStyleName(ValoTheme.COMBOBOX_SMALL);

    verticalLayout.addComponent(firstColumnAndSortLayout);

    valuesColumnChoice.setWidth(100, Sizeable.Unit.PERCENTAGE);
    valuesColumnChoice.setRequired(true);
    valuesColumnChoice.setFilteringMode(FilteringMode.CONTAINS);
    valuesColumnChoice.setNullSelectionAllowed(false);
    valuesColumnChoice.setNewItemsAllowed(false);
    valuesColumnChoice.setImmediate(true);
    valuesColumnChoice.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY);
    valuesColumnChoice.setItemCaptionPropertyId("name");
    valuesColumnChoice.setStyleName(ValoTheme.COMBOBOX_SMALL);

    valuesColumnSortOrder.setWidth(100, Unit.PERCENTAGE);
    valuesColumnSortOrder.setRequired(false);
    valuesColumnSortOrder.setFilteringMode(FilteringMode.CONTAINS);
    valuesColumnSortOrder.setNewItemsAllowed(false);
    valuesColumnSortOrder.setImmediate(true);
    valuesColumnSortOrder.setNullSelectionAllowed(true);
    valuesColumnSortOrder.setStyleName(ValoTheme.COMBOBOX_SMALL);

    valuesColumnAndSortLayout.addComponent(valuesColumnChoice);
    valuesColumnAndSortLayout.addComponent(valuesColumnSortOrder);

    valuesColumnAndSortLayout.setExpandRatio(valuesColumnChoice, 0.8f);
    valuesColumnAndSortLayout.setExpandRatio(valuesColumnSortOrder, 0.2f);
    valuesColumnAndSortLayout.setSpacing(true);
    valuesColumnAndSortLayout.setSizeFull();

    verticalLayout.addComponent(valuesColumnAndSortLayout);

    addComponent(horizontalLayout);
    horizontalLayout.setSpacing(true);
    horizontalLayout.setSizeFull();

    setComboBoxChoices();
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:76,代码来源:ChartConfigureLayout.java

示例7: IntegerValueValidator

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
public IntegerValueValidator()
{
    super(VALDT_MSG, new StringToIntegerConverter());
}
 
开发者ID:tonight-halfmoon,项目名称:Vaadin-Prime-Count,代码行数:5,代码来源:IntegerValueValidator.java

示例8: ProductGrid

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
public ProductGrid() {
    setSizeFull();

    setSelectionMode(SelectionMode.SINGLE);

    BeanItemContainer<Product> container = new BeanItemContainer<Product>(
            Product.class);
    setContainerDataSource(container);
    setColumnOrder("id", "productName", "price", "availability",
            "stockCount", "category");

    // Show empty stock as "-"
    getColumn("stockCount").setConverter(new StringToIntegerConverter() {
        @Override
        public String convertToPresentation(Integer value,
                java.lang.Class<? extends String> targetType, Locale locale)
                throws Converter.ConversionException {
            if (value == 0) {
                return "-";
            }

            return super.convertToPresentation(value, targetType, locale);
        };
    });

    // Add an traffic light icon in front of availability
    getColumn("availability").setConverter(availabilityConverter)
            .setRenderer(new HtmlRenderer());

    // Add " €" automatically after price
    getColumn("price").setConverter(new EuroConverter());

    // Show categories as a comma separated list
    getColumn("category").setConverter(new CollectionToStringConverter());

    // Align columns using a style generator and theme rule until #15438
    setCellStyleGenerator(new CellStyleGenerator() {

        @Override
        public String getStyle(CellReference cellReference) {
            if (cellReference.getPropertyId().equals("price")
                    || cellReference.getPropertyId().equals("stockCount")) {
                return "align-right";
            }
            return null;
        }
    });
}
 
开发者ID:vaadin,项目名称:archetype-application-example,代码行数:49,代码来源:ProductGrid.java

示例9: initialize

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
@Override
public void initialize() {
    final SiteDescriptor siteDescriptor = DefaultSiteUI.getContentProvider().getSiteDescriptor();

    final NavigationVersion navigationVersion = siteDescriptor.getNavigation().getProductionVersion();
    navigationVersion.addChildPage("configuration", "account", "content");
    navigationVersion.addChildPage("configuration", "content", "assets");

    // Describe content view.
    final ViewDescriptor contentView = new ViewDescriptor("content", "Content", DefaultValoView.class);
    contentView.setViewerRoles(DefaultRoles.ADMINISTRATOR);
    contentView.setViewletClass("content", ContentFlow.class);
    siteDescriptor.getViewDescriptors().add(contentView);

    final ViewDescriptor assetsView = new ViewDescriptor("assets", "Assets", DefaultValoView.class);
    assetsView.setViewerRoles(DefaultRoles.ADMINISTRATOR);
    assetsView.setViewletClass("content", AssetFlow.class);
    siteDescriptor.getViewDescriptors().add(assetsView);

    // Describe feedback view fields.
    final FieldSetDescriptor contentFields = new FieldSetDescriptor(Content.class);

    contentFields.setVisibleFieldIds(new String[]{
            "page", "title", "parentPage", "afterPage", "markupType", "markup", "created", "modified"
    });

    contentFields.getFieldDescriptor("created").setReadOnly(true);
    contentFields.getFieldDescriptor("created").setCollapsed(true);
    contentFields.getFieldDescriptor("modified").setReadOnly(true);
    contentFields.getFieldDescriptor("modified").setCollapsed(true);
    contentFields.getFieldDescriptor("page").setRequired(false);
    contentFields.getFieldDescriptor("parentPage").setRequired(false);
    contentFields.getFieldDescriptor("parentPage").setCollapsed(true);
    contentFields.getFieldDescriptor("afterPage").setRequired(false);
    contentFields.getFieldDescriptor("afterPage").setCollapsed(true);
    contentFields.getFieldDescriptor("markupType").setRequired(true);
    contentFields.getFieldDescriptor("markupType").setFieldClass(MarkupTypeField.class);
    contentFields.getFieldDescriptor("markupType").setConverter(null);
    contentFields.getFieldDescriptor("markupType").setWidth(150);
    contentFields.getFieldDescriptor("markup").setFieldClass(MarkupField.class);
    contentFields.getFieldDescriptor("markup").setWidth(700);
    contentFields.getFieldDescriptor("markup").getValidators().clear();
    contentFields.getFieldDescriptor("markup").setCollapsed(true);
    contentFields.getFieldDescriptor("title").setWidth(-1);

    FieldSetDescriptorRegister.registerFieldSetDescriptor(Content.class, contentFields);

    // Describe feedback view fields.
    final FieldSetDescriptor assetFields = new FieldSetDescriptor(Asset.class);

    assetFields.setVisibleFieldIds(new String[]{
            "name", "size", "extension", "type", "description", "created", "modified"
    });

    assetFields.getFieldDescriptor("created").setReadOnly(true);
    assetFields.getFieldDescriptor("created").setCollapsed(true);
    assetFields.getFieldDescriptor("modified").setReadOnly(true);
    assetFields.getFieldDescriptor("modified").setCollapsed(true);

    assetFields.getFieldDescriptor("name").setReadOnly(true);
    assetFields.getFieldDescriptor("name").setRequired(true);
    assetFields.getFieldDescriptor("extension").setReadOnly(true);
    assetFields.getFieldDescriptor("extension").setRequired(true);
    assetFields.getFieldDescriptor("type").setReadOnly(true);
    assetFields.getFieldDescriptor("type").setRequired(true);
    assetFields.getFieldDescriptor("size").setReadOnly(true);
    assetFields.getFieldDescriptor("size").setRequired(true);
   // assetFields.getFieldDescriptor("size").setDefaultValue(0);
    assetFields.getFieldDescriptor("size").setConverter(new StringToIntegerConverter());
    assetFields.getFieldDescriptor("description").setRequired(false);
    assetFields.getFieldDescriptor("description").setWidth(-1);

    FieldSetDescriptorRegister.registerFieldSetDescriptor(Asset.class, assetFields);

}
 
开发者ID:bubblecloud,项目名称:ilves,代码行数:76,代码来源:ContentModule.java

示例10: getContent

import com.vaadin.data.util.converter.StringToIntegerConverter; //导入依赖的package包/类
@Override
public Component getContent()
{
	final VerticalLayout layout = new VerticalLayout();
	layout.setMargin(true);

	this.fieldValidator = new FieldValidator();
	this.formLayout = new MultiColumnFormLayout<IntegerCrudEntity>(1, null); // new
	// ValidatingFieldGroup(dynamicFieldItem));
	this.formLayout.setColumnLabelWidth(0, 150);
	this.formLayout.setColumnFieldWidth(0, 250);
	this.formLayout.setSizeFull();

	final Label label = new Label("<h1>Enter the details for the group of books you want to import.</h1>",
			ContentMode.HTML);

	layout.addComponent(label);
	layout.addComponent(this.formLayout);

	this.firstTicketNoField = this.formLayout.addTextField("First Book Ticket No.");
	this.noOfBooksField = this.formLayout.addTextField("No. of consecutive Books");
	this.noOfBooksField
	.setDescription("The no of Books to be imported. They must be in a consecutive number range!");
	this.lastTicketNoField = this.formLayout.addTextField("Last Ticket No. of Last Book");
	this.lastTicketNoField
			.setDescription("Enter the ticket no of the 'last' ticket of the 'last' book. This is used to check that all of the details are correct.");

	this.firstTicketNoField
	.addValidator(new IntegerRangeValidator("First Ticket No must be an integer", 0, 6000000));
	this.firstTicketNoField.setConverter(new StringToIntegerConverter());
	this.firstTicketNoField.setRequired(true);
	this.fieldValidator.addField(this.firstTicketNoField);

	this.noOfBooksField.addValidator(new IntegerRangeValidator("No. of Books must be an integer", 1, 1000));
	this.noOfBooksField.setConverter(new StringToIntegerConverter());
	this.noOfBooksField.setRequired(true);
	this.fieldValidator.addField(this.noOfBooksField);

	this.lastTicketNoField
	.addValidator(new IntegerRangeValidator("Last Ticket No. must be an integer", 1, 6000000));
	this.lastTicketNoField.setConverter(new StringToIntegerConverter());
	this.lastTicketNoField.setRequired(true);
	this.fieldValidator.addField(this.lastTicketNoField);

	final Label labelImport = new Label("<h1>Clicking Next will import the books!</h1>", ContentMode.HTML);

	layout.addComponent(labelImport);

	return layout;
}
 
开发者ID:bsutton,项目名称:scoutmaster,代码行数:51,代码来源:TicketRangeStep.java


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