// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/MainLayout.java
// @StyleSheet("css/shared-styles.css")
// @Theme(value = Lumo.class, variant = Lumo.DARK)
// public class MainLayout extends FlexLayout implements RouterLayout {
//     private Menu menu;
// 
//     public MainLayout() {
//         setSizeFull();
//         setClassName("main-layout");
// 
//         menu = new Menu();
//         menu.addView(SampleCrudView.class, SampleCrudView.VIEW_NAME,
//                 VaadinIcon.EDIT.create());
//         menu.addView(AboutView.class, AboutView.VIEW_NAME,
//                 VaadinIcon.INFO_CIRCLE.create());
// 
//         add(menu);
//     }
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/DataService.java
// public abstract class DataService implements Serializable {
// 
//     public abstract Collection<Product> getAllProducts();
// 
//     public abstract Collection<Category> getAllCategories();
// 
//     public abstract void updateProduct(Product p);
// 
//     public abstract void deleteProduct(int productId);
// 
//     public abstract Product getProductById(int productId);
// 
//     public static DataService get() {
//         return MockDataService.getInstance();
//     }
// 
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/data/Product.java
// public class Product implements Serializable {
// 
//     @NotNull
//     private int id = -1;
//     @NotNull
//     @Size(min = 2, message = "Product name must have at least two characters")
//     private String productName = "";
//     @Min(0)
//     private BigDecimal price = BigDecimal.ZERO;
//     private Set<Category> category;
//     @Min(value = 0, message = "Can't have negative amount in stock")
//     private int stockCount = 0;
//     @NotNull
//     private Availability availability = Availability.COMING;
// 
//     private String image;
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getProductName() {
//         return productName;
//     }
// 
//     public void setProductName(String productName) {
//         this.productName = productName;
//     }
// 
//     public BigDecimal getPrice() {
//         return price;
//     }
// 
//     public void setPrice(BigDecimal price) {
//         this.price = price;
//     }
// 
//     public Set<Category> getCategory() {
//         return category;
//     }
// 
//     public void setCategory(Set<Category> category) {
//         this.category = category;
//     }
// 
//     public int getStockCount() {
//         return stockCount;
//     }
// 
//     public void setStockCount(int stockCount) {
//         this.stockCount = stockCount;
//     }
// 
//     public Availability getAvailability() {
//         return availability;
//     }
// 
//     public void setAvailability(Availability availability) {
//         this.availability = availability;
//     }
// 
//     public boolean isNewProduct() {
//         return getId() == -1;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public void setImage(String image) {
//         this.image = image;
//     }
// }


import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.BeforeEvent;
import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.OptionalParameter;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias;
import com.github.mcollovati.vertxvaadin.flowdemo.MainLayout;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.DataService;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.data.Product;
        newProduct = new Button("New product");
        newProduct.getElement().getThemeList().add("primary");
        newProduct.setIcon(VaadinIcon.PLUS_CIRCLE.create());
        newProduct.addClickListener(click -> viewLogic.newProduct());

        HorizontalLayout topLayout = new HorizontalLayout();
        topLayout.setWidth("100%");
        topLayout.add(filter);
        topLayout.add(newProduct);
        topLayout.setVerticalComponentAlignment(Alignment.START, filter);
        topLayout.expand(filter);
        return topLayout;
    }

    public void showError(String msg) {
        Notification.show(msg);
    }

    public void showSaveNotification(String msg) {
        Notification.show(msg);
    }

    public void setNewProductEnabled(boolean enabled) {
        newProduct.setEnabled(enabled);
    }

    public void clearSelection() {
        grid.getSelectionModel().deselectAll();
    }

// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/MainLayout.java
// @StyleSheet("css/shared-styles.css")
// @Theme(value = Lumo.class, variant = Lumo.DARK)
// public class MainLayout extends FlexLayout implements RouterLayout {
//     private Menu menu;
// 
//     public MainLayout() {
//         setSizeFull();
//         setClassName("main-layout");
// 
//         menu = new Menu();
//         menu.addView(SampleCrudView.class, SampleCrudView.VIEW_NAME,
//                 VaadinIcon.EDIT.create());
//         menu.addView(AboutView.class, AboutView.VIEW_NAME,
//                 VaadinIcon.INFO_CIRCLE.create());
// 
//         add(menu);
//     }
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/DataService.java
// public abstract class DataService implements Serializable {
// 
//     public abstract Collection<Product> getAllProducts();
// 
//     public abstract Collection<Category> getAllCategories();
// 
//     public abstract void updateProduct(Product p);
// 
//     public abstract void deleteProduct(int productId);
// 
//     public abstract Product getProductById(int productId);
// 
//     public static DataService get() {
//         return MockDataService.getInstance();
//     }
// 
// }
// 
// Path: flow-bookstore/bookstore-backend/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/backend/data/Product.java
// public class Product implements Serializable {
// 
//     @NotNull
//     private int id = -1;
//     @NotNull
//     @Size(min = 2, message = "Product name must have at least two characters")
//     private String productName = "";
//     @Min(0)
//     private BigDecimal price = BigDecimal.ZERO;
//     private Set<Category> category;
//     @Min(value = 0, message = "Can't have negative amount in stock")
//     private int stockCount = 0;
//     @NotNull
//     private Availability availability = Availability.COMING;
// 
//     private String image;
// 
//     public int getId() {
//         return id;
//     }
// 
//     public void setId(int id) {
//         this.id = id;
//     }
// 
//     public String getProductName() {
//         return productName;
//     }
// 
//     public void setProductName(String productName) {
//         this.productName = productName;
//     }
// 
//     public BigDecimal getPrice() {
//         return price;
//     }
// 
//     public void setPrice(BigDecimal price) {
//         this.price = price;
//     }
// 
//     public Set<Category> getCategory() {
//         return category;
//     }
// 
//     public void setCategory(Set<Category> category) {
//         this.category = category;
//     }
// 
//     public int getStockCount() {
//         return stockCount;
//     }
// 
//     public void setStockCount(int stockCount) {
//         this.stockCount = stockCount;
//     }
// 
//     public Availability getAvailability() {
//         return availability;
//     }
// 
//     public void setAvailability(Availability availability) {
//         this.availability = availability;
//     }
// 
//     public boolean isNewProduct() {
//         return getId() == -1;
//     }
// 
//     public String getImage() {
//         return image;
//     }
// 
//     public void setImage(String image) {
//         this.image = image;
//     }
// }


// Path: flow-bookstore/bookstore-ui/src/main/java/com/github/mcollovati/vertxvaadin/flowdemo/crud/SampleCrudView.java
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.icon.VaadinIcon;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.BeforeEvent;
import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.OptionalParameter;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias;
import com.github.mcollovati.vertxvaadin.flowdemo.MainLayout;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.DataService;
import com.github.mcollovati.vertxvaadin.flowdemo.backend.data.Product;

        newProduct = new Button("New product");
        newProduct.getElement().getThemeList().add("primary");
        newProduct.setIcon(VaadinIcon.PLUS_CIRCLE.create());
        newProduct.addClickListener(click -> viewLogic.newProduct());

        HorizontalLayout topLayout = new HorizontalLayout();
        topLayout.setWidth("100%");
        topLayout.add(filter);
        topLayout.add(newProduct);
        topLayout.setVerticalComponentAlignment(Alignment.START, filter);
        topLayout.expand(filter);
        return topLayout;
    }

    public void showError(String msg) {
        Notification.show(msg);
    }

    public void showSaveNotification(String msg) {
        Notification.show(msg);
    }

    public void setNewProductEnabled(boolean enabled) {
        newProduct.setEnabled(enabled);
    }

    public void clearSelection() {
        grid.getSelectionModel().deselectAll();
    }

    public void selectRow(Product row) {