public void init(String title, Class<T> typeOfRows, String objectCode) {
    setModal(true);
    setClosable(true);
    setResizable(false);
    setDraggable(false);
    setHeight("90%");
    setWidth("100%");
    setCaption("<b>" + title + "</b>");
    setCaptionAsHtml(true);

    this.objectCode = objectCode;

    dfFrom = new DateField();
    dfFrom.setCaption("Từ Ngày");
    dfFrom.addStyleName("date-field-caption");
    dfTo = new DateField();
    dfTo.setCaption("Đến Ngày");
    dfTo.addStyleName("date-field-caption");
    btnOk = new Button("Xem Báo Cáo");
    btnOk.addStyleName(ValoTheme.BUTTON_SMALL);
    btnOk.addStyleName(ValoTheme.BUTTON_FRIENDLY);
    btnOk.addStyleName("margin-top-2px");

    gridSummaryReportDetail = new MGrid<ReportDetailSummary>(ReportDetailSummary.class);
    gridSummaryReportDetail.setWidth("50%");
    gridSummaryReportDetail.setHeight("77px");
    gridSummaryReportDetail.setEditorEnabled(false);
    gridSummaryReportDetail.setSelectionMode(SelectionMode.NONE);
    gridSummaryReportDetail.withProperties(
        "openingStock", "issueInPeriod", "receiptInPeriod", "closingStock");

    gridContent = new MGrid<>(typeOfRows);

    VerticalLayout wrapper = new VerticalLayout();
    wrapper.setSpacing(true);

    // Add first line
    HorizontalLayout hrzDateFields = new HorizontalLayout();
    wrapper.addComponent(hrzDateFields);
    wrapper.setComponentAlignment(hrzDateFields, Alignment.TOP_CENTER);
    hrzDateFields.addComponent(dfFrom);
    hrzDateFields.addComponent(dfTo);
    hrzDateFields.addComponent(btnOk);
    hrzDateFields.addStyleName("margin-left-right-20px df-report-detail-style");

    // Add second line
    wrapper.addComponent(gridSummaryReportDetail);
    wrapper.setComponentAlignment(gridSummaryReportDetail, Alignment.TOP_CENTER);

    wrapper.addComponent(gridContent);
    gridContent.setWidth("100%");
    gridContent.setHeight("10%");
    gridContent.setEditorEnabled(false);
    gridContent.setSelectionMode(SelectionMode.NONE);

    gridContentProperties = new ArrayList<String>();

    withTableProperties(getProperties());
    withHeaderNames(getHeaderNames());
    setContent(wrapper);

    btnOk.addClickListener(
        new ClickListener() {
          private static final long serialVersionUID = -2918006939436642296L;

          @Override
          public void buttonClick(ClickEvent event) {
            if (!objectCode.isEmpty()) {
              generateSummaryReportDetails(dfFrom.getValue(), dfTo.getValue());
              generateReportDetails(dfFrom.getValue(), dfTo.getValue());
            }
          }
        });
  }
Ejemplo n.º 2
0
  public DateFields() {
    setMargin(true);

    Label h1 = new Label("Date Fields");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    row.setSpacing(true);
    addComponent(row);

    DateField date = new DateField("Default resolution");
    setDate(date);
    row.addComponent(date);

    date = new DateField("Error");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(date);

    date = new DateField("Error, borderless");
    setDate(date);
    date.setComponentError(new UserError("Fix it, now!"));
    date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
    row.addComponent(date);

    CssLayout group = new CssLayout();
    group.setCaption("Grouped with a Button");
    group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    row.addComponent(group);

    final DateField date2 = new DateField();
    group.addComponent(date2);

    Button today =
        new Button(
            "Today",
            new ClickListener() {
              @Override
              public void buttonClick(ClickEvent event) {
                date2.setValue(new Date());
              }
            });
    group.addComponent(today);

    date = new DateField("Default resolution, explicit size");
    setDate(date);
    row.addComponent(date);
    date.setWidth("260px");
    date.setHeight("60px");

    date = new DateField("Second resolution");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    row.addComponent(date);

    date = new DateField("Minute resolution");
    setDate(date);
    date.setResolution(Resolution.MINUTE);
    row.addComponent(date);

    date = new DateField("Hour resolution");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    row.addComponent(date);

    date = new DateField("Disabled");
    setDate(date);
    date.setResolution(Resolution.HOUR);
    date.setEnabled(false);
    row.addComponent(date);

    date = new DateField("Day resolution");
    setDate(date);
    date.setResolution(Resolution.DAY);
    row.addComponent(date);

    date = new DateField("Month resolution");
    setDate(date);
    date.setResolution(Resolution.MONTH);
    row.addComponent(date);

    date = new DateField("Year resolution");
    setDate(date);
    date.setResolution(Resolution.YEAR);
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color1");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color2");
    row.addComponent(date);

    date = new DateField("Custom color");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName("color3");
    row.addComponent(date);

    date = new DateField("Small");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_SMALL);
    row.addComponent(date);

    date = new DateField("Large");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_LARGE);
    row.addComponent(date);

    date = new DateField("Borderless");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_BORDERLESS);
    row.addComponent(date);

    date = new DateField("Week numbers");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);

    date = new DateField("US locale");
    setDate(date);
    date.setResolution(Resolution.SECOND);
    date.setLocale(new Locale("en", "US"));
    row.addComponent(date);

    date = new DateField("Custom format");
    setDate(date);
    date.setDateFormat("E dd/MM/yyyy");
    row.addComponent(date);

    date = new DateField("Tiny");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_TINY);
    row.addComponent(date);

    date = new DateField("Huge");
    setDate(date);
    date.setResolution(Resolution.DAY);
    date.addStyleName(ValoTheme.DATEFIELD_HUGE);
    row.addComponent(date);

    date = new InlineDateField("Date picker");
    setDate(date);
    setDateRange(date);
    row.addComponent(date);

    date = new InlineDateField("Date picker with week numbers");
    setDate(date);
    date.setLocale(new Locale("fi", "fi"));
    date.setShowISOWeekNumbers(true);
    row.addComponent(date);

    PropertysetItem item = new PropertysetItem();
    item.addItemProperty("date", new ObjectProperty<Date>(getDefaultDate()));

    FormLayout form = new FormLayout();
    form.setMargin(false);

    FieldGroup binder = new FieldGroup(item);
    form.addComponent(binder.buildAndBind("Picker in read-only field group", "date"));
    binder.setReadOnly(true);

    row.addComponent(form);
  }