Example #1
0
  @AutoGenerated
  private VerticalLayout buildMainLayout() {
    // common part: create layout
    mainLayout = new VerticalLayout();
    mainLayout.setImmediate(false);
    mainLayout.setWidth("100%");
    mainLayout.setHeight("100%");
    mainLayout.setMargin(false);

    // top-level component properties
    setWidth("100.0%");
    setHeight("100.0%");

    // dataGridView_1
    dgCalendar =
        new DataGridView() {
          @Override
          protected String formatPropertyValue(Object rowId, Object colId, Property property) {
            // Format by property type
            if (property.getType() == Date.class) {
              SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

              return df.format((Date) property.getValue());
            }

            return super.formatPropertyValue(rowId, colId, property);
          }
        };

    dgCalendar.setImmediate(false);
    dgCalendar.setWidth("100.0%");
    dgCalendar.setHeight("100.0%");
    mainLayout.addComponent(dgCalendar);
    mainLayout.setExpandRatio(dgCalendar, 1.0f);

    return mainLayout;
  }
Example #2
0
  private void initView() {
    // initialize Slide View Organization View
    dgCalendar.setImmediate(true);

    refreshBindindSource();

    // STEP 01: create grid view for slide Organization View
    try {
      dgCalendar.setBindingSource(bsCalendar);
      dgCalendar.setVisibleColumns(
          new String[] {
            "name",
            "description",
            "calendarType.description",
            "calendarFromDate",
            "calendarToDate",
            "observation",
            "active"
          });
      dgCalendar.setColumnHeaders(
          new String[] {
            "Nombre", "DescripciĆ³n", "Tipo", "Fecha Inicio", "Fecha Fin", "Observaciones", "Activo"
          });
      dgCalendar.setEditable(true);
      dgCalendar.setTableFieldFactory(
          new TableFieldFactory() {
            @Override
            public Field createField(
                Container container, Object itemId, Object propertyId, Component uiContext) {
              if ("active".equals(propertyId)) {
                CheckBox field = new CheckBox();
                field.setReadOnly(true);
                return field;
              }

              return null;
            }
          });

      dgCalendar.setColumnCollapsed("observation", true);
    } catch (Exception ex) {
      ex.getMessage();
    }

    // STEP 02: create toolbar for slide Organization View
    navigationToolbar = new NavigationToolbar(0, bsCalendar, viewContainer);
    editionToolbar = new EditionToolbar(1, bsCalendar);
    boxToolbar = new BoxToolbar(2, bsCalendar);

    navigationToolbar.addListenerDownButton(this);
    navigationToolbar.addListenerRefreshButton(this);

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);
  }