use of com.vaadin.ui.ItemCaptionGenerator in project Eclipse-Kuksa-Automotive-Edge-Extension by max-grzanna.
the class AppsListView method init.
@PostConstruct
public void init() {
int currentpage = 1;
int limit = 9;
int total;
Page<App> appsList = findByText(serachText.getValue(), comboBox.getValue(), currentpage - 1, limit);
total = (int) appsList.getTotalElements();
appslayout = AppGridView.crateAppGridView(appsList, 3);
navHeaderLayout = new NavHeader().create(VIEW_NAME, VaadinSession.getCurrent().getAttribute("isCurrentUserAdmin").toString());
mainlayout.addComponent(navHeaderLayout);
ItemCaptionGenerator<String> icg = new ItemCaptionGenerator<String>() {
@Override
public String apply(String item) {
return appCategoryService.findById(Long.parseLong(item)).getName();
}
};
comboBox.setItemCaptionGenerator(icg);
comboBox.setItems(appCategoryService.getAllId());
comboBox.setPlaceholder("Select a category");
comboBox.setEmptySelectionCaption("All");
comboBox.setEmptySelectionAllowed(true);
comboBox.addValueChangeListener(event -> {
listApps(serachText.getValue(), event.getValue());
});
actions = new HorizontalLayout(comboBox, serachText);
actions.setStyleName("v-actions");
serachText.setPlaceholder("Search by App Name");
// Listen changes made by the filter textbox, refresh data from backend
serachText.addValueChangeListener(event -> {
listApps(event.getValue(), comboBox.getValue());
});
mainlayout.addComponent(actions);
mainlayout.addComponent(appslayout);
paginationComponent = createPaginationComponent(total, currentpage, limit);
mainlayout.addComponent(paginationComponent);
setCompositionRoot(mainlayout);
}
Aggregations