Browse Source

Pull request #5698: REPORT-55243

Merge in DESIGN/design from ~FLY.LI/design:feature/x to feature/x

* commit '846fbfe832223f95762d93736935c85d6eef2323':
  取消对JStreamWork的修改
  REPORT-55243:完善注释
  修改方法名
  REPORT-55243:删除不必要的代码
  REPORT-55243:cptx的保存和另存为编译合并到Jtemplate中
  REPORT-55243:将JStreamWork合并到JWorkBook及JTemplate的流程中
  设置之后需要刷新一下面板,决定是否显示计算属性入口
  REPORT-55243:删除错误注释,修改不合理代码
  REPORT-55243:删除getPath的重写 & 兼容cptx的打开流程
  REPORT-55243:如果修改了报表引擎属性,则返回布尔值,以判断是否需要重新预编译
  REPORT-55243:改变报表引擎属性后,需要改变一下JTemplate的保存状态
  将旧的面板换成新的面板
  REPORT-55243:将JStreamBook换成JWorkBook
  REPORT-55243:将预编译流程,改变报表引擎属性功能,判断是否开启了新引擎的功能都统一到了这个工具类中
  REPORT-55243:重新设计报表引擎面板
  将JStreamWork类中相关方法合并到JWorkBook中,这些方法根据报表引擎属性的设置进行了不同的处理
  REPORT-55243:将JStreamWork中的相关方法合并到该类里面 & 将预编译流程合并到cpt保存流程中 & cptx的另存为cpt文件的流程处理
research/11.0
Fly.Li 3 years ago
parent
commit
8056fdfc90
  1. 43
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 216
      designer-base/src/main/java/com/fr/nx/app/designer/utils/CptCompileUtil.java
  3. 22
      designer-realize/src/main/java/com/fr/design/actions/report/ReportEngineAttrAction.java
  4. 18
      designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java
  5. 211
      designer-realize/src/main/java/com/fr/design/report/LayerReportEnginePane.java
  6. 3
      designer-realize/src/main/java/com/fr/nx/app/designer/CptxApp.java
  7. 10
      designer-realize/src/main/java/com/fr/nx/app/designer/menu/CalculateAttrAction.java

43
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;
@ -1458,7 +1463,27 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
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<T extends BaseBook, U extends BaseUndoState<?>>
@Override
public void run() {
callBackForSave();
//在保存后的回调中执行预编译流程
CptCompileUtil.compile(JTemplate.this);
}
});
@ -1591,6 +1618,10 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
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<T extends BaseBook, U extends BaseUndoState<?>>
DesignerFrameFileDealerPane.getInstance().refresh();
}
});
return worker;
}
@ -1651,6 +1681,15 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
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());

216
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());
}
}
}

22
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<WorkSheetDesigner> {
@ -19,7 +18,7 @@ public class ReportEngineAttrAction extends ReportComponentAction<WorkSheetDesig
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon("/com/fr/design/images/m_report/reportEngineAttr");
this.generateAndSetSearchText(LayerReportPane.class.getName());
this.generateAndSetSearchText(LayerReportEnginePane.class.getName());
}
@ -36,22 +35,21 @@ public class ReportEngineAttrAction extends ReportComponentAction<WorkSheetDesig
return false;
}
final WorkSheet tplEC = jws.getTemplateReport();
final LayerReportPane layerReportPane = new LayerReportPane(tplEC);
layerReportPane.populateBean(tplEC.getLayerReportAttr());
BasicDialog dialog = layerReportPane.showWindow(DesignerContext.getDesignerFrame());
final LayerReportEnginePane layerReportEnginePane = new LayerReportEnginePane(tplEC);
layerReportEnginePane.populateBean(tplEC.getLayerReportAttr());
BasicDialog dialog = layerReportEnginePane.showWindow(DesignerContext.getDesignerFrame());
isChange = false;
dialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
isChange = true;
tplEC.setLayerReportAttr(layerReportPane.updateBean());
tplEC.setLayerReportAttr(layerReportEnginePane.updateBean());
//设置新引擎后,需要刷新一下,计算属性设置入口是否显示,取决于是否设置了新引擎模式。
DesignerContext.getDesignerFrame().resetToolkitByPlus(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate());
}
});
dialog.setVisible(true);
return isChange;
}

18
designer-realize/src/main/java/com/fr/design/mainframe/JWorkBook.java

@ -88,6 +88,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;
@ -105,6 +107,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;
@ -715,9 +718,14 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
}
protected void addShortCut(MenuDef exportMenuDef, MenuDef excelExportMenuDef) {
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<WorkBook, WorkBookUndoState> {
*/
@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,7 +759,14 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
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;
}
}
/**
* 模板的工具

211
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<LayerReportAttr> {
private static final int LABEL_HEIGHT = 55;
private UICheckBox isClientPaging;
private UICheckBox isShowDataNumber;
private UICheckBox isPageQueryBox;
private IntegerEditor countPerPageEditor;
private WorkSheet worksheet;
private List<JRadioButton> 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);
}
}

3
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<WorkBook> {
*/
@Override
public JTemplate<WorkBook, ?> openTemplate(FILE tplFile) {
return new JStreamBook(asIOFile(tplFile), tplFile);
return new JWorkBook(asIOFile(tplFile), tplFile);
}
@Override

10
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<JStreamBook> {
public class CalculateAttrAction extends JTemplateAction<JWorkBook> {
public CalculateAttrAction(JStreamBook jTemplate) {
public CalculateAttrAction(JWorkBook jTemplate) {
super(jTemplate);
initMenuStyle();
}
@ -35,7 +35,7 @@ public class CalculateAttrAction extends JTemplateAction<JStreamBook> {
* @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<JStreamBook> {
showReportFitDialog(mark, jwb, workBook, attrPane);
}
private void showReportFitDialog(CalculatorAttrMark mark, final JStreamBook jwb, final WorkBook workBook, final BasicBeanPane<CalculatorAttrMark> attrPane) {
private void showReportFitDialog(CalculatorAttrMark mark, final JWorkBook jwb, final WorkBook workBook, final BasicBeanPane<CalculatorAttrMark> attrPane) {
attrPane.populateBean(mark);
UIDialog dialog = attrPane.showMediumWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() {
@Override

Loading…
Cancel
Save