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 70d1f3e0e2..efeaa6b046 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 @@ -67,7 +67,12 @@ import com.fr.form.ui.NoneWidget; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; +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.cptx.utils.CptxFileUtils; import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginRuntime; import com.fr.nx.app.designer.toolbar.CompileAction; @@ -269,7 +274,7 @@ public abstract class JTemplate> public void fireTabChange() { // do nothing } - + protected void addPane(PropertyItemPaneProvider provider) { // do nothing } @@ -1458,7 +1463,27 @@ public abstract class JTemplate> public abstract String route(); public String getTemplateName() { - return getEditingFILE().getName(); + return getEditingFILE().getName() + compatibilityTip(); + } + + /** + * 设置新引擎后,有不支持的功能时,设计器中模板的标题需要加上“兼容模式”或者“不支持分页引擎”来提示用户 + * */ + private String compatibilityTip() { + 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()) { + 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; } public String getTemplatePredefinedStyle() { @@ -1527,6 +1552,8 @@ public abstract class JTemplate> @Override public void run() { callBackForSave(); + //在保存后的回调中执行预编译流程 + CptCompileUtil.compile(JTemplate.this); } }); @@ -1591,6 +1618,10 @@ public abstract class JTemplate> worker.addSuccessCallback(new Runnable() { @Override public void run() { + boolean isChangedFile = !JTemplate.this.saved; + if (isChangedFile){ + CptCompileUtil.compile(JTemplate.this); + } callBackForSave(); // 当前打开的是正在保存的模板才刷新 if (ComparatorUtils.equals(JTemplate.this.template.getTemplateID(), @@ -1600,7 +1631,6 @@ public abstract class JTemplate> DesignerFrameFileDealerPane.getInstance().refresh(); } }); - return worker; } @@ -1651,6 +1681,15 @@ public abstract class JTemplate> result = result || provider.saveToNewFile(this.editingFILE.getPath(), this); } if (!result) { + /* + * 1.在CptCompileUtil::haveChanged改变报表引擎属性 + * 2.在这三种情况下:1.cptx文件另存为cpt文件 2.cptx另存为cptx文件 3.设置了新引擎的cpt文件另存为cpt文件, + * 因为文件的编译目录改变了,需要重新预编译,因此设置jTemplate的保存状态为false + * */ + boolean hasChanged = CptCompileUtil.hasChanged(oldName, this); + if (hasChanged){ + this.saved = false; + } result = this.saveRealFile(); // 更换最近打开 DesignerEnvManager.getEnvManager().replaceRecentOpenedFilePath(oldName, this.getPath()); @@ -1740,4 +1779,4 @@ public abstract class JTemplate> templateThemeButton.setText(name); templateThemeButton.setToolTipText(name); } -} +} \ No newline at end of file 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 0000000000..7067789a45 --- /dev/null +++ b/designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java @@ -0,0 +1,216 @@ +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; +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文件也执行预编译。在JStreamWork中,保存和另存为流程都进行了重新编译。 + * 但是由于之前的DefaultTemplateResource.saveTemplate的原因导致JStreamWork::saveFile()不能执行--cptx的保存不能进行预编译, + * 应该是流程的误改动,这里改回来,保存时仍然执行预编译。 + * */ + if (!isNewEngine(workbook, path)){ + return; + } + TransformResultInfo resultInfo = compile0(workbook, file); + unSupportLog(resultInfo); + + } + + private 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 boolean hasChanged(String oldName, JTemplate jTemplate){ + FILE editingFILE = jTemplate.getEditingFILE(); + String path = editingFILE.getPath(); + //只有在旧文件是cptx文件并且新文件是cpt文件时才会改变报表引擎属性 + boolean isChange = oldName.endsWith(".cptx") && path.endsWith(".cpt"); + 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(); + workSheet.setLayerReportAttr(layerReportAttr); + } + 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; + } + } + + private static WorkSheet gainWorkSheet(Object workBook){ + if (workBook == null || !(workBook instanceof TemplateWorkBook)){ + return null; + } + Report report = ((TemplateWorkBook) workBook).getReport(0); + 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){ + TransformResult result = transformResultInfo.getResult(); + //这里只打印模板转换不支持的信息,没有打印模板转换失败的信息 + if (result.equals(TransformResult.UNSUPPORT)){ + FineLoggerFactory.getLogger().error(transformResultInfo.getTransformLog()); + } + } + + +} 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 8dd00d1703..310ce257aa 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,13 @@ 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.file.HistoryTemplateListCache; 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 +18,7 @@ public class ReportEngineAttrAction extends ReportComponentAction { } 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(), getEditingFILE().getPath())){ + 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)); + } } /** @@ -740,7 +748,8 @@ public class JWorkBook extends JTemplate { */ @Override public ShortCut[] shortcut4TemplateMenu() { - return ArrayUtils.addAll(new ShortCut[]{ + boolean isNewEngine = CptCompileUtil.isNewEngine(this.getTarget(), getEditingFILE().getPath()); + ShortCut[] commonShortCut = ArrayUtils.addAll(new ShortCut[]{ new ReportWebAttrAction(this), new ReportExportAttrAction(this), new ReportParameterAction(this), @@ -750,8 +759,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; + } } + + /** * 模板的工具 * 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 0000000000..e744579d44 --- /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); + } +} + 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 4597d02343..35aba93d8b 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 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 48585b7fda..15f64a044e 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 @@ -114,4 +114,4 @@ public class JStreamBook extends JWorkBook { public ShortCut[] shortcut4TemplateMenu() { return ArraysUtil.insert(super.shortcut4TemplateMenu(), new CalculateAttrAction(this), 5); } -} +} \ No newline at end of file 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 d318f725a3..a3e06d9cb0 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