use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class JmixTableFormatter method transformData.
protected JmixTableData transformData(BandData rootBand) {
TemplateTableDescription templateTableDescription = ((ReportTemplate) reportTemplate).getTemplateTableDescription();
Map<String, List<KeyValueEntity>> transformedData = new LinkedHashMap<>();
Map<String, Set<JmixTableData.ColumnInfo>> headerMap = new HashMap<>();
Map<String, List<BandData>> childrenBands = rootBand.getChildrenBands();
if (templateTableDescription.getTemplateTableBands().size() > 0) {
return getTableData(templateTableDescription, transformedData, headerMap, childrenBands);
} else {
return getTableData(transformedData, headerMap, childrenBands);
}
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class ChartWidgetEdit method onReportComboBoxValueChange.
@Subscribe("reportComboBox")
public void onReportComboBoxValueChange(HasValue.ValueChangeEvent<Report> event) {
Report report = event.getValue();
if (report != null) {
List<ReportTemplate> chartTemplates = getChartsTemplates(report);
templateComboBox.setOptionsList(chartTemplates);
reportId = report.getId();
if (ReportOutputType.CHART == report.getDefaultTemplate().getReportOutputType()) {
templateComboBox.setValue(report.getDefaultTemplate());
templateId = report.getDefaultTemplate().getId();
}
}
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class TemplateEditor method onAfterInit.
@Subscribe
protected void onAfterInit(AfterInitEvent event) {
templateDc.addItemPropertyChangeListener(e -> {
ReportTemplate reportTemplate = getEditedEntity();
switch(e.getProperty()) {
case REPORT_OUTPUT_TYPE:
{
ReportOutputType prevOutputType = (ReportOutputType) e.getPrevValue();
ReportOutputType newOutputType = (ReportOutputType) e.getValue();
setupVisibility(reportTemplate.getCustom(), newOutputType);
if (hasHtmlCsvTemplateOutput(prevOutputType) && !hasTemplateOutput(newOutputType)) {
dialogs.createMessageDialog().withCaption(messages.getMessage(getClass(), "templateEditor.warning")).withMessage(messages.getMessage(getClass(), "templateEditor.clearTemplateMessage")).show();
}
break;
}
case CUSTOM:
{
setupVisibility(Boolean.TRUE.equals(e.getValue()), reportTemplate.getReportOutputType());
break;
}
case CUSTOM_DEFINE_BY:
{
boolean isGroovyScript = hasScriptCustomDefinedBy(reportTemplate.getCustomDefinedBy());
fullScreenLinkButton.setVisible(isGroovyScript);
customDefinitionHelpLinkButton.setVisible(isGroovyScript);
break;
}
}
});
initOutputTypeList();
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class TemplateEditor method onBeforeCommit.
@Subscribe
protected void onBeforeCommit(BeforeCommitChangesEvent event) {
if (!validateTemplateFile() || !validateInputOutputFormats()) {
event.preventCommit();
}
ReportTemplate reportTemplate = getEditedEntity();
for (DescriptionEditFragment fragment : getDescriptionEditFragments()) {
if (fragment.isApplicable(reportTemplate.getReportOutputType())) {
if (!fragment.applyChanges()) {
event.preventCommit();
}
}
}
if (!Boolean.TRUE.equals(reportTemplate.getCustom())) {
reportTemplate.setCustomDefinition("");
}
String extension = FilenameUtils.getExtension(templateUploadField.getFileName());
if (extension != null) {
ReportOutputType outputType = ReportOutputType.getTypeFromExtension(extension.toUpperCase());
if (hasHtmlCsvTemplateOutput(outputType)) {
byte[] bytes = templateFileEditor.getValue() == null ? new byte[0] : templateFileEditor.getValue().getBytes(StandardCharsets.UTF_8);
reportTemplate.setContent(bytes);
}
}
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class TemplateEditor method initUploadField.
protected void initUploadField() {
ReportTemplate reportTemplate = getEditedEntity();
byte[] templateFile = reportTemplate.getContent();
if (templateFile != null && !hasChartTemplateOutput(reportTemplate.getReportOutputType())) {
temporaryStorage.saveFile(templateFile);
templateUploadField.setValue(templateFile);
templateUploadField.setFileName(reportTemplate.getName());
}
templateUploadField.setEditable(isUpdatePermitted(reportTemplate));
}
Aggregations