Ejemplo n.º 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();
  }