本文整理汇总了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 "";
}
});
}
示例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);
}
示例3: LocaleSelect
import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public LocaleSelect() {
setItemCaptionGenerator(new ItemCaptionGenerator<Locale>() {
@Override
public String apply(Locale option) {
return option.getDisplayName(option);
}
});
}
示例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;
}
示例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);
}
示例6: setCaptionGenerator
import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public void setCaptionGenerator(ItemCaptionGenerator<ET> cg) {
cb.setItemCaptionGenerator(cg);
}
示例7: setCaptionGenerator
import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public void setCaptionGenerator(ItemCaptionGenerator<ET> cg) {
itemCaptionGenerator = cg;
}
示例8: setDescriptionGenerator
import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public void setDescriptionGenerator(ItemCaptionGenerator<ET> cg) {
descriptionGenerator = cg;
}
示例9: withItemCaptionGenerator
import com.vaadin.ui.ItemCaptionGenerator; //导入依赖的package包/类
public EnumSelect<T> withItemCaptionGenerator(ItemCaptionGenerator<T> itemCaptionGenerator) {
setItemCaptionGenerator(itemCaptionGenerator);
return this;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}