use of io.metadew.iesi.cockpit.backend.data.Category in project iesi by metadew.
the class MockDataGenerator method createCategory.
private static Category createCategory(String name) {
Category c = new Category();
c.setId(nextCategoryId++);
c.setName(name);
return c;
}
use of io.metadew.iesi.cockpit.backend.data.Category in project iesi by metadew.
the class AdminView method createCategoryEditor.
private Component createCategoryEditor(Category category) {
TextField nameField = new TextField();
if (category.getId() < 0) {
nameField.focus();
}
Button deleteButton = new Button(VaadinIcon.MINUS_CIRCLE_O.create(), event -> {
DataService.get().deleteCategory(category.getId());
dataProvider.getItems().remove(category);
dataProvider.refreshAll();
Notification.show("Category Deleted.");
});
deleteButton.addThemeVariants(ButtonVariant.LUMO_ERROR);
BeanValidationBinder<Category> binder = new BeanValidationBinder<>(Category.class);
binder.forField(nameField).bind("name");
binder.setBean(category);
binder.addValueChangeListener(event -> {
if (binder.isValid()) {
DataService.get().updateCategory(category);
deleteButton.setEnabled(true);
newCategoryButton.setEnabled(true);
Notification.show("Category Saved.");
}
});
deleteButton.setEnabled(category.getId() > 0);
HorizontalLayout layout = new HorizontalLayout(nameField, deleteButton);
layout.setFlexGrow(1);
return layout;
}
use of io.metadew.iesi.cockpit.backend.data.Category in project iesi by metadew.
the class MockDataGenerator method createCategories.
static List<Category> createCategories() {
List<Category> categories = new ArrayList<Category>();
for (String name : categoryNames) {
Category c = createCategory(name);
categories.add(c);
}
return categories;
}
Aggregations