@Override protected boolean isApplicable() { if (target != null) { Entity selectedItem = target.getSingleSelected(); if (selectedItem != null) { return !Objects.equals(getItem().getDefaultTemplate(), selectedItem); } } return false; }
protected ReportTemplate getDefaultTemplate(Report report) { ReportTemplate defaultTemplate = report.getDefaultTemplate(); if (defaultTemplate == null) throw new ReportingException(String.format("No default template specified for report [%s]", report.getName())); return defaultTemplate; }
@Override protected void afterRemove(Set selected) { super.afterRemove(selected); Report report = getItem(); ReportTemplate defaultTemplate = report.getDefaultTemplate(); if (defaultTemplate != null && selected.contains(defaultTemplate)) { ReportTemplate newDefaultTemplate = null; if (templatesDs.getItems().size() == 1) { newDefaultTemplate = templatesDs.getItems().iterator().next(); } report.setDefaultTemplate(newDefaultTemplate); } } });
@Override protected void afterCommit(Entity entity) { ReportTemplate reportTemplate = (ReportTemplate) entity; ReportTemplate defaultTemplate = getItem().getDefaultTemplate(); if (defaultTemplate != null && defaultTemplate.equals(reportTemplate)) { getItem().setDefaultTemplate(reportTemplate); } } });
protected void setupDropZoneForTemplate() { final ReportTemplate defaultTemplate = getItem().getDefaultTemplate(); if (defaultTemplate != null) { invisibleFileUpload.setDropZone(new UploadField.DropZone(reportFields)); } else { invisibleFileUpload.setDropZone(null); } }
public void initTemplateAndOutputSelect() { if (report != null) { if (report.getTemplates() != null && report.getTemplates().size() > 1) { templateField.setValue(report.getDefaultTemplate()); setTemplateVisible(true); } templateField.addValueChangeListener(e -> updateOutputTypes()); updateOutputTypes(); } }
protected boolean validateInputOutputFormats() { ReportTemplate template = getItem().getDefaultTemplate(); if (template != null && !template.isCustom() && template.getReportOutputType() != ReportOutputType.CHART && template.getReportOutputType() != ReportOutputType.TABLE && template.getReportOutputType() != ReportOutputType.PIVOT_TABLE) { String inputType = template.getExt(); if (!ReportPrintHelper.getInputOutputTypesMapping().containsKey(inputType) || !ReportPrintHelper.getInputOutputTypesMapping().get(inputType).contains(template.getReportOutputType())) { showNotification(getMessage("inputOutputTypesError"), NotificationType.TRAY); return false; } } return true; }
checkReportOutputType(reportTemplate); } else { checkReportOutputType(report.getDefaultTemplate());
protected void showChart() { byte[] content = wizard.buildReport(true).getDefaultTemplate().getContent(); String chartDescriptionJson = new String(content, StandardCharsets.UTF_8); AbstractChartDescription chartDescription = AbstractChartDescription.fromJsonString(chartDescriptionJson); RandomChartDataGenerator randomChartDataGenerator = new RandomChartDataGenerator(); List<Map<String, Object>> randomChartData = randomChartDataGenerator.generateRandomChartData(chartDescription); ChartToJsonConverter chartToJsonConverter = new ChartToJsonConverter(); String chartJson = null; if (chartDescription instanceof PieChartDescription) { chartJson = chartToJsonConverter.convertPieChart((PieChartDescription) chartDescription, randomChartData); } else if (chartDescription instanceof SerialChartDescription) { chartJson = chartToJsonConverter.convertSerialChart((SerialChartDescription) chartDescription, randomChartData); } wizard.openFrame(wizard.chartPreviewBox, ShowChartController.JSON_CHART_SCREEN_ID, ParamsMap.of(ShowChartController.CHART_JSON_PARAMETER, chartJson)); } }
protected void updateOutputTypes() { if (!reportGuiManager.containsAlterableTemplate(report)) { setOutputTypeVisible(false); return; } ReportTemplate template; if (report.getTemplates() != null && report.getTemplates().size() > 1) { template = templateField.getValue(); } else { template = report.getDefaultTemplate(); } if (template != null && reportGuiManager.supportAlterableForTemplate(template)) { List<ReportOutputType> outputTypes = ReportPrintHelper.getInputOutputTypesMapping().get(template.getExt()); if (outputTypes != null && !outputTypes.isEmpty()) { outputTypeField.setOptionsList(outputTypes); if (outputTypeField.getValue() == null) { outputTypeField.setValue(template.getReportOutputType()); } setOutputTypeVisible(true); } else { outputTypeField.setValue(null); setOutputTypeVisible(false); } } else { outputTypeField.setValue(null); setOutputTypeVisible(false); } }
templateCreateAction.setAfterCommitHandler(entity -> { ReportTemplate reportTemplate = (ReportTemplate) entity; ReportTemplate defaultTemplate = getItem().getDefaultTemplate(); if (defaultTemplate == null) { getItem().setDefaultTemplate(reportTemplate);
protected void initGeneral() { invisibleFileUpload.addFileUploadSucceedListener(invisibleUpload -> { final ReportTemplate defaultTemplate = getItem().getDefaultTemplate(); if (defaultTemplate != null) { if (defaultTemplate.getOutputType() != CubaReportOutputType.chart) {
try { EntityManager em = persistence.getEntityManager(); ReportTemplate defaultTemplate = report.getDefaultTemplate(); List<ReportTemplate> loadedTemplates = report.getTemplates(); List<ReportTemplate> savedTemplates = new ArrayList<>();