forked from fanruan/design
26 changed files with 1169 additions and 239 deletions
@ -0,0 +1,20 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.json.JSONObject; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public interface TemplateOperate { |
||||||
|
/** |
||||||
|
* 获取模板操作类型 |
||||||
|
* @return 操作类型 |
||||||
|
*/ |
||||||
|
String getOperateType(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 将模板操作信息转换成json格式 |
||||||
|
* @return jsonObject |
||||||
|
*/ |
||||||
|
JSONObject toJSONObject(); |
||||||
|
} |
@ -1,35 +1,35 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<TplInfo xmlVersion="20170720" releaseVersion="10.0.0"> |
<TplInfo xmlVersion="20170720" releaseVersion="10.0.0"> |
||||||
<DesignerOpenHistory> |
<DesignerOpenHistory> |
||||||
<![CDATA[2019-04-08,2019-04-03,2019-03-29]]></DesignerOpenHistory> |
<![CDATA[2020-05-07,2020-05-06,2020-04-30]]></DesignerOpenHistory> |
||||||
<TemplateInfoList> |
<TemplateInfoList> |
||||||
<TemplateInfo templateID="16a988ce-8529-42f5-b17c-2ee849355071" day_count="9"> |
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="1" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="2" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{"componentID":"60e291c2-be60-4908-83ef-08b4a79d5f03","componentName":"button1","componentType":"Widget","createTime":1588843627801,"deleteTime":0},{"componentID":"fcf77ee3-05f0-4219-8fd2-d2a9ec95477e","componentName":"button0","componentType":"Widget","createTime":1588843624940,"deleteTime":0}]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-26 16:13" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="129" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588843629000,"consume":81}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
<TemplateInfo templateID="23817e4f-64b6-438e-b23b-91c1a4d0b254" day_count="9"> |
<TemplateInfo templateID="2521d03c-b238-41a5-9a1d-2498efff3a97" originID="aac1139e-018b-4481-867a-a18fc6d6f3e6" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="231" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0" paraApply="0" components_info="[]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-26 16:52" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="91" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:45" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588844751000,"consume":1058}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
<TemplateInfo templateID="31319947-5ce7-4d82-97e4-3cfea825df9c" day_count="9"> |
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="2" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{"componentID":"e28e24af-a01a-42cd-aa06-e14dd7990621","componentName":"button1","componentType":"Widget","createTime":1588843526090,"deleteTime":0},{"componentID":"0e7ce6df-f19b-40a9-a4d9-d47bdc097e31","componentName":"button0","componentType":"Widget","createTime":1588843525059,"deleteTime":0}]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-26 16:49" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="160" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588843530000,"consume":6}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
<TemplateInfo templateID="43bdd914-a3f7-405c-ad96-2feaf28bed74" day_count="8"> |
<TemplateInfo templateID="aac1139e-018b-4481-867a-a18fc6d6f3e6" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="1" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0" paraApply="0" components_info="[]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="2019.01.04.18.06.01.38" create_time="2019-03-27 16:17" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="1426" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:28" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588843693000,"consume":4}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
<TemplateInfo templateID="cd527ae5-06e4-48fb-a73e-e9a06c9e7c58" day_count="12"> |
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="1" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{"componentID":"60e291c2-be60-4908-83ef-08b4a79d5f03","componentName":"button1","componentType":"Widget","createTime":0,"deleteTime":1588843630822}]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="2019.01.04.18.06.01.38" create_time="2019-03-15 10:02" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="430" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588843631000,"consume":2}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
<TemplateInfo templateID="08f9c404-8124-4615-a34c-735dcabee137" day_count="9"> |
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="2" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="0" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[{"componentID":"fcf77ee3-05f0-4219-8fd2-d2a9ec95477e","componentName":"button0","componentType":"Widget","createTime":0,"deleteTime":1588843641882}]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-03-25 17:22" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="1497" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588843642000,"consume":10}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
<TemplateInfo templateID="981314a5-9c5b-4831-97d8-15e76735f9e2" day_count="1"> |
<TemplateInfo templateID="e5d7dbb2-d1df-43d4-b974-67acb5ecbffa" day_count="0" test_template="true"> |
||||||
<processMap process="" float_count="0" widget_count="0" cell_count="3" block_count="0" report_type="0"/> |
<processMap process="" float_count="0" widget_count="1" cell_count="0" block_count="0" report_type="2" paraApply="1" components_info="[]"/> |
||||||
<consumingMap activitykey="2e0ea413-fa9c241e0-9723-4354fce51e81" jar_time="不是安装版本" create_time="2019-04-17 16:24" uuid="476ca2cc-f789-4c5d-8e89-ef146580775c" time_consume="155" version="10.0" username="plough"/> |
<consumingMap create_time="2020-05-07 17:25" uuid="6b6699ff-ec63-43b0-9deb-b580a5f10411" uid="71113" saveRecord="{"time":1588843548000,"consume":17}"/> |
||||||
</TemplateInfo> |
</TemplateInfo> |
||||||
</TemplateInfoList> |
</TemplateInfoList> |
||||||
</TplInfo> |
</TplInfo> |
||||||
|
@ -0,0 +1,36 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
|
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public class ComponentCreateOperate extends ComponentOperate { |
||||||
|
public static final String OPERATE_TYPE = "componentCreate"; |
||||||
|
private static final String ATTR_CREATE_TIME = "createTime"; |
||||||
|
private long createTime = 0L; |
||||||
|
|
||||||
|
|
||||||
|
public ComponentCreateOperate(Widget widget) { |
||||||
|
super(widget); |
||||||
|
widget.setWidgetID(UUID.randomUUID().toString()); |
||||||
|
this.createTime = System.currentTimeMillis(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public String getOperateType() { |
||||||
|
return OPERATE_TYPE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject toJSONObject() { |
||||||
|
JSONObject jo = super.toJSONObject(); |
||||||
|
jo.put(ATTR_CREATE_TIME, createTime); |
||||||
|
return jo; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public class ComponentDeleteOperate extends ComponentOperate { |
||||||
|
public static final String OPERATE_TYPE = "componentDelete"; |
||||||
|
private long deleteTime = 0L; |
||||||
|
|
||||||
|
public ComponentDeleteOperate(Widget widget) { |
||||||
|
super(widget); |
||||||
|
this.deleteTime = System.currentTimeMillis(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getOperateType() { |
||||||
|
return OPERATE_TYPE; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject toJSONObject() { |
||||||
|
JSONObject jo = super.toJSONObject(); |
||||||
|
jo.put(ATTR_DELETE_TIME, deleteTime); |
||||||
|
return jo; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,80 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.form.ui.ChartEditor; |
||||||
|
import com.fr.form.ui.ElementCaseEditor; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WAbsoluteLayout; |
||||||
|
import com.fr.form.ui.container.WCardLayout; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public abstract class ComponentOperate implements TemplateOperate { |
||||||
|
private static final String ATTR_COMPONENT_ID = "componentID"; |
||||||
|
private static final String ATTR_COMPONENT_NAME = "componentName"; |
||||||
|
private static final String ATTR_COMPONENT_TYPE = "componentType"; |
||||||
|
protected static final String ATTR_CREATE_TIME = "createTime"; |
||||||
|
protected static final String ATTR_DELETE_TIME = "deleteTime"; |
||||||
|
|
||||||
|
private Widget widget; |
||||||
|
|
||||||
|
public ComponentOperate(Widget widget) { |
||||||
|
this.widget = widget; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONObject toJSONObject() { |
||||||
|
JSONObject jo = new JSONObject(); |
||||||
|
jo.put(ATTR_COMPONENT_ID, widget.getWidgetID()) |
||||||
|
.put(ATTR_COMPONENT_NAME, widget.getWidgetName()) |
||||||
|
.put(ATTR_COMPONENT_TYPE, ComponentType.parseType(widget).name()) |
||||||
|
.put(ATTR_CREATE_TIME, 0L) |
||||||
|
.put(ATTR_DELETE_TIME, 0L); |
||||||
|
return jo; |
||||||
|
} |
||||||
|
|
||||||
|
enum ComponentType { |
||||||
|
Chart { |
||||||
|
@Override |
||||||
|
protected boolean acceptType(Widget widget) { |
||||||
|
return widget.acceptType(ChartEditor.class); |
||||||
|
} |
||||||
|
}, |
||||||
|
Report { |
||||||
|
@Override |
||||||
|
protected boolean acceptType(Widget widget) { |
||||||
|
return widget.acceptType(ElementCaseEditor.class); |
||||||
|
} |
||||||
|
}, |
||||||
|
Widget { |
||||||
|
@Override |
||||||
|
protected boolean acceptType(Widget widget) { |
||||||
|
return false; |
||||||
|
} |
||||||
|
}, |
||||||
|
TabLayout { |
||||||
|
@Override |
||||||
|
protected boolean acceptType(Widget widget) { |
||||||
|
return widget.acceptType(WCardLayout.class); |
||||||
|
} |
||||||
|
}, |
||||||
|
Absolute { |
||||||
|
@Override |
||||||
|
protected boolean acceptType(Widget widget) { |
||||||
|
return widget.acceptType(WAbsoluteLayout.class); |
||||||
|
} |
||||||
|
}; |
||||||
|
|
||||||
|
protected abstract boolean acceptType(Widget widget); |
||||||
|
|
||||||
|
public static ComponentType parseType(Widget widget) { |
||||||
|
for (ComponentType componentType : values()) { |
||||||
|
if (componentType.acceptType(widget)) { |
||||||
|
return componentType; |
||||||
|
} |
||||||
|
} |
||||||
|
return Widget; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.form.ui.ChartEditor; |
||||||
|
import com.fr.form.ui.ElementCaseEditor; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.form.ui.container.WAbsoluteLayout; |
||||||
|
import com.fr.form.ui.container.WCardLayout; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public class ComponentCreateOperateTest { |
||||||
|
@Test |
||||||
|
public void testToJSONObject() { |
||||||
|
Widget button = new FreeButton(); |
||||||
|
button.setWidgetName("button1"); |
||||||
|
ComponentCreateOperate info = new ComponentCreateOperate(button); |
||||||
|
button.setWidgetID("xxxxxxx"); |
||||||
|
JSONObject jo = info.toJSONObject(); |
||||||
|
Assert.assertEquals("xxxxxxx", jo.optString("componentID")); |
||||||
|
Assert.assertEquals("button1", jo.optString("componentName")); |
||||||
|
Assert.assertEquals("Widget", jo.optString("componentType")); |
||||||
|
Assert.assertEquals("0", jo.optString("deleteTime")); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testComponentType() { |
||||||
|
Assert.assertEquals(ComponentOperate.ComponentType.Widget, ComponentOperate.ComponentType.parseType(new FreeButton())); |
||||||
|
Assert.assertEquals(ComponentOperate.ComponentType.Report, ComponentOperate.ComponentType.parseType(new ElementCaseEditor())); |
||||||
|
Assert.assertEquals(ComponentOperate.ComponentType.Chart, ComponentOperate.ComponentType.parseType(new ChartEditor())); |
||||||
|
Assert.assertEquals(ComponentOperate.ComponentType.Absolute, ComponentOperate.ComponentType.parseType(new WAbsoluteLayout())); |
||||||
|
Assert.assertEquals(ComponentOperate.ComponentType.TabLayout, ComponentOperate.ComponentType.parseType(new WCardLayout())); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,149 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.form.main.Form; |
||||||
|
import com.fr.form.ui.CardSwitchButton; |
||||||
|
import com.fr.form.ui.ChartEditor; |
||||||
|
import com.fr.form.ui.ElementCaseEditor; |
||||||
|
import com.fr.form.ui.FreeButton; |
||||||
|
import com.fr.form.ui.container.WAbsoluteLayout; |
||||||
|
import com.fr.form.ui.container.WBorderLayout; |
||||||
|
import com.fr.form.ui.container.WCardLayout; |
||||||
|
import com.fr.form.ui.container.WFitLayout; |
||||||
|
import com.fr.form.ui.container.WParameterLayout; |
||||||
|
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.plugin.chart.vanchart.VanChart; |
||||||
|
import com.fr.report.cell.DefaultTemplateCellElement; |
||||||
|
import com.fr.report.worksheet.FormElementCase; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public class JFormProcessInfoTest { |
||||||
|
@Test |
||||||
|
public void testHasTestECReport() { |
||||||
|
Form form = new Form(); |
||||||
|
WFitLayout wFitLayout = new WFitLayout(); |
||||||
|
ElementCaseEditor editor = new ElementCaseEditor(); |
||||||
|
FormElementCase elementCase = new FormElementCase(); |
||||||
|
editor.setElementCase(elementCase); |
||||||
|
wFitLayout.addWidget(editor); |
||||||
|
form.setContainer(wFitLayout); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); |
||||||
|
Assert.assertTrue(result1); |
||||||
|
|
||||||
|
elementCase.addCellElement(new DefaultTemplateCellElement()); |
||||||
|
boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestECReport").get(); |
||||||
|
Assert.assertTrue(result2); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testHasTestChart() { |
||||||
|
Form form = new Form(); |
||||||
|
WFitLayout wFitLayout = new WFitLayout(); |
||||||
|
ChartEditor editor = new ChartEditor(); |
||||||
|
ChartCollection collection = new ChartCollection(); |
||||||
|
editor.resetChangeChartCollection(collection); |
||||||
|
wFitLayout.addWidget(editor); |
||||||
|
form.setContainer(wFitLayout); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestChart").get(); |
||||||
|
Assert.assertTrue(result1); |
||||||
|
|
||||||
|
collection.addChart(new VanChart()); |
||||||
|
boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestChart").get(); |
||||||
|
Assert.assertTrue(result2); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testHasTestTabLayout() { |
||||||
|
Form form = new Form(); |
||||||
|
WFitLayout wFitLayout = new WFitLayout(); |
||||||
|
WCardLayout editor = new WCardLayout(); |
||||||
|
wFitLayout.addWidget(editor); |
||||||
|
form.setContainer(wFitLayout); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestTabLayout").get(); |
||||||
|
Assert.assertFalse(result1); |
||||||
|
|
||||||
|
WCardTagLayout tagLayout = new WCardTagLayout(); |
||||||
|
CardSwitchButton button = new CardSwitchButton(); |
||||||
|
button.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title") + "0"); |
||||||
|
tagLayout.addWidget(button); |
||||||
|
editor.addWidget(tagLayout); |
||||||
|
boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestTabLayout").get(); |
||||||
|
Assert.assertTrue(result2); |
||||||
|
|
||||||
|
button.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title") + "test"); |
||||||
|
boolean result3 = Reflect.on(jFormProcessInfo).call("hasTestTabLayout").get(); |
||||||
|
Assert.assertFalse(result3); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testHasTestAbsolutePane() { |
||||||
|
Form form = new Form(); |
||||||
|
WFitLayout wFitLayout = new WFitLayout(); |
||||||
|
WAbsoluteLayout editor = new WAbsoluteLayout(); |
||||||
|
wFitLayout.addWidget(editor); |
||||||
|
form.setContainer(wFitLayout); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
boolean result1 = Reflect.on(jFormProcessInfo).call("hasTestAbsolutePane").get(); |
||||||
|
Assert.assertTrue(result1); |
||||||
|
|
||||||
|
editor.addWidget(new FreeButton()); |
||||||
|
boolean result2 = Reflect.on(jFormProcessInfo).call("hasTestAbsolutePane").get(); |
||||||
|
Assert.assertFalse(result2); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testHasEmptyParaPane() { |
||||||
|
Form form = new Form(); |
||||||
|
WBorderLayout borderLayout = new WBorderLayout(); |
||||||
|
form.setContainer(borderLayout); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
boolean result1 = Reflect.on(jFormProcessInfo).call("hasEmptyParaPane").get(); |
||||||
|
Assert.assertFalse(result1); |
||||||
|
|
||||||
|
borderLayout.addNorth(new WParameterLayout()); |
||||||
|
boolean result2 = Reflect.on(jFormProcessInfo).call("hasEmptyParaPane").get(); |
||||||
|
Assert.assertTrue(result2); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testUseParaPane() { |
||||||
|
Form form = new Form(); |
||||||
|
WBorderLayout borderLayout = new WBorderLayout(); |
||||||
|
form.setContainer(borderLayout); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
Assert.assertFalse(jFormProcessInfo.useParaPane()); |
||||||
|
|
||||||
|
borderLayout.addNorth(new WParameterLayout()); |
||||||
|
Assert.assertTrue(jFormProcessInfo.useParaPane()); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetComponentsInfo() { |
||||||
|
Form form = new Form(); |
||||||
|
JFormProcessInfo jFormProcessInfo = new JFormProcessInfo(form); |
||||||
|
FreeButton button1 = new FreeButton(); |
||||||
|
FreeButton button2 = new FreeButton(); |
||||||
|
button1.setWidgetID("xxxx1"); |
||||||
|
button2.setWidgetID("xxxx2"); |
||||||
|
Reflect.on(jFormProcessInfo).call("addComponentCreateInfo", new ComponentCreateOperate(button1).toJSONObject()); |
||||||
|
Reflect.on(jFormProcessInfo).call("addComponentRemoveInfo", new ComponentDeleteOperate(button2).toJSONObject()); |
||||||
|
JSONArray ja = jFormProcessInfo.getComponentsInfo(); |
||||||
|
Assert.assertEquals(2, ja.size()); |
||||||
|
|
||||||
|
|
||||||
|
ja = jFormProcessInfo.getComponentsInfo(); |
||||||
|
Assert.assertEquals(0, ja.size()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.report.block.Block; |
||||||
|
import com.fr.report.poly.PolyChartBlock; |
||||||
|
import com.fr.report.poly.PolyWorkSheet; |
||||||
|
import com.fr.report.report.Report; |
||||||
|
|
||||||
|
import java.util.Iterator; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-06 |
||||||
|
*/ |
||||||
|
public class JPolyWorkBookProcessInfo extends JWorkBookProcessInfo { |
||||||
|
public JPolyWorkBookProcessInfo(WorkBook template) { |
||||||
|
super(template); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getReportType() { |
||||||
|
return 1; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getCellCount() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getFloatCount() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getBlockCount() { |
||||||
|
int blockCount = 0; |
||||||
|
if (!template.isElementCaseBook()) { // 如果是聚合报表
|
||||||
|
for (int i = 0; i < template.getReportCount(); i++) { |
||||||
|
Report report = template.getReport(i); |
||||||
|
// 考虑多个sheet下 包含WorkSheet的情况 需要判断下
|
||||||
|
if (report instanceof PolyWorkSheet) { |
||||||
|
PolyWorkSheet r = (PolyWorkSheet) report; |
||||||
|
blockCount += r.getBlockCount(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return blockCount; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean isTestTemplate() { |
||||||
|
Iterator<String> it = this.template.getTableDataNameIterator(); |
||||||
|
if (!it.hasNext() || getBlockCount() <= 1 || isTestECReport() || isTestChartBlock()) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private boolean isTestChartBlock() { |
||||||
|
int count = this.template.getReportCount(); |
||||||
|
for (int m = 0; m < count; m++) { |
||||||
|
PolyWorkSheet report = (PolyWorkSheet) this.template.getReport(m); |
||||||
|
int blockCount = report.getBlockCount(); |
||||||
|
for (int i = 0; i < blockCount; i++) { |
||||||
|
Block block = report.getBlock(i); |
||||||
|
if (block instanceof PolyChartBlock && isTestChartCollection((ChartCollection) ((PolyChartBlock) block).getChartCollection())) { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package com.fr.design.mainframe.template.info; |
||||||
|
|
||||||
|
import com.fr.base.Style; |
||||||
|
import com.fr.chart.chartattr.ChartCollection; |
||||||
|
import com.fr.form.main.parameter.FormParameterUI; |
||||||
|
import com.fr.invoke.Reflect; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.main.impl.WorkBook; |
||||||
|
import com.fr.main.parameter.ReportParameterAttr; |
||||||
|
import com.fr.plugin.chart.vanchart.VanChart; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by kerry on 2020-05-08 |
||||||
|
*/ |
||||||
|
public class JWorkBookProcessInfoTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testIsTestCell() { |
||||||
|
ChartCollection chartCollection = new ChartCollection(); |
||||||
|
chartCollection.addChart(new VanChart()); |
||||||
|
JWorkBookProcessInfo processInfo = new JWorkBookProcessInfo(new WorkBook()); |
||||||
|
boolean result = Reflect.on(processInfo).call("isTestCell", chartCollection, Style.getInstance()).get(); |
||||||
|
Assert.assertTrue(result); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Test |
||||||
|
public void testUseParaPane(){ |
||||||
|
WorkBook workBook = new WorkBook(); |
||||||
|
JWorkBookProcessInfo processInfo = new JWorkBookProcessInfo(workBook); |
||||||
|
Assert.assertFalse(processInfo.useParaPane()); |
||||||
|
|
||||||
|
ReportParameterAttr attr = new ReportParameterAttr(); |
||||||
|
workBook.setReportParameterAttr(attr); |
||||||
|
Assert.assertFalse(processInfo.useParaPane()); |
||||||
|
|
||||||
|
attr.setParameterUI(new FormParameterUI()); |
||||||
|
Assert.assertTrue(processInfo.useParaPane()); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testGetComponentsInfo() { |
||||||
|
JWorkBookProcessInfo processInfo = new JWorkBookProcessInfo(new WorkBook()); |
||||||
|
JSONArray ja = processInfo.getComponentsInfo(); |
||||||
|
Assert.assertEquals(0, ja.size()); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue