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()); } } }); }
/** * Function is used to set properties for table content * * @param properties * @return */ public AbstractReportDetailsView<T> withTableProperties(String... properties) { gridContent.withProperties(properties); gridContentProperties.clear(); gridContentProperties.addAll(Arrays.asList(properties)); return this; }