Browse Source

Pull request #3145: REPORT-45558【设计器埋点】process表reuseCmptList字段准确性确认

Merge in DESIGN/design from ~KERRY/design_10.0:release/10.0 to release/10.0

* commit 'bb555ecedcfbd94eb0f7cdbdb10410204717f4b8':
  REPORT-45558【设计器埋点】process表reuseCmptList字段准确性确认
feature/big-screen
kerry 4 years ago
parent
commit
6235e1817f
  1. 45
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  2. 33
      designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java

45
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.AbstractBorderStyleWidget;
import com.fr.form.ui.BaseChartEditor; import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ElementCaseEditor;
import com.fr.form.ui.ElementCaseEditorProvider; 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.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout; 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.JSONArray;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.DefaultTemplateCellElement;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -94,23 +96,40 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private boolean hasTestECReport() { private boolean hasTestECReport() {
ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases(); ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases();
for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) { for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) {
FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase(); if (isTestECReport(elementCaseEditorProvider)) {
Iterator it = elementCase.cellIterator();
if (!it.hasNext()) {
return true; return true;
} }
while (it.hasNext()) {
DefaultTemplateCellElement ce = (DefaultTemplateCellElement) it.next();
Object value = ce.getValue();
if (isTestCell(value, ce.getStyle())) {
return true;
}
}
} }
return false; 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() { private boolean hasTestChart() {
final boolean[] hasTestChart = {false}; final boolean[] hasTestChart = {false};
Form.traversalWidget(this.template.getContainer(), new WidgetGather() { Form.traversalWidget(this.template.getContainer(), new WidgetGather() {
@ -226,7 +245,7 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private void addComponentRemoveInfo(JSONObject jsonObject) { private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID"); String componentID = jsonObject.getString("componentID");
if (componentID == null){ if (componentID == null) {
return; return;
} }
JSONObject info = componentProcessInfoMap.get(componentID); JSONObject info = componentProcessInfoMap.get(componentID);

33
designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java

@ -1,5 +1,6 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.base.background.ColorBackground;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.CardSwitchButton;
@ -21,6 +22,8 @@ import com.fr.report.worksheet.FormElementCase;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import java.awt.Color;
/** /**
* Created by kerry on 2020-05-08 * Created by kerry on 2020-05-08
*/ */
@ -35,14 +38,36 @@ public class JFormProcessInfoTest {
wFitLayout.addWidget(editor); wFitLayout.addWidget(editor);
form.setContainer(wFitLayout); form.setContainer(wFitLayout);
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form);
boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); boolean result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result1); Assert.assertTrue(result);
elementCase.addCellElement(new DefaultTemplateCellElement()); elementCase.addCellElement(new DefaultTemplateCellElement());
boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); result = Reflect.on(jFormProcessInfo).call("hasTestECReport").get();
Assert.assertTrue(result2); 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 @Test
public void testHasTestChart() { public void testHasTestChart() {
Form form = new Form(); Form form = new Form();

Loading…
Cancel
Save