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


Java ItemCaptionGenerator类代码示例

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


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

示例1: updateMessageStrings

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
@Override
    public void updateMessageStrings() {
        Messages messages = Messages.getInstance();
        //        setValue(getLocale());
//        setItemCaption(Locale.ENGLISH, messages.getMessage("languageSelector.en"));
//        setItemCaption(Locale.FRENCH, messages.getMessage("languageSelector.fr"));
        setItemCaptionGenerator(new ItemCaptionGenerator<Locale>() {
            private static final long serialVersionUID = -1634395306396320788L;

            @Override
            public String apply(Locale option) {
                if (option == Locale.CANADA_FRENCH) {
                    return messages.getMessage("languageSelector.fr");
                } else if (option == Locale.ENGLISH) {
                    return messages.getMessage("languageSelector.en");
                }
                return "";
            }
        });
    }
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:21,代码来源:LanguageSelector.java

示例2: init

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
@PostConstruct
void init() {
	// get cities inside germany
	List<City> cities = cityRepository.findByCountryOrderByNameAsc("DE");

	// create combobox
	ComboBox<City> combobox = new ComboBox<City>("Select a City");
	combobox.setItems(cities);
	combobox.setWidth("200px");
	combobox.setItemCaptionGenerator(new ItemCaptionGenerator<City>() {
		
		private static final long serialVersionUID = -5328245622581583103L;

		@Override
		public String apply(City item) {
			return item.getName();
		}
	}); 

	// select listener
	combobox.addSelectionListener(new SingleSelectionListener<City>() {
		
		private static final long serialVersionUID = -5456043484862675591L;

		@Override
		public void selectionChange(SingleSelectionEvent<City> event) {
			LOG.info("City <"+event.getSelectedItem().toString()+"> selected.");
			
		}
	});
	
	addComponent(combobox);
}
 
开发者ID:theMightyFly,项目名称:demo-spring-vaadin,代码行数:34,代码来源:CityComboboxView.java

示例3: LocaleSelect

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public LocaleSelect() {
    setItemCaptionGenerator(new ItemCaptionGenerator<Locale>() {
        @Override
        public String apply(Locale option) {
            return option.getDisplayName(option);
        }
    });
}
 
开发者ID:viritin,项目名称:viritin,代码行数:9,代码来源:LocaleSelect.java

示例4: withItemCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public default THIS withItemCaptionGenerator(ItemCaptionGenerator<VALUE> itemCaptionGenerator) {
    ((AbstractMultiSelect<VALUE>) this).setItemCaptionGenerator(itemCaptionGenerator);
    return (THIS) this;
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:6,代码来源:FluentAbstractMultiSelect.java

示例5: test

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
@Test
public void test() {
    Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
    Person p2 = new Person(2, "George", LocalDate.of(1991, Month.JUNE, 19));
    Person p3 = new Person(3, "Tim", LocalDate.of(1995, Month.APRIL, 7));

    List<Person> persons = Arrays.asList(p1, p2, p3);

    ItemCaptionGenerator<Person> captionGenerator = Person::getName;
    IconGenerator<Person> iconProvider = person -> VaadinIcons.USER;
    StyleGenerator<Person> styleGenerator = person -> "test";

    FTree<Person> tree = new FTree<Person>().withCaption("My Tree", true)
                                            .withContentMode(ContentMode.HTML)
                                            .withDescription("description", ContentMode.HTML)
                                            .withCollapseListener(event -> System.out.println("collapsed"))
                                            .withExpandListener(event -> System.out.println("expanded"))
                                            .withAutoRecalculateWidth(false)
                                            .withItemCaptionGenerator(captionGenerator)
                                            .withItemClickListener(event -> System.out.println("clicked"))
                                            .withItemIconGenerator(iconProvider)
                                            .withItems(persons)
                                            .withItemCollapseAllowedProvider(person -> person.getId() > 1)
                                            .withSelectionMode(SelectionMode.MULTI)
                                            .withSelectionListener(event -> System.out.println("selected"))
                                            .withRowHeight(14)
                                            .withStyleGenerator(styleGenerator)
                                            .withWidth("50%")
                                            .withId("treeId");

    assertEquals("My Tree", tree.getCaption());
    assertEquals("treeId", tree.getId());
    assertEquals("description", tree.getDescription());
    assertFalse(tree.isAutoRecalculateWidth());
    assertEquals(1, tree.getListeners(CollapseEvent.class).size());
    assertEquals(1, tree.getListeners(ExpandEvent.class).size());
    assertEquals(1, tree.getListeners(ItemClick.class).size());
    assertTrue(tree.getSelectionModel() instanceof MultiSelectionModel);
    assertEquals(captionGenerator, tree.getItemCaptionGenerator());
    assertEquals(iconProvider, tree.getItemIconGenerator());
    assertEquals(styleGenerator, tree.getStyleGenerator());
    assertEquals(50, tree.getWidth(), 0);
    assertEquals(Unit.PERCENTAGE, tree.getWidthUnits());
    assertTrue(tree.getDataProvider() instanceof HierarchicalDataProvider);
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:46,代码来源:FTreeTest.java

示例6: setCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public void setCaptionGenerator(ItemCaptionGenerator<ET> cg) {
    cb.setItemCaptionGenerator(cg);
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:4,代码来源:SubSetSelector.java

示例7: setCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public void setCaptionGenerator(ItemCaptionGenerator<ET> cg) {
    itemCaptionGenerator = cg;
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:4,代码来源:SubSetSelectorDraggable.java

示例8: setDescriptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public void setDescriptionGenerator(ItemCaptionGenerator<ET> cg) {
    descriptionGenerator = cg;
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:4,代码来源:SubSetSelectorDraggable.java

示例9: withItemCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public EnumSelect<T> withItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator) {
	setItemCaptionGenerator(itemCaptionGenerator);
	return this;
}
 
开发者ID:viritin,项目名称:viritin,代码行数:5,代码来源:EnumSelect.java

示例10: withItemCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
/**
 * Sets the item caption generator that is used to produce the strings shown
 * as the text for each item. By default, {@link String#valueOf(Object)} is
 * used.
 *
 * @param captionGenerator
 *            the item caption provider to use, not <code>null</code>
 *            
 * @return this for method chaining
 * @see Tree#setItemCaptionGenerator(ItemCaptionGenerator)
 */
@SuppressWarnings("unchecked")
public default THIS withItemCaptionGenerator(ItemCaptionGenerator<ITEM> captionGenerator) {
    ((Tree<ITEM>) this).setItemCaptionGenerator(captionGenerator);
    return (THIS) this;
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:17,代码来源:FluentTree.java

示例11: withItemCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
/**
 * Sets the item caption generator that is used to produce the strings shown
 * in the combo box for each item. By default,
 * {@link String#valueOf(Object)} is used.
 *
 * @param itemCaptionGenerator
 *            the item caption provider to use, not null
 * @return this for method chaining
 * @see NativeSelect#setItemCaptionGenerator(ItemCaptionGenerator)
 */
@SuppressWarnings("unchecked")
public default THIS withItemCaptionGenerator(ItemCaptionGenerator<ITEM> itemCaptionGenerator) {
    ((NativeSelect<ITEM>) this).setItemCaptionGenerator(itemCaptionGenerator);
    return (THIS) this;
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:16,代码来源:FluentNativeSelect.java

示例12: withItemCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
/**
 * Sets the item caption generator that is used to produce the strings shown
 * in the combo box for each item. By default,
 * {@link String#valueOf(Object)} is used.
 *
 * @param itemCaptionGenerator
 *            the item caption provider to use, not null
 * @return this for method chaining
 * @see ComboBox#setItemCaptionGenerator(ItemCaptionGenerator)
 */
@SuppressWarnings("unchecked")
public default THIS withItemCaptionGenerator(ItemCaptionGenerator<ITEM> itemCaptionGenerator) {
    ((ComboBox<ITEM>) this).setItemCaptionGenerator(itemCaptionGenerator);
    return (THIS) this;
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:16,代码来源:FluentComboBox.java

示例13: withItemCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
/**
 * Sets the item caption generator that is used to produce the strings shown
 * in the radio button group for each item. By default,
 * {@link String#valueOf(Object)} is used.
 *
 * @param itemCaptionGenerator
 *            the item caption provider to use, not null
 * @return this for method chaining
 * @see RadioButtonGroup#setItemCaptionGenerator(ItemCaptionGenerator)
 */
@SuppressWarnings("unchecked")
public default THIS withItemCaptionGenerator(ItemCaptionGenerator<ITEM> itemCaptionGenerator) {
    ((RadioButtonGroup<ITEM>) this).setItemCaptionGenerator(itemCaptionGenerator);
    return (THIS) this;
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:16,代码来源:FluentRadioButtonGroup.java

示例14: setCaptionGenerator

import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
/**
 * Sets the ItemCaptionGenerator for creating the label value.
 *
 * @param captionGenerator the caption generator used to format the
 * displayed property
 */
public void setCaptionGenerator(ItemCaptionGenerator<T> captionGenerator) {
    this.captionGenerator = captionGenerator;
    updateLabel();
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:11,代码来源:LabelField.java


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