Browse Source

REPORT-45558【设计器埋点】process表reuseCmptList字段准确性确认

feature/big-screen
kerry 4 years ago
parent
commit
bb555ecedc
  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.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<Form> {
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<Form> {
private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID");
if (componentID == null){
if (componentID == null) {
return;
}
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;
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();

Loading…
Cancel
Save