From 098e494eca7379a95976020cfdf2fc1adca7a7ac Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Wed, 1 Sep 2021 21:28:24 +0800 Subject: [PATCH 01/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=B0=86JStreamWork?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=9B=B8=E5=85=B3=E6=96=B9=E6=B3=95=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=88=B0=E8=AF=A5=E7=B1=BB=E9=87=8C=E9=9D=A2=20&=20?= =?UTF-8?q?=E5=B0=86=E9=A2=84=E7=BC=96=E8=AF=91=E6=B5=81=E7=A8=8B=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=88=B0cpt=E4=BF=9D=E5=AD=98=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E4=B8=AD=20&=20cptx=E7=9A=84=E5=8F=A6=E5=AD=98=E4=B8=BAcpt?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E6=B5=81=E7=A8=8B=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 4fb13150e..c3b82646b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -62,10 +62,15 @@ import com.fr.file.MemFILE; import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; +import com.fr.main.impl.WorkBook; +import com.fr.nx.app.designer.toolbar.CompileAction; +import com.fr.nx.app.designer.utils.CptCompileUtil; +import com.fr.nx.cptx.entry.metadata.CptxMetadata; +import com.fr.nx.cptx.utils.CptxFileUtils; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; -import com.fr.nx.app.designer.toolbar.CompileAction; import com.fr.nx.app.designer.toolbar.TemplateTransformer; import com.fr.plugin.injectable.PluginModule; import com.fr.plugin.manage.PluginFilter; @@ -331,6 +336,15 @@ public abstract class JTemplate> return getEditingFILE().getPath(); } + private String getSuffix() { + CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); + if (metadata != null && metadata.isForceCpt()) { + //在不支持新引擎时,标题上需要显示分页引擎未生效 + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); + } + return StringUtils.EMPTY; + } + protected abstract JComponent createCenterPane(); /** @@ -1404,7 +1418,7 @@ public abstract class JTemplate> * @return 按钮组 */ public UIButton[] createExtraButtons() { - UIButton[] uiButtons = new UIButton[] { + UIButton[] uiButtons = new UIButton[]{ (UIButton) new CompileAction().createToolBarComponent() }; Set providers = ExtraDesignClassManager.getInstance().getArray(DesignerFrameUpButtonProvider.XML_TAG); @@ -1439,7 +1453,12 @@ public abstract class JTemplate> public abstract String route(); public String getTemplateName() { - return getEditingFILE().getName(); + boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget()); + if (isNewEngine) { + return getEditingFILE().getName() + getSuffix(); + }else { + return getEditingFILE().getName(); + } } public String getTemplatePredefinedStyle() { @@ -1468,6 +1487,9 @@ public abstract class JTemplate> @Override public void run() { callBackForSave(); + //在保存后的回调中执行预编译流程 + CptCompileUtil.compile(JTemplate.this); + } }); @@ -1532,7 +1554,12 @@ public abstract class JTemplate> worker.addSuccessCallback(new Runnable() { @Override public void run() { - callBackForSave(); + //新添加代码,另存为流程中,有可能没有保存,在没有保存的情况下,应该进行预编译判断 + if (!JTemplate.this.isSaved() && !DesignModeContext.isVcsMode()){ + //这里要先调下面这行代码 + callBackForSave(); + CptCompileUtil.compile(JTemplate.this); + } // 当前打开的是正在保存的模板才刷新 if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { @@ -1592,6 +1619,8 @@ public abstract class JTemplate> result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); } if (!result) { + //在这里改变报表引擎属性 + CptCompileUtil.changeFrEngineAttr(oldName, this); result = this.saveRealFile(); // 更换最近打开 DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); From 5eacc359688dfd81c1ff4310889d71e6768dac14 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Wed, 1 Sep 2021 21:36:43 +0800 Subject: [PATCH 02/17] =?UTF-8?q?=E5=B0=86JStreamWork=E7=B1=BB=E4=B8=AD?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=96=B9=E6=B3=95=E5=90=88=E5=B9=B6=E5=88=B0?= =?UTF-8?q?JWorkBook=E4=B8=AD=EF=BC=8C=E8=BF=99=E4=BA=9B=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=8A=A5=E8=A1=A8=E5=BC=95=E6=93=8E=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=9A=84=E8=AE=BE=E7=BD=AE=E8=BF=9B=E8=A1=8C=E4=BA=86?= =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JWorkBook.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 0887ffdea..855201733 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -82,6 +82,8 @@ import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBookAdapter; import com.fr.main.impl.WorkBookX; import com.fr.main.parameter.ReportParameterAttr; +import com.fr.nx.app.designer.menu.CalculateAttrAction; +import com.fr.nx.app.designer.utils.CptCompileUtil; import com.fr.poly.PolyDesigner; import com.fr.poly.creator.BlockCreator; import com.fr.privilege.finegrain.WorkSheetPrivilegeControl; @@ -99,6 +101,7 @@ import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.module.Module; import com.fr.stable.project.ProjectConstants; +import com.fr.third.jodd.util.ArraysUtil; import com.fr.web.controller.ViewRequestConstants; import com.fr.workspace.WorkContext; @@ -693,8 +696,13 @@ public class JWorkBook extends JTemplate { } protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) { - exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), - new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this)); + if (CptCompileUtil.isNewEngine(this.getTarget())){ + exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), + new CSVExportAction(this), new TextExportAction(this)); + }else { + exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), + new CSVExportAction(this), new TextExportAction(this), new EmbeddedExportExportAction(this)); + } } /** @@ -718,7 +726,8 @@ public class JWorkBook extends JTemplate { */ @Override public ShortCut[] shortcut4TemplateMenu() { - return ArrayUtils.addAll(new ShortCut[]{ + boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget()); + ShortCut[] commonShortCut = ArrayUtils.addAll(new ShortCut[]{ new ReportWebAttrAction(this), new ReportExportAttrAction(this), new ReportParameterAction(this), @@ -728,8 +737,15 @@ public class JWorkBook extends JTemplate { new ReportWatermarkAction(this), new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Current_Sheet")), }, this.reportComposite.getEditingReportComponent().shortcut4TemplateMenu()); + if (isNewEngine){ + return ArraysUtil.insert(commonShortCut, new CalculateAttrAction(this), 5); + }else { + return commonShortCut; + } } + + /** * 模板的工具 * From 9656286078f72d937c1f2e95f8e9d22d9b6371cd Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Wed, 1 Sep 2021 21:48:59 +0800 Subject: [PATCH 03/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=8A=A5=E8=A1=A8=E5=BC=95=E6=93=8E=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/report/LayerReportEnginePane.java | 211 ++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java diff --git a/designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java b/designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java new file mode 100644 index 000000000..e744579d4 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java @@ -0,0 +1,211 @@ +package com.fr.design.report; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.editor.editor.IntegerEditor; +import com.fr.design.gui.ibutton.UIRadioButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.FRExplainLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; +import com.fr.locale.InterProviderFactory; +import com.fr.report.core.ReportUtils; +import com.fr.report.stable.LayerReportAttr; +import com.fr.report.worksheet.WorkSheet; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; + +/** + * @author fly.li + * @version 10.0 + * Created on 2021/08/22 + */ +public class LayerReportEnginePane extends BasicBeanPane { + private static final int LABEL_HEIGHT = 55; + private UICheckBox isClientPaging; + private UICheckBox isShowDataNumber; + private UICheckBox isPageQueryBox; + private IntegerEditor countPerPageEditor; + private WorkSheet worksheet; + private List radioButtons = new ArrayList<>(2); + + public LayerReportEnginePane(WorkSheet worksheet) { + this.worksheet = worksheet; + this.initComponents(); + } + + public LayerReportEnginePane() { + this(null); + } + + protected void initComponents() { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel outlayerReportPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Report_Engine_Attribute")); + JPanel layerReportPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); + this.add(outlayerReportPane); + outlayerReportPane.add(layerReportPane); + + JPanel isClientPagingPanle = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + isClientPaging = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enable_Client_Page")); + isClientPaging.addActionListener(new ActionListener(){ + + @Override + public void actionPerformed(ActionEvent e) { + if (isClientPaging.isSelected()){ + isPageQueryBox.setEnabled(true); + }else{ + isPageQueryBox.setEnabled(false); + } + + } + }); + isClientPaging.setSelected(false); + isClientPagingPanle.add(isClientPaging); + layerReportPane.add(isClientPagingPanle); + UIRadioButton lineEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine"), false); + UIRadioButton newEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine"), false); + + ButtonGroup buttonGroup = new ButtonGroup(); + buttonGroup.add(newEngine); + buttonGroup.add(lineEngine); + radioButtons.add(lineEngine); + radioButtons.add(newEngine); + + double p = TableLayout.PREFERRED; + double[] rowSize = {p}; + double[] columnSize = {p, p, p, p, p}; + Component[][] components = new Component[][]{ + new Component[] { + new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Page_Engine_Select")), + lineEngine, + newEngine + } + }; + JPanel pagingEngineRadioPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + layerReportPane.add(pagingEngineRadioPanel); + + JPanel infoPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Attention")); + FRExplainLabel label = new FRExplainLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Layer_Report_Warnning_Info")); + label.setPreferredSize(new Dimension(label.getPreferredSize().width, LABEL_HEIGHT)); + infoPane.add(label); + layerReportPane.add(infoPane); + + JPanel isShowDataNumberPanle = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + isShowDataNumber = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Show_Data_Total_Number")); + isShowDataNumber.setSelected(false); + isShowDataNumberPanle.add(isShowDataNumber); + layerReportPane.add(isShowDataNumberPanle); + + JPanel isPageQueryBoxPanle = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + isPageQueryBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Fixed_Line_Paging")); + isPageQueryBox.setSelected(false); + isPageQueryBox.setEnabled(false); + isPageQueryBoxPanle.add(isPageQueryBox); + layerReportPane.add(isPageQueryBoxPanle); + isPageQueryBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + if (isPageQueryBox.isSelected()) { + countPerPageEditor.setEnabled(true); + } else { + countPerPageEditor.setEnabled(false); + } + } + }); + + JPanel pageQueryPane = createPageQueryPane(); + layerReportPane.add(pageQueryPane); + + } + + private JPanel createPageQueryPane() { + double p = TableLayout.PREFERRED; + double rowSize[] = {p, p}; + double columnSize[] = {p, p}; + countPerPageEditor = new IntegerEditor(new Integer(30)); + countPerPageEditor.setPreferredSize(new Dimension(120,20)); + countPerPageEditor.setEnabled(false); + Component[][] components = {{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_LayerPageReport_Count_PerPage") + ":"), countPerPageEditor}}; + JPanel pageQueryPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); + pageQueryPane.setBorder(BorderFactory.createEmptyBorder(5, 15, 0, 0)); + return pageQueryPane; + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Report_Engine_Attribute"); + } + + @Override + public void populateBean(LayerReportAttr ob) { + if (ob == null){ + setDefaultAttr(); + return; + } + isClientPaging.setSelected(ob.isClientPaging()); + isShowDataNumber.setSelected(ob.isShowDataNumber()); + countPerPageEditor.setValue(new Integer(ob.getCountPerPage())); + if (ob.isPageQuery()) { + isPageQueryBox.setSelected(true); + countPerPageEditor.setEnabled(true); + } else { + isPageQueryBox.setSelected(false); + countPerPageEditor.setEnabled(false); + } + radioButtons.get(0).setSelected(ob.isNewEngine()); + radioButtons.get(1).setSelected(!ob.isNewEngine()); + } + + @Override + public LayerReportAttr updateBean() { + //这里注意一下怎么更新的,后续可能存在判断为空的调用,从而对老引擎造成影响。 + LayerReportAttr attr = new LayerReportAttr(); + attr.setPageQuery(isPageQueryBox.isSelected()); + attr.setCountPerPage(Math.min(500, ((Integer)countPerPageEditor.getValue()).intValue())); + attr.setClientPaging(isClientPaging.isSelected()); + attr.setShowDataNumber(isShowDataNumber.isSelected()); + for (int i = 0; i < radioButtons.size(); i++){ + if (radioButtons.get(i).isSelected()){ + attr.setNewEngine((i == 0)); + } + } + return attr; + } + + @Override + public void checkValid() throws Exception { + if (isClientPaging.isSelected()) { + if (!ReportUtils.isLayerReportUsable(worksheet)) { + int value = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_After_Changed_Some_Attributes_Are_Different") + "?", + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Confirm"), JOptionPane.YES_NO_OPTION); + if (value != JOptionPane.YES_OPTION) { + isClientPaging.setSelected(false); + } + } + } + } + public void setDefaultAttr(){ + isClientPaging.setSelected(false); + isShowDataNumber.setSelected(false); + countPerPageEditor.setValue(new Integer(30)); + countPerPageEditor.setEnabled(false); + isPageQueryBox.setSelected(false); + isPageQueryBox.setEnabled(false); + radioButtons.get(0).setSelected(false); + radioButtons.get(1).setSelected(false); + } +} + From b5802fbd95f48c6bc7e6f06a9a6f2c8f145b0d47 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Wed, 1 Sep 2021 21:54:57 +0800 Subject: [PATCH 04/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=B0=86=E9=A2=84?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=B5=81=E7=A8=8B=EF=BC=8C=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=BC=95=E6=93=8E=E5=B1=9E=E6=80=A7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E4=BA=86=E6=96=B0=E5=BC=95=E6=93=8E=E7=9A=84=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E9=83=BD=E7=BB=9F=E4=B8=80=E5=88=B0=E4=BA=86=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E5=B7=A5=E5=85=B7=E7=B1=BB=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nx/app/designer/utils/CptCompileUtil.java | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java new file mode 100644 index 000000000..f6dce92b4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java @@ -0,0 +1,184 @@ +package com.fr.nx.app.designer.utils; + +import com.fr.design.mainframe.JTemplate; +import com.fr.file.FILE; +import com.fr.file.FileNodeFILE; +import com.fr.general.ComparatorUtils; +import com.fr.log.FineLoggerFactory; +import com.fr.main.TemplateWorkBook; +import com.fr.main.impl.WorkBook; +import com.fr.nx.app.designer.cptx.io.DesignReadWritableProvider; +import com.fr.nx.app.designer.monitor.DesignerMetricRecorder; +import com.fr.nx.app.designer.toolbar.TransformResult; +import com.fr.nx.app.designer.toolbar.TransformResultInfo; +import com.fr.nx.compile.CompileStatus; +import com.fr.nx.compile.ReportCompiler; +import com.fr.nx.compile.adapter.LegacyWorkBookAdapter; +import com.fr.nx.compile.util.ReportCompileUtils; +import com.fr.nx.cptx.CptxIOManager; +import com.fr.nx.cptx.cache.CptxTemplatePool; +import com.fr.nx.cptx.entry.CptxTemplate; +import com.fr.nx.cptx.io.handle.CptxTemplateHandle; +import com.fr.nx.cptx.monitor.CompileMonitorHandler; +import com.fr.nx.cptx.utils.CptxFileUtils; +import com.fr.nx.data.layer.LayerItem; +import com.fr.nx.data.layer.LayerProps; +import com.fr.nx.template.compile.CompiledReport; +import com.fr.report.report.Report; +import com.fr.report.stable.LayerReportAttr; +import com.fr.report.worksheet.WorkSheet; + +import java.io.OutputStream; + + +public class CptCompileUtil { + public static void compile(JTemplate jtemplate) { + if (jtemplate == null || jtemplate.getEditingFILE() == null) { + return; + } + FILE file = jtemplate.getEditingFILE(); + String path = file.getPath(); + WorkBook workbook = (WorkBook) jtemplate.getTarget(); + //如果是cpt并且引擎设置正确,执行预编译。cptx文件不执行预编译 + if (!(path.endsWith(".cpt") && isNewEngine(workbook))){ + return; + } + TransformResultInfo resultInfo = compile0(workbook, file); + unSupportLog(resultInfo); + } + + public static TransformResultInfo compile0(WorkBook workbook, FILE file) { + if (!(file instanceof FileNodeFILE)) { + try { + OutputStream outputStream = file.asOutputStream(); + workbook.export(outputStream); + return TransformResultInfo.generateResult(TransformResult.SUCCESS).saved(true); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return TransformResultInfo.generateResult(TransformResult.FAILED).saved(false); + } + } + boolean saved; + CompiledReport report = null; + CompileStatus compileStatus = CompileStatus.SUCCEED; + if (workbook == null || file == null) { + return TransformResultInfo + .generateResult(TransformResult.FAILED, "work and file must not be null") + .saved(false); + } + String failMessage = null; + // 编译 + ReportCompiler compiler; + try { + compiler = new ReportCompiler(new LegacyWorkBookAdapter(workbook)); + long startTime = System.currentTimeMillis(); + compiler.compile(); + report = compiler.getCompiledReport(); + // 折叠树埋点 + LayerProps props = ReportCompileUtils.getLayerProps(report); + LayerItem[] items; + if (props != null && (items = props.getLayerItems()) != null) { + CompileMonitorHandler.submitTreeCompileFocusPoint( + startTime, file.getPath(), items.length, + props.getExpandLayer(), true + ); + } + compileStatus = compiler.getStatus(); + failMessage = compiler.getFailMessage(); + long endTime = System.currentTimeMillis(); + CompileMonitorHandler.submitCompileMessage(startTime, endTime, file.getPath(), ""); + if (compileStatus != CompileStatus.SUCCEED) { + DesignerMetricRecorder.submitUnSupportTransform( + TransformResult.UNSUPPORT, + workbook.getTemplateID(), + file.getName(), + compileStatus == CompileStatus.FAILED_UNSUPPORT ? failMessage : null + ); + } + } catch (Exception exception) { + String templateID = workbook.getTemplateID(); + String fileName = file.getName(); + DesignerMetricRecorder.submitFailedTransform(TransformResult.FAILED, templateID, fileName, exception); + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + } + + // 构建编译结果,当前的 cptx template 是未经反序列化钩子处理过的 cptx 模版对象,不能直接用于模版预览 + CptxTemplate template = CptxIOManager.createCptxTemplate(workbook, report, compileStatus, failMessage); + // 保存 + DesignReadWritableProvider cptx = new DesignReadWritableProvider(file); + CptxTemplateHandle handle = CptxIOManager.create(template, cptx); + try { + saved = handle.save(); + } catch (Exception exception) { + // 存储cptx格式报错或者失败 + FineLoggerFactory.getLogger().error(exception.getMessage(), exception); + DesignerMetricRecorder.submitFailedTransform(TransformResult.FAILED, workbook.getTemplateID(), file.getName(), exception); + return TransformResultInfo.generateResult(TransformResult.FAILED, failMessage).saved(false); + } + // 读取可 web 预览模版并缓存 + try { + CptxTemplate previewCptxTemplate = CptxIOManager.open(cptx).getTemplate(); + CptxTemplatePool.getInstance().addCptxTemplate(CptxFileUtils.getFormatPath(file.getPath()), previewCptxTemplate); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + if (report == null) { + // 编译报错或者失败 + return TransformResultInfo.generateResult(TransformResult.FAILED, failMessage).saved(saved); + } + return TransformResultInfo.generateResult(TransformResult.parse(compileStatus), failMessage).saved(saved); + } + + private static boolean needDoAfterCompile(TransformResult result) { + return ComparatorUtils.equals(TransformResult.SUCCESS, result) + || ComparatorUtils.equals(TransformResult.UNSUPPORT, result); + } + + /* + * 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 + * */ + public static void changeFrEngineAttr(String oldName, JTemplate jTemplate){ + FILE editingFILE = jTemplate.getEditingFILE(); + String path = editingFILE.getPath(); + //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 + if (oldName.endsWith(".cptx") && path.endsWith(".cpt")){ + WorkBook target = (WorkBook)jTemplate.getTarget(); + WorkSheet workSheet = (WorkSheet)target.getReport(0); + LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); + if (layerReportAttr == null){ + layerReportAttr = new LayerReportAttr(); + workSheet.setLayerReportAttr(layerReportAttr); + } + layerReportAttr.setClientPaging(true); + layerReportAttr.setNewEngine(true); + } + } + + public static boolean isNewEngine(Object workBook){ + if (workBook == null || !(workBook instanceof TemplateWorkBook)){ + return false; + } + Report report = ((TemplateWorkBook) workBook).getReport(0); + if (report instanceof WorkSheet){ + WorkSheet workSheet = (WorkSheet) report; + LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); + if (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.isNewEngine()){ + return true; + }else{ + return false; + } + }else { + return false; + } + } + + private static void unSupportLog(TransformResultInfo transformResultInfo){ + TransformResult result = transformResultInfo.getResult(); + //这里只打印模板转换不支持的信息,没有打印模板转换失败的信息 + if (result.equals(TransformResult.UNSUPPORT)){ + FineLoggerFactory.getLogger().error(transformResultInfo.getTransformLog()); + } + } + + +} From 310e77f35566a94e713fc7545548ae6f4262d012 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Wed, 1 Sep 2021 22:03:54 +0800 Subject: [PATCH 05/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=B0=86JStreamBook?= =?UTF-8?q?=E6=8D=A2=E6=88=90JWorkBook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/nx/app/designer/menu/CalculateAttrAction.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrAction.java b/designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrAction.java index d318f725a..a3e06d9cb 100644 --- a/designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrAction.java +++ b/designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrAction.java @@ -6,18 +6,18 @@ import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.UIDialog; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JWorkBook; import com.fr.design.menu.MenuKeySet; import com.fr.locale.InterProviderFactory; import com.fr.main.impl.WorkBook; -import com.fr.nx.app.designer.JStreamBook; import com.fr.plugin.attr.CalculatorAttrMark; import javax.swing.KeyStroke; import java.awt.event.ActionEvent; -public class CalculateAttrAction extends JTemplateAction { +public class CalculateAttrAction extends JTemplateAction { - public CalculateAttrAction(JStreamBook jTemplate) { + public CalculateAttrAction(JWorkBook jTemplate) { super(jTemplate); initMenuStyle(); } @@ -35,7 +35,7 @@ public class CalculateAttrAction extends JTemplateAction { * @param e 事件 */ public void actionPerformed(ActionEvent e) { - final JStreamBook jwb = getEditingComponent(); + final JWorkBook jwb = getEditingComponent(); if (jwb == null) { return; } @@ -45,7 +45,7 @@ public class CalculateAttrAction extends JTemplateAction { showReportFitDialog(mark, jwb, workBook, attrPane); } - private void showReportFitDialog(CalculatorAttrMark mark, final JStreamBook jwb, final WorkBook workBook, final BasicBeanPane attrPane) { + private void showReportFitDialog(CalculatorAttrMark mark, final JWorkBook jwb, final WorkBook workBook, final BasicBeanPane attrPane) { attrPane.populateBean(mark); UIDialog dialog = attrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { @Override From 6d4045543fe2bb67b0358e01ec458bce31513715 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Wed, 1 Sep 2021 22:04:21 +0800 Subject: [PATCH 06/17] =?UTF-8?q?=E5=B0=86=E6=97=A7=E7=9A=84=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=8D=A2=E6=88=90=E6=96=B0=E7=9A=84=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../actions/report/ReportEngineAttrAction.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java index 8dd00d170..12316429f 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java @@ -1,14 +1,12 @@ package com.fr.design.actions.report; - -import com.fr.base.svg.IconUtils; import com.fr.design.actions.ReportComponentAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.WorkSheetDesigner; import com.fr.design.menu.KeySetUtils; -import com.fr.design.report.LayerReportPane; +import com.fr.design.report.LayerReportEnginePane; import com.fr.report.worksheet.WorkSheet; public class ReportEngineAttrAction extends ReportComponentAction { @@ -19,7 +17,7 @@ public class ReportEngineAttrAction extends ReportComponentAction Date: Thu, 2 Sep 2021 19:33:41 +0800 Subject: [PATCH 07/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E5=BC=95=E6=93=8E=E5=B1=9E=E6=80=A7=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E9=9C=80=E8=A6=81=E6=94=B9=E5=8F=98=E4=B8=80=E4=B8=8B?= =?UTF-8?q?JTemplate=E7=9A=84=E4=BF=9D=E5=AD=98=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mainframe/JTemplate.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 8d18bb0db..79762f212 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1615,9 +1615,8 @@ public abstract class JTemplate> worker.addSuccessCallback(new Runnable() { @Override public void run() { - //在新建报表流程会走这个流程,应该进行预编译 - if (!JTemplate.this.isSaved() && !DesignModeContext.isVcsMode()){ - //这里要先调下面这行代码 + boolean isChangedFile = !JTemplate.this.isSaved() && !DesignModeContext.isVcsMode(); + if (isChangedFile){ callBackForSave(); CptCompileUtil.compile(JTemplate.this); } @@ -1626,11 +1625,11 @@ public abstract class JTemplate> if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { refreshToolArea(); + } DesignerFrameFileDealerPane.getInstance().refresh(); } }); - return worker; } @@ -1682,7 +1681,11 @@ public abstract class JTemplate> } if (!result) { //在这里改变报表引擎属性 - CptCompileUtil.changeFrEngineAttr(oldName, this); + boolean ischanged = CptCompileUtil.changeFrEngineAttr(oldName, this); + if (ischanged){ + //如果改变了属性,则需要重新预编译,因此设置jTemplate的保存状态为false + this.saved = false; + } result = this.saveRealFile(); // 更换最近打开 DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); From e9b026ea885d8460b440a10ecd1f654bd0211650 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Thu, 2 Sep 2021 19:45:42 +0800 Subject: [PATCH 08/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=8A=A5=E8=A1=A8=E5=BC=95=E6=93=8E?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=EF=BC=8C=E5=88=99=E8=BF=94=E5=9B=9E=E5=B8=83?= =?UTF-8?q?=E5=B0=94=E5=80=BC=EF=BC=8C=E4=BB=A5=E5=88=A4=E6=96=AD=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E9=A2=84=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/nx/app/designer/utils/CptCompileUtil.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java index f6dce92b4..1d76a71d1 100644 --- a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java @@ -45,6 +45,7 @@ public class CptCompileUtil { } TransformResultInfo resultInfo = compile0(workbook, file); unSupportLog(resultInfo); + } public static TransformResultInfo compile0(WorkBook workbook, FILE file) { @@ -137,11 +138,12 @@ public class CptCompileUtil { /* * 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 * */ - public static void changeFrEngineAttr(String oldName, JTemplate jTemplate){ + public static boolean changeFrEngineAttr(String oldName, JTemplate jTemplate){ FILE editingFILE = jTemplate.getEditingFILE(); String path = editingFILE.getPath(); //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 - if (oldName.endsWith(".cptx") && path.endsWith(".cpt")){ + boolean isChange = oldName.endsWith(".cptx") && path.endsWith(".cpt"); + if (isChange){ WorkBook target = (WorkBook)jTemplate.getTarget(); WorkSheet workSheet = (WorkSheet)target.getReport(0); LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); @@ -152,6 +154,7 @@ public class CptCompileUtil { layerReportAttr.setClientPaging(true); layerReportAttr.setNewEngine(true); } + return isChange; } public static boolean isNewEngine(Object workBook){ From 581a1c8fe8044dcefeb4a009f9495ddcfb014d3e Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Thu, 2 Sep 2021 19:46:59 +0800 Subject: [PATCH 09/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=88=A0=E9=99=A4ge?= =?UTF-8?q?tPath=E7=9A=84=E9=87=8D=E5=86=99=20&=20=E5=85=BC=E5=AE=B9cptx?= =?UTF-8?q?=E7=9A=84=E6=89=93=E5=BC=80=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/nx/app/designer/JStreamBook.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java b/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java index 48585b7fd..9af3d83da 100644 --- a/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java +++ b/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java @@ -6,6 +6,7 @@ import com.fr.design.actions.file.export.PDFExportAction; import com.fr.design.actions.file.export.SVGExportAction; import com.fr.design.actions.file.export.TextExportAction; import com.fr.design.actions.file.export.WordExportAction; +import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JWorkBook; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; @@ -14,6 +15,7 @@ import com.fr.general.ComparatorUtils; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; +import com.fr.nx.app.designer.utils.CptCompileUtil; import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.app.designer.menu.CalculateAttrAction; import com.fr.nx.app.designer.toolbar.TemplateTransformer; @@ -92,26 +94,31 @@ public class JStreamBook extends JWorkBook { new CSVExportAction(this), new TextExportAction(this)); } - - @Override - public String getPath() { - return getEditingFILE().getPath() + getSuffix(); - } - public String getTemplateName() { return getEditingFILE().getName() + getSuffix(); } private String getSuffix() { - CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); + String path = this.getEditingFILE().getPath(); + CptxMetadata metadata = CptxFileUtils.getMetadata(path); + //兼容另存为模式中标题显示 if (metadata != null && metadata.isForceCpt()) { - return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); + if (path.endsWith(".cptx")){ + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); + } else if (path.endsWith(".cpt")){ + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); + } } return StringUtils.EMPTY; } @Override public ShortCut[] shortcut4TemplateMenu() { - return ArraysUtil.insert(super.shortcut4TemplateMenu(), new CalculateAttrAction(this), 5); + //兼容另存为流程中,在cptx转换成cpt时,在不重新关闭打开文件的基础上刷新面板 + if (!CptCompileUtil.isNewEngine(this.getTarget())){ + return ArraysUtil.insert(super.shortcut4TemplateMenu(), new CalculateAttrAction(this), 5); + } else { + return super.shortcut4TemplateMenu(); + } } } From 07c83f08b8ccb6718adac67b788aaa25a87d1402 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Thu, 2 Sep 2021 20:33:54 +0800 Subject: [PATCH 10/17] =?UTF-8?q?REPORT-55243:=E5=88=A0=E9=99=A4=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=B3=A8=E9=87=8A=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=B8=8D?= =?UTF-8?q?=E5=90=88=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 71372b727..695130aad 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1475,7 +1475,6 @@ public abstract class JTemplate> private String getSuffix() { - //这里需要重写getPath(),getPath()方法中,使用到了getSuffix()方法 CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); if (metadata != null && metadata.isForceCpt()) { //返回分页引擎未生效 @@ -1620,13 +1619,13 @@ public abstract class JTemplate> if (isChangedFile){ callBackForSave(); CptCompileUtil.compile(JTemplate.this); + } else{ + callBackForSave(); } - callBackForSave(); // 当前打开的是正在保存的模板才刷新 if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { refreshToolArea(); - } DesignerFrameFileDealerPane.getInstance().refresh(); } From 236ce2329737433a57fe3da77d1942d37200947c Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Fri, 3 Sep 2021 17:05:37 +0800 Subject: [PATCH 11/17] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=88=B7=E6=96=B0=E4=B8=80=E4=B8=8B=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=EF=BC=8C=E5=86=B3=E5=AE=9A=E6=98=AF=E5=90=A6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E8=AE=A1=E7=AE=97=E5=B1=9E=E6=80=A7=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/report/ReportEngineAttrAction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java b/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java index 12316429f..310ce257a 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java @@ -3,6 +3,7 @@ package com.fr.design.actions.report; import com.fr.design.actions.ReportComponentAction; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.WorkSheetDesigner; import com.fr.design.menu.KeySetUtils; @@ -34,17 +35,18 @@ public class ReportEngineAttrAction extends ReportComponentAction Date: Fri, 3 Sep 2021 17:10:31 +0800 Subject: [PATCH 12/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=B0=86JStreamWork?= =?UTF-8?q?=E5=90=88=E5=B9=B6=E5=88=B0JWorkBook=E5=8F=8AJTemplate=E7=9A=84?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JWorkBook.java | 4 ++-- .../src/main/java/com/fr/nx/app/designer/CptxApp.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java index 0ba6c6991..9fdbf6762 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java @@ -718,7 +718,7 @@ public class JWorkBook extends JTemplate { } protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) { - if (CptCompileUtil.isNewEngine(this.getTarget())){ + if (CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath())){ exportMenuDef.addShortCut(excelExportMenuDef, new PDFExportAction(this), new WordExportAction(this), new SVGExportAction(this), new CSVExportAction(this), new TextExportAction(this)); }else { @@ -748,7 +748,7 @@ public class JWorkBook extends JTemplate { */ @Override public ShortCut[] shortcut4TemplateMenu() { - boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget()); + boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath()); ShortCut[] commonShortCut = ArrayUtils.addAll(new ShortCut[]{ new ReportWebAttrAction(this), new ReportExportAttrAction(this), diff --git a/designer-realize/src/main/java/com/fr/nx/app/designer/CptxApp.java b/designer-realize/src/main/java/com/fr/nx/app/designer/CptxApp.java index 4597d0234..35aba93d8 100644 --- a/designer-realize/src/main/java/com/fr/nx/app/designer/CptxApp.java +++ b/designer-realize/src/main/java/com/fr/nx/app/designer/CptxApp.java @@ -3,6 +3,7 @@ package com.fr.nx.app.designer; import com.fr.base.extension.FileExtension; import com.fr.design.mainframe.AbstractAppProvider; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.JWorkBook; import com.fr.file.FILE; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; @@ -36,7 +37,7 @@ public class CptxApp extends AbstractAppProvider { */ @Override public JTemplate openTemplate(FILE tplFile) { - return new JStreamBook(asIOFile(tplFile), tplFile); + return new JWorkBook(asIOFile(tplFile), tplFile); } @Override From 3f0af2a666cff2405a0173030feaa58bf51d7dc8 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Fri, 3 Sep 2021 17:14:49 +0800 Subject: [PATCH 13/17] =?UTF-8?q?REPORT-55243=EF=BC=9Acptx=E7=9A=84?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=92=8C=E5=8F=A6=E5=AD=98=E4=B8=BA=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=90=88=E5=B9=B6=E5=88=B0Jtemplate=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 28 +++++--- .../nx/app/designer/utils/CptCompileUtil.java | 71 +++++++++++++------ 2 files changed, 67 insertions(+), 32 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 695130aad..f99bceed9 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1465,20 +1465,26 @@ public abstract class JTemplate> public abstract String route(); public String getTemplateName() { - boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget()); - if (isNewEngine) { - return getEditingFILE().getName() + getSuffix(); - }else { - return getEditingFILE().getName(); - } + return getEditingFILE().getName() + getSuffix(); } + public boolean isNewEngineMode(){ + return CptCompileUtil.isNewEngine(this.getTarget(),getEditingFILE().getPath()) || getEditingFILE().getPath().endsWith(".cptx"); + } private String getSuffix() { - CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); + if (!CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath())){ + return StringUtils.EMPTY; + } + String path = this.getEditingFILE().getPath(); + CptxMetadata metadata = CptxFileUtils.getMetadata(path); + //是否是兼容模式,兼容模式下,设置了新引擎的cpt和cptx的后缀不同 if (metadata != null && metadata.isForceCpt()) { - //返回分页引擎未生效 - return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); + if (path.endsWith(".cptx")){ + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); + } else if (path.endsWith(".cpt")){ + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); + } } return StringUtils.EMPTY; } @@ -1681,9 +1687,9 @@ public abstract class JTemplate> } if (!result) { //在这里改变报表引擎属性 - boolean ischanged = CptCompileUtil.changeFrEngineAttr(oldName, this); + boolean ischanged = CptCompileUtil.haveChanged(oldName, this); if (ischanged){ - //如果改变了属性,则需要重新预编译,因此设置jTemplate的保存状态为false + //如果cptx另存为cpt/cptx的另存为/cpt另存为,则需要重新预编译,因此设置jTemplate的保存状态为false。 this.saved = false; } result = this.saveRealFile(); diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java index 1d76a71d1..92856148a 100644 --- a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java @@ -1,5 +1,6 @@ package com.fr.nx.app.designer.utils; +import com.fr.base.extension.FileExtension; import com.fr.design.mainframe.JTemplate; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; @@ -39,8 +40,12 @@ public class CptCompileUtil { FILE file = jtemplate.getEditingFILE(); String path = file.getPath(); WorkBook workbook = (WorkBook) jtemplate.getTarget(); - //如果是cpt并且引擎设置正确,执行预编译。cptx文件不执行预编译 - if (!(path.endsWith(".cpt") && isNewEngine(workbook))){ + /* + * 如果是cpt并且引擎设置正确,执行预编译,如果是cptx文件也执行预编译。在JStreamWork中,保存和另存为流程都进行了重新编译。 + * 但是由于之前的DefaultTemplateResource.saveTemplate的原因导致JStreamWork::saveFile()不能执行--cptx的保存不能进行预编译, + * 应该是流程的误改动,这里改回来,保存时仍然执行预编译。 + * */ + if (!isNewEngine(workbook, path)){ return; } TransformResultInfo resultInfo = compile0(workbook, file); @@ -48,7 +53,7 @@ public class CptCompileUtil { } - public static TransformResultInfo compile0(WorkBook workbook, FILE file) { + private static TransformResultInfo compile0(WorkBook workbook, FILE file) { if (!(file instanceof FileNodeFILE)) { try { OutputStream outputStream = file.asOutputStream(); @@ -138,14 +143,28 @@ public class CptCompileUtil { /* * 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 * */ - public static boolean changeFrEngineAttr(String oldName, JTemplate jTemplate){ + public static boolean haveChanged(String oldName, JTemplate jTemplate){ FILE editingFILE = jTemplate.getEditingFILE(); String path = editingFILE.getPath(); //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 boolean isChange = oldName.endsWith(".cptx") && path.endsWith(".cpt"); - if (isChange){ - WorkBook target = (WorkBook)jTemplate.getTarget(); - WorkSheet workSheet = (WorkSheet)target.getReport(0); + if (isChange && !changeFrEngineAttr(jTemplate)){ + isChange = false; + } + //合并JStreamWork中另存为流程,cptx的另存为也需要重新预编译 + return (isChange || isSaveAs(jTemplate, oldName, path)); + } + + //cptx和设置了新引擎的cpt的另存也需要进行预编译 + private static boolean isSaveAs(JTemplate jTemplate, String oldName, String newName){ + return isNewEngine(jTemplate.getTarget(), newName) && ((FileExtension.CPTX.matchExtension(oldName) && FileExtension.CPTX.matchExtension(newName)) || (FileExtension.CPT.matchExtension(oldName) && FileExtension.CPT.matchExtension(newName))); + } + + private static boolean changeFrEngineAttr(JTemplate jTemplate){ + WorkSheet workSheet = gainWorkSheet(jTemplate); + if (workSheet == null){ + return false; + }else { LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); if (layerReportAttr == null){ layerReportAttr = new LayerReportAttr(); @@ -153,26 +172,36 @@ public class CptCompileUtil { } layerReportAttr.setClientPaging(true); layerReportAttr.setNewEngine(true); + return true; + } + } + + + public static boolean isNewEngine(Object workBook, String fileName){ + WorkSheet workSheet = gainWorkSheet(workBook); + LayerReportAttr layerReportAttr = gainLayerReportAttr(workSheet); + return isNewEngine(layerReportAttr, fileName); + } + + private static LayerReportAttr gainLayerReportAttr(WorkSheet workSheet){ + if (workSheet != null){ + LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); + return layerReportAttr; + } else { + return null; } - return isChange; } - public static boolean isNewEngine(Object workBook){ + private static WorkSheet gainWorkSheet(Object workBook){ if (workBook == null || !(workBook instanceof TemplateWorkBook)){ - return false; + return null; } Report report = ((TemplateWorkBook) workBook).getReport(0); - if (report instanceof WorkSheet){ - WorkSheet workSheet = (WorkSheet) report; - LayerReportAttr layerReportAttr = workSheet.getLayerReportAttr(); - if (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.isNewEngine()){ - return true; - }else{ - return false; - } - }else { - return false; - } + return report instanceof WorkSheet ? (WorkSheet)report : null; + } + + private static boolean isNewEngine(LayerReportAttr layerReportAttr, String fileName){ + return (layerReportAttr!= null && layerReportAttr.isClientPaging() && layerReportAttr.isNewEngine()) || FileExtension.CPTX.matchExtension(fileName); } private static void unSupportLog(TransformResultInfo transformResultInfo){ From ec6190e773efc28be66870f95b46fc7f85a248cc Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Fri, 3 Sep 2021 17:18:46 +0800 Subject: [PATCH 14/17] =?UTF-8?q?REPORT-55243:=E5=88=A0=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index f99bceed9..81a8e387a 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1468,10 +1468,6 @@ public abstract class JTemplate> return getEditingFILE().getName() + getSuffix(); } - public boolean isNewEngineMode(){ - return CptCompileUtil.isNewEngine(this.getTarget(),getEditingFILE().getPath()) || getEditingFILE().getPath().endsWith(".cptx"); - } - private String getSuffix() { if (!CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath())){ return StringUtils.EMPTY; From 21d62272f7c34a09fd0b1f982f09f15d892da91e Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Sun, 5 Sep 2021 14:12:51 +0800 Subject: [PATCH 15/17] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/JTemplate.java | 24 +++++++++++-------- .../nx/app/designer/utils/CptCompileUtil.java | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 81a8e387a..07af72a80 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1465,10 +1465,13 @@ public abstract class JTemplate> public abstract String route(); public String getTemplateName() { - return getEditingFILE().getName() + getSuffix(); + return getEditingFILE().getName() + compatibilityTip(); } - private String getSuffix() { + /** + * 设置新引擎后,有不支持的功能时,设计器中模板的标题需要加上“兼容模式”或者“不支持分页引擎”来提示用户 + * */ + private String compatibilityTip() { if (!CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath())){ return StringUtils.EMPTY; } @@ -1617,13 +1620,11 @@ public abstract class JTemplate> worker.addSuccessCallback(new Runnable() { @Override public void run() { - boolean isChangedFile = !JTemplate.this.isSaved() && !DesignModeContext.isVcsMode(); + boolean isChangedFile = !JTemplate.this.saved; if (isChangedFile){ - callBackForSave(); CptCompileUtil.compile(JTemplate.this); - } else{ - callBackForSave(); } + callBackForSave(); // 当前打开的是正在保存的模板才刷新 if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { @@ -1682,10 +1683,13 @@ public abstract class JTemplate> result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); } if (!result) { - //在这里改变报表引擎属性 - boolean ischanged = CptCompileUtil.haveChanged(oldName, this); - if (ischanged){ - //如果cptx另存为cpt/cptx的另存为/cpt另存为,则需要重新预编译,因此设置jTemplate的保存状态为false。 + /* + * 1.在CptCompileUtil::haveChanged改变报表引擎属性 + * 2.如果cptx文件另存为cpt文件/cptx另存为cptx文件/设置了新引擎的cpt文件另存为cpt文件, + * 因为编译目录改变了,需要重新预编译,因此设置jTemplate的保存状态为false + * */ + boolean hasChanged = CptCompileUtil.hasChanged(oldName, this); + if (hasChanged){ this.saved = false; } result = this.saveRealFile(); diff --git a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java index 92856148a..7067789a4 100644 --- a/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java @@ -143,7 +143,7 @@ public class CptCompileUtil { /* * 该另存为流程会改变文件内容,现在作为兼容的流程,以后可以随时删除该流程 * */ - public static boolean haveChanged(String oldName, JTemplate jTemplate){ + public static boolean hasChanged(String oldName, JTemplate jTemplate){ FILE editingFILE = jTemplate.getEditingFILE(); String path = editingFILE.getPath(); //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 From 1f07e3ee2fa1028921b937af81de53ceb94056b2 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Sun, 5 Sep 2021 14:21:21 +0800 Subject: [PATCH 16/17] =?UTF-8?q?REPORT-55243=EF=BC=9A=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 07af72a80..e1fbed2e1 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -1685,8 +1685,8 @@ public abstract class JTemplate> if (!result) { /* * 1.在CptCompileUtil::haveChanged改变报表引擎属性 - * 2.如果cptx文件另存为cpt文件/cptx另存为cptx文件/设置了新引擎的cpt文件另存为cpt文件, - * 因为编译目录改变了,需要重新预编译,因此设置jTemplate的保存状态为false + * 2.在这三种情况下:1.cptx文件另存为cpt文件 2.cptx另存为cptx文件 3.设置了新引擎的cpt文件另存为cpt文件, + * 因为文件的编译目录改变了,需要重新预编译,因此设置jTemplate的保存状态为false * */ boolean hasChanged = CptCompileUtil.hasChanged(oldName, this); if (hasChanged){ From 846fbfe832223f95762d93736935c85d6eef2323 Mon Sep 17 00:00:00 2001 From: "fly.li" Date: Mon, 6 Sep 2021 11:28:27 +0800 Subject: [PATCH 17/17] =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=AF=B9JStreamWork?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/nx/app/designer/JStreamBook.java | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java b/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java index 9af3d83da..15f64a044 100644 --- a/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java +++ b/designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java @@ -6,7 +6,6 @@ import com.fr.design.actions.file.export.PDFExportAction; import com.fr.design.actions.file.export.SVGExportAction; import com.fr.design.actions.file.export.TextExportAction; import com.fr.design.actions.file.export.WordExportAction; -import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JWorkBook; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; @@ -15,7 +14,6 @@ import com.fr.general.ComparatorUtils; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.nx.app.designer.utils.CptCompileUtil; import com.fr.nx.cptx.entry.metadata.CptxMetadata; import com.fr.nx.app.designer.menu.CalculateAttrAction; import com.fr.nx.app.designer.toolbar.TemplateTransformer; @@ -94,31 +92,26 @@ public class JStreamBook extends JWorkBook { new CSVExportAction(this), new TextExportAction(this)); } + + @Override + public String getPath() { + return getEditingFILE().getPath() + getSuffix(); + } + public String getTemplateName() { return getEditingFILE().getName() + getSuffix(); } private String getSuffix() { - String path = this.getEditingFILE().getPath(); - CptxMetadata metadata = CptxFileUtils.getMetadata(path); - //兼容另存为模式中标题显示 + CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); if (metadata != null && metadata.isForceCpt()) { - if (path.endsWith(".cptx")){ - return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); - } else if (path.endsWith(".cpt")){ - return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Paging_Engine_Not_Work"); - } + return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); } return StringUtils.EMPTY; } @Override public ShortCut[] shortcut4TemplateMenu() { - //兼容另存为流程中,在cptx转换成cpt时,在不重新关闭打开文件的基础上刷新面板 - if (!CptCompileUtil.isNewEngine(this.getTarget())){ - return ArraysUtil.insert(super.shortcut4TemplateMenu(), new CalculateAttrAction(this), 5); - } else { - return super.shortcut4TemplateMenu(); - } + return ArraysUtil.insert(super.shortcut4TemplateMenu(), new CalculateAttrAction(this), 5); } -} +} \ No newline at end of file