public SampleCrudView() { setSizeFull(); addStyleName("crud-view"); HorizontalLayout topLayout = createTopBar(); grid = new ProductGrid(); grid.addSelectionListener( new SelectionListener() { @Override public void select(SelectionEvent event) { viewLogic.rowSelected(grid.getSelectedRow()); } }); form = new ProductForm(viewLogic); // form.setCategories(DataService.get().getAllCategories());//should be in the Logic init, views // should not know about database // the main View could be an intermediate between sub-view and the main Logic // VO.setFormDataCategories(Ob) -> form.setCategories(Ob) VerticalLayout barAndGridLayout = new VerticalLayout(); barAndGridLayout.addComponent(topLayout); barAndGridLayout.addComponent(grid); barAndGridLayout.setMargin(true); barAndGridLayout.setSpacing(true); barAndGridLayout.setSizeFull(); barAndGridLayout.setExpandRatio(grid, 1); barAndGridLayout.setStyleName("crud-main-layout"); addComponent(barAndGridLayout); addComponent(form); viewLogic.init(); }
public int compareTo(ProductGrid paramProductGrid) { if (this == paramProductGrid) {} do { return 0; paramProductGrid = paramProductGrid.getProduct(); } while (paramProductGrid == null); switch (sSortByCriteria) { default: return compareByPopularityDesc(paramProductGrid); case 0: return compareByPopularityDesc(paramProductGrid); case 2: return compareByPriceDesc(paramProductGrid); case 1: return compareByPriceAsc(paramProductGrid); case 3: return compareByNameAsc(paramProductGrid); } return compareByNameDesc(paramProductGrid); }
public void removeProduct(Product product) { grid.remove(product); }
public void refreshProduct(Product product) { grid.refresh(product); grid.scrollTo(product); }
public void showProducts(Collection<Product> products) { grid.setProducts(products); }
public Product getSelectedRow() { return grid.getSelectedRow(); }
public void selectRow(Product row) { ((SelectionModel.Single) grid.getSelectionModel()).select(row); }
public void clearSelection() { grid.getSelectionModel().reset(); }
public int compare( ProductGrid paramAnonymousProductGrid1, ProductGrid paramAnonymousProductGrid2) { return paramAnonymousProductGrid1.compareTo(paramAnonymousProductGrid2); }