// Path: example-app/example-app-widgetset/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/ResetButtonForTextField.java
// public class ResetButtonForTextField extends AbstractExtension {
// 
//     public static void extend(TextField field) {
//         new ResetButtonForTextField().extend((AbstractClientConnector) field);
//     }
// }
// 
// Path: example-app/example-app-backend/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/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: example-app/example-app-backend/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/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;
// 
//     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;
//     }
// 
// }


import com.github.mcollovati.vaadin.exampleapp.samples.ResetButtonForTextField;
import com.github.mcollovati.vaadin.exampleapp.samples.backend.DataService;
import com.github.mcollovati.vaadin.exampleapp.samples.backend.data.Product;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
package com.github.mcollovati.vaadin.exampleapp.samples.crud;



/**
 * A view for performing create-read-update-delete operations on products.
 *
 * See also {@link SampleCrudLogic} for fetching the data, the actual CRUD
 * operations and controlling the view based on events from outside.
 */
public class SampleCrudView extends CssLayout implements View {

    public static final String VIEW_NAME = "Inventory";
    private ProductGrid grid;
    private ProductForm form;
    private TextField filter;

    private SampleCrudLogic viewLogic = new SampleCrudLogic(this);
    private Button newProduct;

    private ProductDataProvider dataProvider = new ProductDataProvider();

    public SampleCrudView() {
        setSizeFull();
        addStyleName("crud-view");
        HorizontalLayout topLayout = createTopBar();

        grid = new ProductGrid();
        grid.setDataProvider(dataProvider);
        grid.asSingleSelect().addValueChangeListener(
                event -> viewLogic.rowSelected(event.getValue()));

        form = new ProductForm(viewLogic);
// Path: example-app/example-app-widgetset/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/ResetButtonForTextField.java
// public class ResetButtonForTextField extends AbstractExtension {
// 
//     public static void extend(TextField field) {
//         new ResetButtonForTextField().extend((AbstractClientConnector) field);
//     }
// }
// 
// Path: example-app/example-app-backend/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/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: example-app/example-app-backend/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/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;
// 
//     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;
//     }
// 
// }


// Path: example-app/example-app-ui/src/main/java/com/github/mcollovati/vaadin/exampleapp/samples/crud/SampleCrudView.java
import com.github.mcollovati.vaadin.exampleapp.samples.ResetButtonForTextField;
import com.github.mcollovati.vaadin.exampleapp.samples.backend.DataService;
import com.github.mcollovati.vaadin.exampleapp.samples.backend.data.Product;
import com.vaadin.icons.VaadinIcons;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Notification.Type;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;

package com.github.mcollovati.vaadin.exampleapp.samples.crud;



/**
 * A view for performing create-read-update-delete operations on products.
 *
 * See also {@link SampleCrudLogic} for fetching the data, the actual CRUD
 * operations and controlling the view based on events from outside.
 */
public class SampleCrudView extends CssLayout implements View {

    public static final String VIEW_NAME = "Inventory";
    private ProductGrid grid;
    private ProductForm form;
    private TextField filter;

    private SampleCrudLogic viewLogic = new SampleCrudLogic(this);
    private Button newProduct;

    private ProductDataProvider dataProvider = new ProductDataProvider();

    public SampleCrudView() {
        setSizeFull();
        addStyleName("crud-view");
        HorizontalLayout topLayout = createTopBar();

        grid = new ProductGrid();
        grid.setDataProvider(dataProvider);
        grid.asSingleSelect().addValueChangeListener(
                event -> viewLogic.rowSelected(event.getValue()));

        form = new ProductForm(viewLogic);
        form.setCategories(DataService.get().getAllCategories());