Example #1
0
  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);
 }
Example #3
0
 public void removeProduct(Product product) {
   grid.remove(product);
 }
Example #4
0
 public void refreshProduct(Product product) {
   grid.refresh(product);
   grid.scrollTo(product);
 }
Example #5
0
 public void showProducts(Collection<Product> products) {
   grid.setProducts(products);
 }
Example #6
0
 public Product getSelectedRow() {
   return grid.getSelectedRow();
 }
Example #7
0
 public void selectRow(Product row) {
   ((SelectionModel.Single) grid.getSelectionModel()).select(row);
 }
Example #8
0
 public void clearSelection() {
   grid.getSelectionModel().reset();
 }
 public int compare(
     ProductGrid paramAnonymousProductGrid1, ProductGrid paramAnonymousProductGrid2) {
   return paramAnonymousProductGrid1.compareTo(paramAnonymousProductGrid2);
 }