From bb555ecedcfbd94eb0f7cdbdb10410204717f4b8 Mon Sep 17 00:00:00 2001 From: kerry Date: Tue, 22 Dec 2020 15:54:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-45558=E3=80=90=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=9F=8B=E7=82=B9=E3=80=91process=E8=A1=A8reuseCmptLi?= =?UTF-8?q?st=E5=AD=97=E6=AE=B5=E5=87=86=E7=A1=AE=E6=80=A7=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../template/info/JFormProcessInfo.java | 45 +++++++++++++------ .../template/info/JFormProcessInfoTest.java | 33 ++++++++++++-- 2 files changed, 61 insertions(+), 17 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java index 180215a24..c8d52dae7 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java @@ -10,7 +10,10 @@ import com.fr.form.main.WidgetUtil; import com.fr.form.ui.AbstractBorderStyleWidget; import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.CardSwitchButton; +import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.ElementCaseEditorProvider; +import com.fr.form.ui.LayoutBorderStyle; +import com.fr.form.ui.PaddingMargin; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WLayout; @@ -18,7 +21,6 @@ import com.fr.general.ComparatorUtils; import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.report.cell.DefaultTemplateCellElement; - import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -94,23 +96,40 @@ public class JFormProcessInfo extends TemplateProcessInfo
{ private boolean hasTestECReport() { ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases(); for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) { - FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); - Iterator it = elementCase.cellIterator(); - if (!it.hasNext()) { + if (isTestECReport(elementCaseEditorProvider)) { return true; } - while (it.hasNext()) { - DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); - Object value = ce.getValue(); - if (isTestCell(value, ce.getStyle())) { - return true; - } - } - } return false; } + private boolean isTestECReport(ElementCaseEditorProvider elementCaseEditorProvider) { + FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); + if (!isTestElementCaseEditor((ElementCaseEditor) elementCaseEditorProvider)) { + return false; + } + Iterator it = elementCase.cellIterator(); + if (!it.hasNext()) { + return true; + } + while (it.hasNext()) { + DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next(); + Object value = ce.getValue(); + if (!isTestCell(value, ce.getStyle())) { + return false; + } + } + return true; + } + + private boolean isTestElementCaseEditor(ElementCaseEditor editor) { + return editor.getToolBars().length == 0 && editor.getListenerSize() == 0 + && ComparatorUtils.equals(editor.getBorderStyle(), new LayoutBorderStyle()) + && ComparatorUtils.equals(editor.getMargin(), new PaddingMargin()) + && editor.getBackground() == null; + + } + private boolean hasTestChart() { final boolean[] hasTestChart = {false}; Form.traversalWidget(this.template.getContainer(), new WidgetGather() { @@ -226,7 +245,7 @@ public class JFormProcessInfo extends TemplateProcessInfo { private void addComponentRemoveInfo(JSONObject jsonObject) { String componentID = jsonObject.getString("componentID"); - if (componentID == null){ + if (componentID == null) { return; } JSONObject info = componentProcessInfoMap.get(componentID); diff --git a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java index 663be8758..04327d354 100644 --- a/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java +++ b/designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.template.info; +import com.fr.base.background.ColorBackground; import com.fr.chart.chartattr.ChartCollection; import com.fr.form.main.Form; import com.fr.form.ui.CardSwitchButton; @@ -21,6 +22,8 @@ import com.fr.report.worksheet.FormElementCase; import org.junit.Assert; import org.junit.Test; +import java.awt.Color; + /** * Created by kerry on 2020-05-08 */ @@ -35,14 +38,36 @@ public class JFormProcessInfoTest { wFitLayout.addWidget(editor); form.setContainer(wFitLayout); JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); - boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); - Assert.assertTrue(result1); + boolean result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); elementCase.addCellElement(new DefaultTemplateCellElement()); - boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); - Assert.assertTrue(result2); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); + + DefaultTemplateCellElement templateCellElement = new DefaultTemplateCellElement(); + templateCellElement.setValue(123); + + elementCase.addCellElement(templateCellElement); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertFalse(result); + + elementCase.removeCellElement(templateCellElement); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); + + editor.setBackground(ColorBackground.getInstance(Color.WHITE)); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertFalse(result); + + + editor.setBackground(null); + result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); + Assert.assertTrue(result); } + + @Test public void testHasTestChart() { Form form = new Form();