Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
31c5708e71
  1. 2
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  3. 9
      designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java
  4. 1
      designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java
  5. 113
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java
  6. 115
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java
  7. 20
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java
  8. 46
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java
  10. 8
      designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java
  11. 131
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java
  12. 90
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java
  13. 18
      designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java
  14. 44
      designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info
  15. 23
      designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java
  16. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/cuvette.png
  17. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_180.png
  18. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_360.png
  19. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/ring.png
  20. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/cuvette.png
  21. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_180.png
  22. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_360.png
  23. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/ring.png
  24. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/slot.png
  25. BIN
      designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/slot.png
  26. 4
      designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java
  27. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java
  28. 17
      designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java
  29. 2
      designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java
  30. 3
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  31. 6
      designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java
  32. 36
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentCreateOperate.java
  33. 29
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentDeleteOperate.java
  34. 80
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java
  35. 161
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  36. 38
      designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java
  37. 149
      designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java
  38. 12
      designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java
  39. 77
      designer-realize/src/main/java/com/fr/design/mainframe/template/info/JPolyWorkBookProcessInfo.java
  40. 84
      designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java
  41. 2
      designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java
  42. 49
      designer-realize/src/test/java/com.fr/design/mainframe/template/info/JWorkBookProcessInfoTest.java

2
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -240,7 +240,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
"floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART}, "floatelement", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.POLY_REPORT});
// 控件设置 // 控件设置
PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Settings"), PropertyItem widgetSettings = new PropertyItem(KEY_WIDGET_SETTINGS, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Settings"),
"widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY}, "widgetsettings", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.FORM, PropertyMode.POLY},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.FORM, PropertyMode.POLY_REPORT, PropertyMode.POLY_CHART}); new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.FORM, PropertyMode.POLY_REPORT, PropertyMode.POLY_CHART});
// 条件属性 // 条件属性

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -97,7 +97,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复 private static short currentIndex = 0;// 此变量用于多次新建模板时,让名字不重复
private DesignModelAdapter<T, ?> designModel; private DesignModelAdapter<T, ?> designModel;
private PreviewProvider previewType; private PreviewProvider previewType;
private TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
public int resolution = ScreenResolution.getScreenResolution(); public int resolution = ScreenResolution.getScreenResolution();
public JTemplate() { public JTemplate() {

9
designer-base/src/main/java/com/fr/design/mainframe/burying/point/AbstractPointInfo.java

@ -11,6 +11,9 @@ public abstract class AbstractPointInfo implements BasePointInfo {
protected int idleDayCount; // 到现在为止,埋点闲置的天数 protected int idleDayCount; // 到现在为止,埋点闲置的天数
//是否是测试模板
protected boolean testTemplate;
@Override @Override
public void resetIdleDayCount() { public void resetIdleDayCount() {
this.idleDayCount = 0; this.idleDayCount = 0;
@ -38,10 +41,14 @@ public abstract class AbstractPointInfo implements BasePointInfo {
} }
} }
public void setTestTemplate(boolean testTemplate) {
testTemplate = testTemplate;
}
/** /**
* 是否为测试模板 * 是否为测试模板
*/ */
protected abstract boolean isTestTemplate(); public abstract boolean isTestTemplate();
/** /**
* 是否已经制作完成 * 是否已经制作完成

1
designer-base/src/main/java/com/fr/design/mainframe/chart/info/ChartInfo.java

@ -67,7 +67,6 @@ public class ChartInfo extends AbstractPointInfo {
private BaseBook book; private BaseBook book;
private boolean testTemplate;
private boolean testChart; private boolean testChart;

113
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfo.java

@ -4,17 +4,15 @@ import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.burying.point.AbstractPointInfo; import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.GeneralUtils; import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.fr.third.joda.time.DateTime;
/** /**
* 对应一张模版的记录 * 对应一张模版的记录
@ -22,6 +20,7 @@ import java.util.Map;
*/ */
public class TemplateInfo extends AbstractPointInfo { public class TemplateInfo extends AbstractPointInfo {
static final String XML_TAG = "TemplateInfo"; static final String XML_TAG = "TemplateInfo";
private static final String SIMPLE_DATE_PATTRN = "yyyy-MM-dd HH:mm";
private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single"; private static final String CONSUMING_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.consuming") + "/single";
private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single"; private static final String PROCESS_URL = CloudCenter.getInstance().acquireUrlByKind("tempinfo.process") + "/single";
@ -37,18 +36,17 @@ public class TemplateInfo extends AbstractPointInfo {
private static final String ATTR_CELL_COUNT = "cell_count"; private static final String ATTR_CELL_COUNT = "cell_count";
private static final String ATTR_BLOCK_COUNT = "block_count"; private static final String ATTR_BLOCK_COUNT = "block_count";
private static final String ATTR_REPORT_TYPE = "report_type"; private static final String ATTR_REPORT_TYPE = "report_type";
private static final String ATTR_ACTIVITYKEY = "activitykey";
private static final String ATTR_JAR_TIME = "jar_time";
private static final String ATTR_CREATE_TIME = "create_time"; private static final String ATTR_CREATE_TIME = "create_time";
private static final String ATTR_UUID = "uuid"; private static final String ATTR_UUID = "uuid";
private static final String ATTR_TIME_CONSUME = "time_consume"; private static final String ATTR_UID = "uid";
private static final String ATTR_ORIGIN_TIME = "originTime"; private static final String ATTR_SAVE_RECORD = "saveRecord";
private static final String ATTR_VERSION = "version"; private static final String ATTR_PARA_APPLY = "paraApply";
private static final String ATTR_USERNAME = "username"; private static final String ATTR_COMPONENTS_INFO = "components_info";
private static final String TEST_TEMPLATE_FLAG = "test_template";
private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数 private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数
private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数
private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数
private String templateID = StringUtils.EMPTY; private String templateID = StringUtils.EMPTY;
private String originID = StringUtils.EMPTY; private String originID = StringUtils.EMPTY;
@ -76,28 +74,25 @@ public class TemplateInfo extends AbstractPointInfo {
} }
public static TemplateInfo newInstance(String templateID) { public static TemplateInfo newInstance(String templateID) {
return newInstance(templateID, StringUtils.EMPTY, 0); return newInstance(templateID, StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY);
}
public static TemplateInfo newInstance(String templateID, String originID, String saveRecord) {
String createTime = DateTime.now().toString(SIMPLE_DATE_PATTRN);
return newInstance(templateID, originID, saveRecord, createTime);
} }
public static TemplateInfo newInstance(String templateID, String originID, int originTime) { public static TemplateInfo newInstance(String templateID, String originID, String saveRecord, String createTime) {
HashMap<String, Object> consumingMap = new HashMap<>(); HashMap<String, Object> consumingMap = new HashMap<>();
String username = MarketConfig.getInstance().getBbsUsername();
String uuid = DesignerEnvManager.getEnvManager().getUUID(); String uuid = DesignerEnvManager.getEnvManager().getUUID();
String activitykey = DesignerEnvManager.getEnvManager().getActivationKey(); MarketConfig config = MarketConfig.getInstance();
String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm").format(Calendar.getInstance().getTime());
String jarTime = GeneralUtils.readBuildNO();
String version = ProductConstants.VERSION;
consumingMap.put(ATTR_USERNAME, username);
consumingMap.put(ATTR_UUID, uuid); consumingMap.put(ATTR_UUID, uuid);
consumingMap.put(ATTR_ACTIVITYKEY, activitykey);
consumingMap.put(ATTR_TEMPLATE_ID, templateID); consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put(ATTR_ORIGIN_ID, originID); consumingMap.put(ATTR_ORIGIN_ID, originID);
consumingMap.put(ATTR_CREATE_TIME, createTime); consumingMap.put(ATTR_CREATE_TIME, createTime);
consumingMap.put(ATTR_TIME_CONSUME, originTime); // timeConsume 在原来模版的基础上累加 consumingMap.put(ATTR_UID, config.getBBSAttr().getBbsUid());
consumingMap.put(ATTR_ORIGIN_TIME, originTime); consumingMap.put(ATTR_SAVE_RECORD, saveRecord);
consumingMap.put(ATTR_JAR_TIME, jarTime);
consumingMap.put(ATTR_VERSION, version);
TemplateInfo templateInfo = new TemplateInfo(templateID, originID); TemplateInfo templateInfo = new TemplateInfo(templateID, originID);
templateInfo.consumingMap = consumingMap; templateInfo.consumingMap = consumingMap;
@ -109,14 +104,21 @@ public class TemplateInfo extends AbstractPointInfo {
return templateID; return templateID;
} }
String getOriginID() { public String getTemplateInfoID() {
return originID; return templateID + "_" + getSaveTime();
} }
int getTimeConsume() { public long getSaveTime() {
return (int) consumingMap.get(ATTR_TIME_CONSUME); String saveRecord = (String) consumingMap.get(ATTR_SAVE_RECORD);
JSONObject jo = JSONFactory.createJSON(JSON.OBJECT, saveRecord);
return jo.getLong("time");
} }
public String getTemplateCreateTime() {
return (String) consumingMap.get(ATTR_CREATE_TIME);
}
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG); writer.startTAG(XML_TAG);
@ -129,6 +131,7 @@ public class TemplateInfo extends AbstractPointInfo {
if (idleDayCount >= 0) { if (idleDayCount >= 0) {
writer.attr(ATTR_DAY_COUNT, this.idleDayCount); writer.attr(ATTR_DAY_COUNT, this.idleDayCount);
} }
writer.attr(TEST_TEMPLATE_FLAG, this.testTemplate);
writeProcessMap(writer); writeProcessMap(writer);
writeConsumingMap(writer); writeConsumingMap(writer);
@ -143,19 +146,17 @@ public class TemplateInfo extends AbstractPointInfo {
writer.attr(ATTR_CELL_COUNT, (int) processMap.get(ATTR_CELL_COUNT)); writer.attr(ATTR_CELL_COUNT, (int) processMap.get(ATTR_CELL_COUNT));
writer.attr(ATTR_BLOCK_COUNT, (int) processMap.get(ATTR_BLOCK_COUNT)); writer.attr(ATTR_BLOCK_COUNT, (int) processMap.get(ATTR_BLOCK_COUNT));
writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE)); writer.attr(ATTR_REPORT_TYPE, (int) processMap.get(ATTR_REPORT_TYPE));
writer.attr(ATTR_PARA_APPLY, (int) processMap.get(ATTR_PARA_APPLY));
writer.attr(ATTR_COMPONENTS_INFO, (String) processMap.get(ATTR_COMPONENTS_INFO));
writer.end(); writer.end();
} }
private void writeConsumingMap(XMLPrintWriter writer) { private void writeConsumingMap(XMLPrintWriter writer) {
writer.startTAG(XML_CONSUMING_MAP); writer.startTAG(XML_CONSUMING_MAP);
writer.attr(ATTR_ACTIVITYKEY, (String) consumingMap.get(ATTR_ACTIVITYKEY));
writer.attr(ATTR_JAR_TIME, (String) consumingMap.get(ATTR_JAR_TIME));
writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME)); writer.attr(ATTR_CREATE_TIME, (String) consumingMap.get(ATTR_CREATE_TIME));
writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID)); writer.attr(ATTR_UUID, (String) consumingMap.get(ATTR_UUID));
writer.attr(ATTR_TIME_CONSUME, (int) consumingMap.get(ATTR_TIME_CONSUME)); writer.attr(ATTR_UID, (int) consumingMap.get(ATTR_UID));
writer.attr(ATTR_ORIGIN_TIME, (int) consumingMap.get(ATTR_ORIGIN_TIME)); writer.attr(ATTR_SAVE_RECORD, (String) consumingMap.get(ATTR_SAVE_RECORD));
writer.attr(ATTR_VERSION, (String) consumingMap.get(ATTR_VERSION));
writer.attr(ATTR_USERNAME, (String) consumingMap.get(ATTR_USERNAME));
writer.end(); writer.end();
} }
@ -163,6 +164,7 @@ public class TemplateInfo extends AbstractPointInfo {
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (!reader.isChildNode()) { if (!reader.isChildNode()) {
idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0); idleDayCount = reader.getAttrAsInt(ATTR_DAY_COUNT, 0);
testTemplate = reader.getAttrAsBoolean(TEST_TEMPLATE_FLAG, false);
templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY); templateID = reader.getAttrAsString(ATTR_TEMPLATE_ID, StringUtils.EMPTY);
originID = reader.getAttrAsString(ATTR_ORIGIN_ID, StringUtils.EMPTY); originID = reader.getAttrAsString(ATTR_ORIGIN_ID, StringUtils.EMPTY);
} else { } else {
@ -175,18 +177,16 @@ public class TemplateInfo extends AbstractPointInfo {
processMap.put(ATTR_CELL_COUNT, reader.getAttrAsInt(ATTR_CELL_COUNT, 0)); processMap.put(ATTR_CELL_COUNT, reader.getAttrAsInt(ATTR_CELL_COUNT, 0));
processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0)); processMap.put(ATTR_BLOCK_COUNT, reader.getAttrAsInt(ATTR_BLOCK_COUNT, 0));
processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0)); processMap.put(ATTR_REPORT_TYPE, reader.getAttrAsInt(ATTR_REPORT_TYPE, 0));
processMap.put(ATTR_PARA_APPLY, reader.getAttrAsInt(ATTR_PARA_APPLY, 0));
processMap.put(ATTR_COMPONENTS_INFO, reader.getAttrAsString(ATTR_COMPONENTS_INFO, StringUtils.EMPTY));
processMap.put(ATTR_TEMPLATE_ID, templateID); processMap.put(ATTR_TEMPLATE_ID, templateID);
} else if (XML_CONSUMING_MAP.equals(name)) { } else if (XML_CONSUMING_MAP.equals(name)) {
consumingMap.put(ATTR_ACTIVITYKEY, reader.getAttrAsString(ATTR_ACTIVITYKEY, StringUtils.EMPTY));
consumingMap.put(ATTR_JAR_TIME, reader.getAttrAsString(ATTR_JAR_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY)); consumingMap.put(ATTR_CREATE_TIME, reader.getAttrAsString(ATTR_CREATE_TIME, StringUtils.EMPTY));
consumingMap.put(ATTR_TEMPLATE_ID, templateID); consumingMap.put(ATTR_TEMPLATE_ID, templateID);
consumingMap.put(ATTR_ORIGIN_ID, originID); consumingMap.put(ATTR_ORIGIN_ID, originID);
consumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY)); consumingMap.put(ATTR_UUID, reader.getAttrAsString(ATTR_UUID, StringUtils.EMPTY));
consumingMap.put(ATTR_TIME_CONSUME, reader.getAttrAsInt(ATTR_TIME_CONSUME, 0)); consumingMap.put(ATTR_UID, reader.getAttrAsInt(ATTR_UID, 0));
consumingMap.put(ATTR_ORIGIN_TIME, reader.getAttrAsInt(ATTR_ORIGIN_TIME, 0)); consumingMap.put(ATTR_SAVE_RECORD, reader.getAttrAsString(ATTR_SAVE_RECORD, StringUtils.EMPTY));
consumingMap.put(ATTR_VERSION, reader.getAttrAsString(ATTR_VERSION, "8.0"));
consumingMap.put(ATTR_USERNAME, reader.getAttrAsString(ATTR_USERNAME, StringUtils.EMPTY));
} }
} catch (Exception ex) { } catch (Exception ex) {
// 什么也不做,使用默认值 // 什么也不做,使用默认值
@ -195,17 +195,8 @@ public class TemplateInfo extends AbstractPointInfo {
} }
@Override @Override
protected boolean isTestTemplate() { public boolean isTestTemplate() {
if (!isComplete()) { return testTemplate;
return false;
}
int reportType = (int) processMap.get(ATTR_REPORT_TYPE);
int cellCount = (int) processMap.get(ATTR_CELL_COUNT);
int floatCount = (int) processMap.get(ATTR_FLOAT_COUNT);
int blockCount = (int) processMap.get(ATTR_BLOCK_COUNT);
int widgetCount = (int) processMap.get(ATTR_WIDGET_COUNT);
return isTestTemplate(reportType, cellCount, floatCount, blockCount, widgetCount);
} }
public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) { public static boolean isTestTemplate(int reportType, int cellCount, int floatCount, int blockCount, int widgetCount) {
@ -222,25 +213,17 @@ public class TemplateInfo extends AbstractPointInfo {
@Override @Override
protected boolean isComplete() { protected boolean isComplete() {
// 条件 1. 超过15天未编辑 return true;
// 条件 2. 设计器在这段未编辑的时间内启动超过 X 次(目前定的 X = 3)。即"设计器最近 X 次启动的时间跨度" < "未编辑时间";
return idleDayCount > COMPLETE_DAY_COUNT
&& DesignerOpenHistory.getInstance().isOpenEnoughTimesInPeriod(idleDayCount);
} }
@Override @Override
public Map<String, String> getSendInfo() { public Map<String, String> getSendInfo() {
Map<String, String> sendMap = new HashMap<>(); Map<String, String> sendMap = new HashMap<>();
sendMap.put(CONSUMING_URL, new JSONObject(consumingMap).toString()); sendMap.put(CONSUMING_URL, JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString());
sendMap.put(PROCESS_URL, new JSONObject(processMap).toString()); sendMap.put(PROCESS_URL, JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
return sendMap; return sendMap;
} }
void addTimeConsume(int timeConsume) {
timeConsume += (int) consumingMap.get(ATTR_TIME_CONSUME); // 加上之前的累计编辑时间
consumingMap.put(ATTR_TIME_CONSUME, timeConsume);
}
void updateProcessMap(TemplateProcessInfo processInfo) { void updateProcessMap(TemplateProcessInfo processInfo) {
HashMap<String, Object> processMap = new HashMap<>(); HashMap<String, Object> processMap = new HashMap<>();
@ -253,10 +236,12 @@ public class TemplateInfo extends AbstractPointInfo {
processMap.put(ATTR_FLOAT_COUNT, processInfo.getFloatCount()); processMap.put(ATTR_FLOAT_COUNT, processInfo.getFloatCount());
processMap.put(ATTR_BLOCK_COUNT, processInfo.getBlockCount()); processMap.put(ATTR_BLOCK_COUNT, processInfo.getBlockCount());
processMap.put(ATTR_WIDGET_COUNT, processInfo.getWidgetCount()); processMap.put(ATTR_WIDGET_COUNT, processInfo.getWidgetCount());
processMap.put(ATTR_PARA_APPLY, processInfo.useParaPane() ? 1 : 0);
processMap.put(ATTR_COMPONENTS_INFO, processInfo.getComponentsInfo().toString());
this.processMap = processMap; this.processMap = processMap;
} }
int getIdleDayCount() { int getIdleDayCount() {
return this.idleDayCount; return this.idleDayCount;
} }

115
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -1,6 +1,10 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.design.mainframe.burying.point.AbstractPointCollector; import com.fr.design.mainframe.burying.point.AbstractPointCollector;
import com.fr.design.mainframe.burying.point.AbstractPointInfo;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -8,6 +12,10 @@ import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* 做模板的过程和耗时收集辅助类 * 做模板的过程和耗时收集辅助类
@ -19,8 +27,11 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
private static final String XML_FILE_NAME = "tpl.info"; private static final String XML_FILE_NAME = "tpl.info";
private static TemplateInfoCollector instance; private static TemplateInfoCollector instance;
private DesignerOpenHistory designerOpenHistory; private DesignerOpenHistory designerOpenHistory;
//记录指定模板最新的模板耗时信息ID
private Map<String, Long> latestTemplateInfo;
private TemplateInfoCollector() { private TemplateInfoCollector() {
super();
} }
public static TemplateInfoCollector getInstance() { public static TemplateInfoCollector getInstance() {
@ -34,7 +45,7 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
* 根据模板ID是否在收集列表中判断是否需要收集当前模板的信息 * 根据模板ID是否在收集列表中判断是否需要收集当前模板的信息
*/ */
public boolean contains(String templateID) { public boolean contains(String templateID) {
return StringUtils.isNotEmpty(templateID) && pointInfoMap.containsKey(templateID); return StringUtils.isNotEmpty(templateID) && latestTemplateInfo.containsKey(templateID);
} }
/** /**
@ -51,27 +62,43 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
if (!shouldCollectInfo()) { if (!shouldCollectInfo()) {
return; return;
} }
long saveTime = System.currentTimeMillis();
TemplateInfo templateInfo; TemplateInfo templateInfo = createTemplateInfo(templateID, originID, saveTime, timeConsume);
if (this.contains(templateID)) {
templateInfo = pointInfoMap.get(templateID); pointInfoMap.put(templateInfo.getTemplateInfoID(), templateInfo);
} else {
int originTime = this.contains(originID) ? pointInfoMap.get(originID).getTimeConsume() : 0; //更新下此模板最新保存记录
templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); updateLatestTemplateInfo(templateID, saveTime);
pointInfoMap.put(templateID, templateInfo);
}
// 收集制作耗时
templateInfo.addTimeConsume(timeConsume);
// 收集模版基本信息 // 收集模版基本信息
templateInfo.updateProcessMap(processInfo); templateInfo.updateProcessMap(processInfo);
//设置是否是测试模板
templateInfo.setTestTemplate(processInfo.isTestTemplate());
// 刷新闲置日计数器 // 刷新闲置日计数器
templateInfo.resetIdleDayCount(); templateInfo.resetIdleDayCount();
// 每次更新之后,都同步到暂存文件中 // 每次更新之后,都同步到暂存文件中
saveInfo(); saveInfo();
} }
private TemplateInfo createTemplateInfo(String templateID, String originID, long saveTime, int timeConsume){
JSONObject saveRecord = JSONFactory.createJSON(JSON.OBJECT);
saveRecord.put("time", saveTime);
saveRecord.put("consume", timeConsume);
if (this.contains(templateID)){
return TemplateInfo.newInstance(templateID, originID, saveRecord.toString(), getTemplateCreateTime(templateID));
}
return TemplateInfo.newInstance(templateID, originID, saveRecord.toString());
}
private String getTemplateCreateTime(String templateID) {
long latestSaveTime = latestTemplateInfo.get(templateID);
TemplateInfo latestTemplateInfo = pointInfoMap.get(templateID + "_" + latestSaveTime);
return latestTemplateInfo.getTemplateCreateTime();
}
/** /**
* 获取缓存文件存放路径 * 获取缓存文件存放路径
*/ */
@ -80,15 +107,6 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME)); return new File(StableUtils.pathJoin(ProductConstants.getEnvHome(), XML_FILE_NAME));
} }
TemplateInfo getOrCreateTemplateInfoByID(String templateID) {
if (pointInfoMap.containsKey(templateID)) {
return pointInfoMap.get(templateID);
}
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID);
pointInfoMap.put(templateID, templateInfo);
return templateInfo;
}
/** /**
* 更新 day_count打开设计器却未编辑模板的连续日子 * 更新 day_count打开设计器却未编辑模板的连续日子
*/ */
@ -104,6 +122,20 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
designerOpenHistory.update(); designerOpenHistory.update();
} }
private void updateLatestTemplateInfo(TemplateInfo templateInfo) {
String templateID = templateInfo.getTemplateID();
if (latestTemplateInfo.containsKey(templateID)) {
long latestSaveTime = latestTemplateInfo.get(templateID);
updateLatestTemplateInfo(templateID, Math.max(latestSaveTime, templateInfo.getSaveTime()));
} else {
updateLatestTemplateInfo(templateID, templateInfo.getSaveTime());
}
}
private void updateLatestTemplateInfo(String templateID, long saveTime) {
latestTemplateInfo.put(templateID, saveTime);
}
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isChildNode()) { if (reader.isChildNode()) {
@ -116,7 +148,8 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
reader.readXMLObject(designerOpenHistory); reader.readXMLObject(designerOpenHistory);
} else if (TemplateInfo.XML_TAG.equals(name)) { } else if (TemplateInfo.XML_TAG.equals(name)) {
TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(reader); TemplateInfo templateInfo = TemplateInfo.newInstanceByRead(reader);
pointInfoMap.put(templateInfo.getTemplateID(), templateInfo); updateLatestTemplateInfo(templateInfo);
pointInfoMap.put(templateInfo.getTemplateInfoID(), templateInfo);
} }
} catch (Exception ex) { } catch (Exception ex) {
// 什么也不做,使用默认值 // 什么也不做,使用默认值
@ -138,4 +171,44 @@ public class TemplateInfoCollector extends AbstractPointCollector<TemplateInfo>
writer.end(); writer.end();
} }
@Override
public void sendPointInfo() {
addIdleDayCount();
List<String> removeList = new ArrayList<>();
List<String> sendList = new ArrayList<>();
for (String latestTemplateInfokey : latestTemplateInfo.keySet()) {
AbstractPointInfo pointInfo = pointInfoMap.get(latestTemplateInfokey + "_" + latestTemplateInfo.get(latestTemplateInfokey));
if (pointInfo.isTestTemplate()) {
continue;
}
for (String key : pointInfoMap.keySet()) {
if (key.startsWith(latestTemplateInfokey)) {
sendList.add(key);
}
}
}
// 发送记录
for (String key : sendList) {
if (SendHelper.sendPointInfo(pointInfoMap.get(key))) {
removeList.add(key);
}
}
// 清空记录
for (String key : removeList) {
pointInfoMap.remove(key);
}
saveInfo();
}
@Override
protected void loadFromFile() {
latestTemplateInfo = new ConcurrentHashMap<>();
super.loadFromFile();
}
} }

20
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java

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

46
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java

@ -1,6 +1,10 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.base.Style;
import com.fr.base.io.BaseBook; import com.fr.base.io.BaseBook;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.json.JSONArray;
/** /**
* Created by plough on 2017/3/17. * Created by plough on 2017/3/17.
@ -19,12 +23,54 @@ public abstract class TemplateProcessInfo<T extends BaseBook> {
// 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单 // 获取模板类型。0 代表普通报表,1 代表聚合报表,2 代表表单
public abstract int getReportType(); public abstract int getReportType();
// 获取模板格子数 // 获取模板格子数
public abstract int getCellCount(); public abstract int getCellCount();
// 获取模板悬浮元素个数 // 获取模板悬浮元素个数
public abstract int getFloatCount(); public abstract int getFloatCount();
// 获取模板聚合块个数 // 获取模板聚合块个数
public abstract int getBlockCount(); public abstract int getBlockCount();
// 获取模板控件数 // 获取模板控件数
public abstract int getWidgetCount(); public abstract int getWidgetCount();
//是否是测试模板
public abstract boolean isTestTemplate();
//是否使用参数面板
public abstract boolean useParaPane();
//获取组件信息
public abstract JSONArray getComponentsInfo();
public abstract void updateTemplateOperationInfo(TemplateOperate templateOption);
protected boolean isTestCell(Object value, Style style) {
if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) {
return true;
}
if (value == null && Style.getInstance().equals(style)) {
return true;
}
return false;
}
protected boolean isTestChartCollection(ChartCollection chartCollection) {
int chartCount = chartCollection.getChartCount();
if (chartCount == 0) {
return true;
}
for (int i = 0; i < chartCount; i++) {
ChartProvider chart = chartCollection.getChart(i, ChartProvider.class);
if (chart.isTestChart()) {
return true;
}
}
return false;
}
} }

2
designer-base/src/main/java/com/fr/design/mainframe/widget/BasicPropertyPane.java

@ -63,7 +63,7 @@ public class BasicPropertyPane extends BasicPane {
double[] columnSize = {p, f}; double[] columnSize = {p, f};
int[][] rowCount = {{1, 1}}; int[][] rowCount = {{1, 1}};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Name")), widgetName}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Name")), widgetName},
}; };
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1); JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_W1, IntervalConstants.INTERVAL_L1);
panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); panel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));

8
designer-base/src/main/java/com/fr/design/widget/WidgetBoundsPaneFactory.java

@ -25,7 +25,7 @@ public class WidgetBoundsPaneFactory {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)}, new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)},
new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))},
}; };
double[] rowSize = {p, p}; double[] rowSize = {p, p};
@ -53,11 +53,11 @@ public class WidgetBoundsPaneFactory {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
Component[][] northComponents = new Component[][]{ Component[][] northComponents = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Position")), createRightPane(x, y)}, new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Position")), createRightPane(x, y)},
new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))}, new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_X_Coordinate"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Y_Coordinate"), SwingConstants.CENTER))},
}; };
Component[][] centerComponents = new Component[][]{ Component[][] centerComponents = new Component[][]{
new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), createRightPane(width, height)}, new Component[]{FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), createRightPane(width, height)},
new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))}, new Component[]{null, createRightPane(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Width"), SwingConstants.CENTER), new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tree_Height"), SwingConstants.CENTER))},
}; };
double[] rowSize = {p, p}; double[] rowSize = {p, p};
@ -79,7 +79,7 @@ public class WidgetBoundsPaneFactory {
double f = TableLayout.FILL; double f = TableLayout.FILL;
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Size")), width}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Component_Size")), width},
}; };
double[] rowSize = {p}; double[] rowSize = {p};
double[] columnSize = {p, f}; double[] columnSize = {p, f};

131
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoCollectorTest.java

@ -1,14 +1,18 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.general.GeneralUtils; import com.fr.design.DesignerEnvManager;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.json.JSON;
import com.fr.json.JSONArray;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FileUtils; import com.fr.third.org.apache.commons.io.FileUtils;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -29,7 +33,7 @@ import static org.junit.Assert.assertTrue;
* Created by plough on 2019/4/18. * Created by plough on 2019/4/18.
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({ProductConstants.class, MarketConfig.class, ProductConstants.class, GeneralUtils.class}) @PrepareForTest({ProductConstants.class, MarketConfig.class, DesignerEnvManager.class})
public class TemplateInfoCollectorTest { public class TemplateInfoCollectorTest {
private String filePath; private String filePath;
private String initialFileContent; private String initialFileContent;
@ -51,6 +55,9 @@ public class TemplateInfoCollectorTest {
EasyMock.expect(mockProcessInfo.getFloatCount()).andReturn(1).anyTimes(); EasyMock.expect(mockProcessInfo.getFloatCount()).andReturn(1).anyTimes();
EasyMock.expect(mockProcessInfo.getReportType()).andReturn(0).anyTimes(); EasyMock.expect(mockProcessInfo.getReportType()).andReturn(0).anyTimes();
EasyMock.expect(mockProcessInfo.getWidgetCount()).andReturn(0).anyTimes(); EasyMock.expect(mockProcessInfo.getWidgetCount()).andReturn(0).anyTimes();
EasyMock.expect(mockProcessInfo.useParaPane()).andReturn(false).anyTimes();
EasyMock.expect(mockProcessInfo.getComponentsInfo()).andReturn(new JSONArray()).anyTimes();
EasyMock.expect(mockProcessInfo.isTestTemplate()).andReturn(true).anyTimes();
EasyMock.replay(mockProcessInfo); EasyMock.replay(mockProcessInfo);
// 缓存 tpl.info // 缓存 tpl.info
@ -72,36 +79,36 @@ public class TemplateInfoCollectorTest {
assertEquals(",,", DesignerOpenHistory.getInstance().toString()); assertEquals(",,", DesignerOpenHistory.getInstance().toString());
TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
assertEquals(7, ((Map) Reflect.on(collector).field("pointInfoMap").get()).size());
assertEquals("2019-04-08,2019-04-03,2019-03-29", DesignerOpenHistory.getInstance().toString()); assertEquals("2020-05-07,2020-05-06,2020-04-30", DesignerOpenHistory.getInstance().toString());
} }
@Test @Test
public void testCollectInfo() { public void testCollectInfo() throws Exception {
setUpMockForNewInstance();
TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "16a988ce-8529-42f5-b17c-2ee849355071"; String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
int timeConsume = 200; int timeConsume = 200;
collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume); collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume);
// 检查是否写入成功 // 检查是否写入成功
Reflect.on(collector).call("loadFromFile"); Reflect.on(collector).call("loadFromFile");
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Map processMap = Reflect.on(templateInfo).field("processMap").get(); Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString()); "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}",
JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\"," +
"\"jar_time\":\"不是安装版本\",\"create_time\":\"2019-03-26 16:13\"," + Assert.assertEquals(71113, consumingMap.get("uid"));
"\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," + Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":329,\"originTime\":0," + Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
"\"version\":\"10.0\",\"username\":\"plough\"}", new JSONObject(consumingMap).toString()); Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
} }
@Test @Test
@ -110,7 +117,7 @@ public class TemplateInfoCollectorTest {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "73a97777-8jnk-47cd-b57c-2ee89991279796"; String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
int timeConsume = 200; int timeConsume = 200;
collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume); collector.collectInfo(templateID, StringUtils.EMPTY, mockProcessInfo, timeConsume);
@ -119,20 +126,20 @@ public class TemplateInfoCollectorTest {
Reflect.on(collector).call("loadFromFile"); Reflect.on(collector).call("loadFromFile");
assertTrue(collector.contains(templateID)); assertTrue(collector.contains(templateID));
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get(); Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(templateID, templateInfo.getTemplateID());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," + "\"cell_count\":13,\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"73a97777-8jnk-47cd-b57c-2ee89991279796\"}", new JSONObject(processMap).toString()); "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID")); Assert.assertEquals(71113, consumingMap.get("uid"));
assertEquals(StringUtils.EMPTY, consumingMap.get("originID")); Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
assertEquals(200, consumingMap.get("time_consume")); Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
assertEquals(0, consumingMap.get("originTime")); Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
} }
@Test @Test
@ -141,7 +148,7 @@ public class TemplateInfoCollectorTest {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3"; String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
String originID = "16a988ce-8529-42f5-b17c-2ee849355071"; String originID = "16a988ce-8529-42f5-b17c-2ee849355071";
int timeConsume = 200; int timeConsume = 200;
@ -149,18 +156,19 @@ public class TemplateInfoCollectorTest {
// 检查是否写入成功 // 检查是否写入成功
Reflect.on(collector).call("loadFromFile"); Reflect.on(collector).call("loadFromFile");
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); TemplateInfo templateInfo = getTemplateInfoByID(templateID);
Map processMap = Reflect.on(templateInfo).field("processMap").get(); Map processMap = Reflect.on(templateInfo).field("processMap").get();
assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":1,\"widget_count\":0,\"cell_count\":13," +
"\"cell_count\":13,\"block_count\":3,\"report_type\":0," + "\"paraApply\":0,\"block_count\":3,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"423238d4-5223-22vj-vlsj-42jc49245iw3\"}", new JSONObject(processMap).toString()); "\"templateID\":\"e5d7dbb2-d1df-43d4-b974-67acb5ecbffa\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID")); Assert.assertEquals(71113, consumingMap.get("uid"));
assertEquals(originID, consumingMap.get("originID")); Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
assertEquals(329, consumingMap.get("time_consume")); Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
assertEquals(129, consumingMap.get("originTime")); Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
Assert.assertEquals("16a988ce-8529-42f5-b17c-2ee849355071", consumingMap.get("originID"));
} }
@Test @Test
@ -169,36 +177,71 @@ public class TemplateInfoCollectorTest {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance(); TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "423238d4-5223-22vj-vlsj-42jc49245iw3"; String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
String originID = "3kha8jcs-31xw-42f5-h2ww-2ee84935312z"; String originID = "3kha8jcs-31xw-42f5-h2ww-2ee84935312z";
int timeConsume = 200; int timeConsume = 200;
collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume); collector.collectInfo(templateID, originID, mockProcessInfo, timeConsume);
TemplateInfo templateInfo = collector.getOrCreateTemplateInfoByID(templateID); TemplateInfo templateInfo = getTemplateInfoByID(templateID);
assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(originID, templateInfo.getOriginID());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID")); Assert.assertEquals(71113, consumingMap.get("uid"));
assertEquals(originID, consumingMap.get("originID")); Assert.assertEquals("2020-05-07 17:25", consumingMap.get("create_time"));
assertEquals(200, consumingMap.get("time_consume")); Assert.assertEquals("e5d7dbb2-d1df-43d4-b974-67acb5ecbffa", consumingMap.get("templateID"));
assertEquals(0, consumingMap.get("originTime")); Assert.assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
Assert.assertEquals("3kha8jcs-31xw-42f5-h2ww-2ee84935312z", consumingMap.get("originID"));
} }
@Test @Test
public void testAddIdleDateCount() { public void testAddIdleDateCount() {
String templateID = "16a988ce-8529-42f5-b17c-2ee849355071"; String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
TemplateInfoCollector collecter = TemplateInfoCollector.getInstance(); TemplateInfoCollector collecter = TemplateInfoCollector.getInstance();
TemplateInfo templateInfo = collecter.getOrCreateTemplateInfoByID(templateID); TemplateInfo templateInfo = getTemplateInfoByID(templateID);
assertEquals(9, templateInfo.getIdleDayCount()); assertEquals(0, templateInfo.getIdleDayCount());
Reflect.on(collecter).call("addIdleDayCount"); Reflect.on(collecter).call("addIdleDayCount");
assertEquals(10, templateInfo.getIdleDayCount()); assertEquals(1, templateInfo.getIdleDayCount());
// 同一天内多次调用无效 // 同一天内多次调用无效
Reflect.on(collecter).call("addIdleDayCount"); Reflect.on(collecter).call("addIdleDayCount");
assertEquals(10, templateInfo.getIdleDayCount()); assertEquals(1, templateInfo.getIdleDayCount());
}
@Test
public void testContains() {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID1 = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
Assert.assertTrue(collector.contains(templateID1));
String templateID2 = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffb";
Assert.assertFalse(collector.contains(templateID2));
}
@Test
public void testGetTemplateCreateTime() throws Exception {
setUpMockForNewInstance();
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
String templateID = "e5d7dbb2-d1df-43d4-b974-67acb5ecbffa";
String createTime = Reflect.on(collector).call("getTemplateCreateTime", templateID).get();
Assert.assertEquals("2020-05-07 17:25", createTime);
templateID = "2521d03c-b238-41a5-9a1d-2498efff3a97";
createTime = Reflect.on(collector).call("getTemplateCreateTime", templateID).get();
Assert.assertEquals("2020-05-07 17:45", createTime);
}
private TemplateInfo getTemplateInfoByID(String templateID) {
TemplateInfoCollector collector = TemplateInfoCollector.getInstance();
Map<String, Long> latestTemplateInfo = Reflect.on(collector).field("latestTemplateInfo").get();
Map<String, TemplateInfo> pointInfoMap = Reflect.on(collector).field("pointInfoMap").get();
if (latestTemplateInfo.containsKey(templateID)) {
long latestSaveTime = latestTemplateInfo.get(templateID);
return pointInfoMap.get(templateID + "_" + latestSaveTime);
} else {
return TemplateInfo.newInstance(templateID);
}
} }
} }

90
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTest.java

@ -1,13 +1,15 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.general.GeneralUtils; import com.fr.design.DesignerEnvManager;
import com.fr.invoke.Reflect; import com.fr.invoke.Reflect;
import com.fr.json.JSON;
import com.fr.json.JSONFactory;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException; import com.fr.third.javax.xml.stream.XMLStreamException;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -25,17 +27,17 @@ import static org.junit.Assert.assertEquals;
* Created by plough on 2019/4/19. * Created by plough on 2019/4/19.
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({MarketConfig.class, ProductConstants.class, GeneralUtils.class}) @PrepareForTest({MarketConfig.class, DesignerEnvManager.class})
public class TemplateInfoTest { public class TemplateInfoTest {
private static final String NORMAL_INFO = "<TemplateInfo templateID=\"16a988ce-8529-42f5-b17c-2ee849355071\" day_count=\"9\">\n" + private static final String NORMAL_INFO = "<TemplateInfo templateID=\"aac1139e-018b-4481-867a-a18fc6d6f3e6\" day_count=\"0\" test_template=\"true\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"1\" block_count=\"0\" report_type=\"0\"/>\n" + "<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"3\" block_count=\"0\" report_type=\"0\" paraApply=\"0\" components_info=\"[]\"/>\n" +
"<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\"/>\n" + "<consumingMap create_time=\"2020-05-07 17:28\" uuid=\"6b6699ff-ec63-43b0-9deb-b580a5f10411\" uid=\"71113\" saveRecord=\"{&quot;time&quot;:1588843693000,&quot;consume&quot;:4}\"/>\n" +
"</TemplateInfo>"; "</TemplateInfo>";
private static final String SAVE_AS_INFO = "<TemplateInfo templateID=\"49avd2c4-1104-92j2-wx24-3dd0k2136080\" originID=\"16a988ce-8529-42f5-b17c-2ee849355071\" day_count=\"9\">\n" + private static final String SAVE_AS_INFO = "<TemplateInfo templateID=\"2521d03c-b238-41a5-9a1d-2498efff3a97\" originID=\"aac1139e-018b-4481-867a-a18fc6d6f3e6\" day_count=\"0\" test_template=\"true\">\n" +
"<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"1\" block_count=\"0\" report_type=\"0\"/>\n" + "<processMap process=\"\" float_count=\"0\" widget_count=\"0\" cell_count=\"3\" block_count=\"0\" report_type=\"0\" paraApply=\"0\" components_info=\"[]\"/>\n" +
"<consumingMap activitykey=\"2e0ea413-fa9c241e0-9723-4354fce51e81\" jar_time=\"不是安装版本\" create_time=\"2019-03-26 16:13\" uuid=\"476ca2cc-f789-4c5d-8e89-ef146580775c\" time_consume=\"429\" originTime=\"129\" version=\"10.0\" username=\"plough\"/>\n" + "<consumingMap create_time=\"2020-05-07 17:45\" uuid=\"6b6699ff-ec63-43b0-9deb-b580a5f10411\" uid=\"71113\" saveRecord=\"{&quot;time&quot;:1588844751000,&quot;consume&quot;:1058}\"/>\n" +
"</TemplateInfo>"; "</TemplateInfo>";
private TemplateInfo templateInfo; private TemplateInfo templateInfo;
@ -56,15 +58,14 @@ public class TemplateInfoTest {
assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(StringUtils.EMPTY, Reflect.on(templateInfo).field("originID").get()); assertEquals(StringUtils.EMPTY, Reflect.on(templateInfo).field("originID").get());
assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get()); assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get());
assertEquals(false, templateInfo.isTestTemplate());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID")); assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(0, consumingMap.get("originTime"));
assertEquals(StringUtils.EMPTY, consumingMap.get("originID")); assertEquals(StringUtils.EMPTY, consumingMap.get("originID"));
assertEquals(0, consumingMap.get("time_consume")); assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
assertEquals("不是安装版本", consumingMap.get("jar_time")); assertEquals(71113, consumingMap.get("uid"));
assertEquals("plough", consumingMap.get("username")); assertEquals(StringUtils.EMPTY, consumingMap.get("saveRecord"));
assertEquals("10.0", consumingMap.get("version"));
} }
@Test @Test
@ -73,26 +74,27 @@ public class TemplateInfoTest {
String templateID = "24121212-u2c8-ncd2-82nx-8ud0i8138888"; String templateID = "24121212-u2c8-ncd2-82nx-8ud0i8138888";
String originID = "24avc8n2-1iq8-iuj2-wx24-8yy0i8132302"; String originID = "24avc8n2-1iq8-iuj2-wx24-8yy0i8132302";
int originTime = 100; String saveRecord = "{\"time\";:1588843629000,\"consume\":81}";
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID, originID, originTime); String createTime = "2020-05-07 17:25";
TemplateInfo templateInfo = TemplateInfo.newInstance(templateID, originID, saveRecord, createTime);
assertEquals(templateID, templateInfo.getTemplateID()); assertEquals(templateID, templateInfo.getTemplateID());
assertEquals(originID, Reflect.on(templateInfo).field("originID").get()); assertEquals(originID, Reflect.on(templateInfo).field("originID").get());
assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get()); assertEquals(0, (int) Reflect.on(templateInfo).field("idleDayCount").get());
assertEquals(false, templateInfo.isTestTemplate());
Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get(); Map<String, Object> consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
assertEquals(templateID, consumingMap.get("templateID")); assertEquals(templateID, consumingMap.get("templateID"));
assertEquals(originTime, consumingMap.get("originTime"));
assertEquals(originID, consumingMap.get("originID")); assertEquals(originID, consumingMap.get("originID"));
assertEquals(originTime, consumingMap.get("time_consume")); assertEquals("6b6699ff-ec63-43b0-9deb-b580a5f10411", consumingMap.get("uuid"));
assertEquals("不是安装版本", consumingMap.get("jar_time")); assertEquals(71113, consumingMap.get("uid"));
assertEquals("plough", consumingMap.get("username")); assertEquals(saveRecord, consumingMap.get("saveRecord"));
assertEquals("10.0", consumingMap.get("version")); assertEquals(createTime, consumingMap.get("create_time"));
} }
@Test @Test
public void testGetTemplateID() { public void testGetTemplateID() {
assertEquals("16a988ce-8529-42f5-b17c-2ee849355071", templateInfo.getTemplateID()); assertEquals("aac1139e-018b-4481-867a-a18fc6d6f3e6", templateInfo.getTemplateID());
assertEquals("49avd2c4-1104-92j2-wx24-3dd0k2136080", templateInfoSaveAs.getTemplateID()); assertEquals("2521d03c-b238-41a5-9a1d-2498efff3a97", templateInfoSaveAs.getTemplateID());
} }
@Test @Test
@ -102,19 +104,21 @@ public class TemplateInfoTest {
Map processMap = Reflect.on(templateInfo).field("processMap").get(); Map processMap = Reflect.on(templateInfo).field("processMap").get();
Map consumingMap1 = Reflect.on(templateInfoSaveAs).field("consumingMap").get(); Map consumingMap1 = Reflect.on(templateInfoSaveAs).field("consumingMap").get();
Map processMap1 = Reflect.on(templateInfoSaveAs).field("processMap").get(); Map processMap1 = Reflect.on(templateInfoSaveAs).field("processMap").get();
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," + assertJsonStringEquals("{\"uid\":71113,\"originID\":\"\",\"create_time\":\"2020-05-07 17:28\"," +
"\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\",\"originID\":\"\"," + "\"saveRecord\":\"{\\\"time\\\":1588843693000,\\\"consume\\\":4}\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":129,\"originTime\":0,\"version\":\"10.0\"," + "\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," +
"\"username\":\"plough\"}", new JSONObject(consumingMap).toString()); "\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap).toString());
assertJsonStringEquals("{\"activitykey\":\"2e0ea413-fa9c241e0-9723-4354fce51e81\",\"jar_time\":\"不是安装版本\"," + assertJsonStringEquals("{\"uid\":71113,\"originID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"," +
"\"create_time\":\"2019-03-26 16:13\",\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\",\"originID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"," + "\"create_time\":\"2020-05-07 17:45\",\"saveRecord\":\"{\\\"time\\\":1588844751000,\\\"consume\\\":1058}\"," +
"\"uuid\":\"476ca2cc-f789-4c5d-8e89-ef146580775c\",\"time_consume\":429,\"originTime\":129,\"version\":\"10.0\"," + "\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"," +
"\"username\":\"plough\"}", new JSONObject(consumingMap1).toString()); "\"uuid\":\"6b6699ff-ec63-43b0-9deb-b580a5f10411\"}", JSONFactory.createJSON(JSON.OBJECT, consumingMap1).toString());
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," + assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," +
"\"block_count\":0,\"report_type\":0,\"templateID\":\"16a988ce-8529-42f5-b17c-2ee849355071\"}", new JSONObject(processMap).toString()); "\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," +
assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":1," + "\"templateID\":\"aac1139e-018b-4481-867a-a18fc6d6f3e6\"}", JSONFactory.createJSON(JSON.OBJECT, processMap).toString());
"\"block_count\":0,\"report_type\":0,\"templateID\":\"49avd2c4-1104-92j2-wx24-3dd0k2136080\"}", new JSONObject(processMap1).toString()); assertJsonStringEquals("{\"process\":\"\",\"float_count\":0,\"widget_count\":0,\"cell_count\":3," +
"\"paraApply\":0,\"block_count\":0,\"report_type\":0,\"components_info\":\"[]\"," +
"\"templateID\":\"2521d03c-b238-41a5-9a1d-2498efff3a97\"}", JSONFactory.createJSON(JSON.OBJECT, processMap1).toString());
} }
private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException { private TemplateInfo createTemplateInfo(String xmlContent) throws XMLStreamException {
@ -122,4 +126,18 @@ public class TemplateInfoTest {
XMLableReader xmlReader = XMLableReader.createXMLableReader(sr); XMLableReader xmlReader = XMLableReader.createXMLableReader(sr);
return TemplateInfo.newInstanceByRead(xmlReader); return TemplateInfo.newInstanceByRead(xmlReader);
} }
@Test
public void testGetSaveTime() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
String saveRecord = (String) consumingMap.get("saveRecord");
JSONObject object = JSONFactory.createJSON(JSON.OBJECT, saveRecord);
Assert.assertEquals(1588843693000L, object.optLong("time"));
}
@Test
public void testGetTemplateCreateTime() {
Map consumingMap = Reflect.on(templateInfo).field("consumingMap").get();
Assert.assertEquals("2020-05-07 17:28", (String) consumingMap.get("create_time"));
}
} }

18
designer-base/src/test/java/com/fr/design/mainframe/template/info/TemplateInfoTestHelper.java

@ -1,10 +1,10 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.config.BBSAttr;
import com.fr.config.MarketConfig; import com.fr.config.MarketConfig;
import com.fr.design.DesignerEnvManager;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.GeneralUtils;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.stable.ProductConstants;
import org.easymock.EasyMock; import org.easymock.EasyMock;
import org.powermock.api.easymock.PowerMock; import org.powermock.api.easymock.PowerMock;
@ -33,17 +33,21 @@ class TemplateInfoTestHelper {
static void setUpMockForNewInstance() throws Exception { static void setUpMockForNewInstance() throws Exception {
MarketConfig mockMarketConfig = EasyMock.mock(MarketConfig.class); MarketConfig mockMarketConfig = EasyMock.mock(MarketConfig.class);
EasyMock.expect(mockMarketConfig.getBbsUsername()).andReturn("plough").anyTimes(); BBSAttr bbsAttr = EasyMock.mock(BBSAttr.class);
EasyMock.expect(bbsAttr.getBbsUid()).andReturn(71113).anyTimes();
EasyMock.expect(mockMarketConfig.getBBSAttr()).andReturn(bbsAttr).anyTimes();
PowerMock.mockStatic(MarketConfig.class); PowerMock.mockStatic(MarketConfig.class);
EasyMock.expect(MarketConfig.getInstance()).andReturn(mockMarketConfig).anyTimes(); EasyMock.expect(MarketConfig.getInstance()).andReturn(mockMarketConfig).anyTimes();
PowerMock.mockStatic(GeneralUtils.class); PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(GeneralUtils.readBuildNO()).andReturn("不是安装版本").anyTimes(); DesignerEnvManager envManager = EasyMock.mock( DesignerEnvManager.class);
EasyMock.expect(envManager.getUUID()).andReturn("6b6699ff-ec63-43b0-9deb-b580a5f10411").anyTimes();
EasyMock.expect(envManager.isJoinProductImprove()).andReturn(true).anyTimes();
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(envManager).anyTimes();
EasyMock.replay(mockMarketConfig, bbsAttr, envManager);
setFinalStatic(ProductConstants.class.getDeclaredField("VERSION"), "10.0");
EasyMock.replay(mockMarketConfig);
PowerMock.replayAll(); PowerMock.replayAll();
} }
} }

44
designer-base/src/test/resources/com/fr/design/mainframe/template/info/tpl.info

@ -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="[{&quot;componentID&quot;:&quot;60e291c2-be60-4908-83ef-08b4a79d5f03&quot;,&quot;componentName&quot;:&quot;button1&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843627801,&quot;deleteTime&quot;:0},{&quot;componentID&quot;:&quot;fcf77ee3-05f0-4219-8fd2-d2a9ec95477e&quot;,&quot;componentName&quot;:&quot;button0&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843624940,&quot;deleteTime&quot;: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="{&quot;time&quot;:1588843629000,&quot;consume&quot;: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="{&quot;time&quot;:1588844751000,&quot;consume&quot;: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="[{&quot;componentID&quot;:&quot;e28e24af-a01a-42cd-aa06-e14dd7990621&quot;,&quot;componentName&quot;:&quot;button1&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843526090,&quot;deleteTime&quot;:0},{&quot;componentID&quot;:&quot;0e7ce6df-f19b-40a9-a4d9-d47bdc097e31&quot;,&quot;componentName&quot;:&quot;button0&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:1588843525059,&quot;deleteTime&quot;: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="{&quot;time&quot;:1588843530000,&quot;consume&quot;: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="{&quot;time&quot;:1588843693000,&quot;consume&quot;: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="[{&quot;componentID&quot;:&quot;60e291c2-be60-4908-83ef-08b4a79d5f03&quot;,&quot;componentName&quot;:&quot;button1&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:0,&quot;deleteTime&quot;: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="{&quot;time&quot;:1588843631000,&quot;consume&quot;: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="[{&quot;componentID&quot;:&quot;fcf77ee3-05f0-4219-8fd2-d2a9ec95477e&quot;,&quot;componentName&quot;:&quot;button0&quot;,&quot;componentType&quot;:&quot;Widget&quot;,&quot;createTime&quot;:0,&quot;deleteTime&quot;: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="{&quot;time&quot;:1588843642000,&quot;consume&quot;: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="{&quot;time&quot;:1588843548000,&quot;consume&quot;:17}"/>
</TemplateInfo> </TemplateInfo>
</TemplateInfoList> </TemplateInfoList>
</TplInfo> </TplInfo>

23
designer-chart/src/main/java/com/fr/van/chart/designer/component/marker/VanChartCommonMarkerPane.java

@ -1,12 +1,13 @@
package com.fr.van.chart.designer.component.marker; package com.fr.van.chart.designer.component.marker;
import com.fr.chart.chartglyph.Marker; import com.fr.chart.chartglyph.Marker;
import com.fr.design.i18n.Toolkit;
import com.fr.design.beans.BasicBeanPane; import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.xcombox.MarkerComboBox; import com.fr.design.gui.xcombox.MarkerComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.plugin.chart.base.VanChartAttrMarker; import com.fr.plugin.chart.base.VanChartAttrMarker;
import com.fr.plugin.chart.marker.type.MarkerType; import com.fr.plugin.chart.marker.type.MarkerType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
@ -102,6 +103,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
MarkerType.MARKER_STAR MarkerType.MARKER_STAR
}; };
private static Marker[] ganttMarkers = null; private static Marker[] ganttMarkers = null;
protected static Marker[] getGanttMarkers() { protected static Marker[] getGanttMarkers() {
if (ganttMarkers == null) { if (ganttMarkers == null) {
ganttMarkers = new Marker[GANTT_TYPES.length]; ganttMarkers = new Marker[GANTT_TYPES.length];
@ -124,10 +126,22 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
public VanChartCommonMarkerPane() { public VanChartCommonMarkerPane() {
markerTypeComboBox = new MarkerComboBox(getMarkers()); markerTypeComboBox = new MarkerComboBox(getMarkers());
markerFillColor = new VanChartMarkerBackgroundPane() { markerFillColor = new VanChartMarkerBackgroundPane() {
protected JPanel initContentPanel() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double e = getColumnSize()[1];
double[] columnSize = {f, e};
double[] rowSize = {p, p, p};
return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize);
}
protected Component[][] getPaneComponents() { protected Component[][] getPaneComponents() {
return new Component[][]{ return new Component[][]{
new Component[]{typeComboBox, null}, new Component[]{null, null},
new Component[]{centerPane, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), typeComboBox},
new Component[]{null, centerPane},
}; };
} }
}; };
@ -161,7 +175,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
protected Component[][] getMarkerConfigComponent() { protected Component[][] getMarkerConfigComponent() {
return new Component[][]{ return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Fill_Color")), markerFillColor}, new Component[]{markerFillColor, null},
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), radius} new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Radius")), radius}
}; };
} }
@ -217,6 +231,7 @@ public class VanChartCommonMarkerPane extends BasicBeanPane<VanChartAttrMarker>
protected MarkerType populateMarkType(VanChartAttrMarker marker) { protected MarkerType populateMarkType(VanChartAttrMarker marker) {
return marker.getMarkerType(); return marker.getMarkerType();
} }
/** /**
* Update. * Update.
*/ */

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/cuvette.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 574 B

After

Width:  |  Height:  |  Size: 739 B

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_180.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/pointer_360.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/ring.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/cuvette.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 771 B

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_180.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/pointer_360.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/ring.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/selected/slot.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
designer-chart/src/main/resources/com/fr/van/chart/custom/images/custom/icon/slot.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

4
designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java

@ -10,6 +10,7 @@ import com.fr.design.designer.creator.*;
import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout;
import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelection;
@ -261,8 +262,11 @@ public class SelectionModel {
creator.removeAll(); creator.removeAll();
// 清除被选中的组件 // 清除被选中的组件
selection.reset(); selection.reset();
FormDesignerUtils.removeWidgetProcessInfo(creator.toData());
} }
setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent()); setSelectedCreator(isInPara ? designer.getParaComponent() : designer.getRootComponent());
// 触发事件 // 触发事件
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED);

2
designer-form/src/main/java/com/fr/design/designer/creator/XWBorderLayout.java

@ -77,7 +77,7 @@ public class XWBorderLayout extends XLayoutContainer {
@Override @Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[] { return new CRPropertyDescriptor[] {
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")), new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Basic_Component_Name")),
new CRPropertyDescriptor("customTitleName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Title")) new CRPropertyDescriptor("customTitleName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Title"))
}; };
} }

17
designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java

@ -1,8 +1,14 @@
package com.fr.design.form.util; package com.fr.design.form.util;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.template.info.ComponentCreateOperate;
import com.fr.design.mainframe.template.info.ComponentDeleteOperate;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
public class FormDesignerUtils { public class FormDesignerUtils {
/** /**
* body布局是否设置了手机重布局 * body布局是否设置了手机重布局
@ -25,4 +31,15 @@ public class FormDesignerUtils {
return root.getBodyLayoutType() == com.fr.form.ui.container.WBodyLayoutType.ABSOLUTE; return root.getBodyLayoutType() == com.fr.form.ui.container.WBodyLayoutType.ABSOLUTE;
} }
public static void addWidgetProcessInfo(Widget widget) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jTemplate.getProcessInfo().updateTemplateOperationInfo(new ComponentCreateOperate(widget));
}
public static void removeWidgetProcessInfo(Widget widget) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jTemplate.getProcessInfo().updateTemplateOperationInfo(new ComponentDeleteOperate(widget));
}
} }

2
designer-form/src/main/java/com/fr/design/form/util/XCreatorConstants.java

@ -19,7 +19,7 @@ public class XCreatorConstants {
public static final String WIDGETNAME = "widgetName"; public static final String WIDGETNAME = "widgetName";
// 描述属性的分类 // 描述属性的分类
public static final String PROPERTY_CATEGORY = "category"; public static final String PROPERTY_CATEGORY = "category";
public static final String DEFAULT_GROUP_NAME = "Fine-Design_Basic_Form_Basic_Properties"; public static final String DEFAULT_GROUP_NAME = "Fine-Design_Report_Basic";
public static final String PROPERTY_VALIDATE = "Fine-Design_Basic_Validate"; public static final String PROPERTY_VALIDATE = "Fine-Design_Basic_Validate";
public static final Color FORM_BG = new Color(255, 255, 255); public static final Color FORM_BG = new Color(255, 255, 255);
// 拖拽标识块的大小 // 拖拽标识块的大小

3
designer-form/src/main/java/com/fr/design/mainframe/JForm.java

@ -135,6 +135,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
startListenPlugin(); startListenPlugin();
} }
public JForm(Form form, FILE file) { public JForm(Form form, FILE file) {
super(form, file); super(form, file);
@ -206,12 +207,14 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} }
public TemplateProcessInfo<Form> getProcessInfo() { public TemplateProcessInfo<Form> getProcessInfo() {
//这边需要判空,图表的埋点信息收集时可能没有初始化processInfo
if (processInfo == null) { if (processInfo == null) {
processInfo = new JFormProcessInfo(template); processInfo = new JFormProcessInfo(template);
} }
return processInfo; return processInfo;
} }
public FormECCompositeProvider getReportComposite() { public FormECCompositeProvider getReportComposite() {
return this.reportComposite; return this.reportComposite;
} }

6
designer-form/src/main/java/com/fr/design/mainframe/ToolBarButton.java

@ -2,6 +2,8 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.core.WidgetOption;
import com.fr.design.designer.creator.XCreatorUtils; import com.fr.design.designer.creator.XCreatorUtils;
@ -91,7 +93,9 @@ public class ToolBarButton extends UIButton implements MouseListener, MouseMotio
creatorSource = no.getNameOption().createWidget(); creatorSource = no.getNameOption().createWidget();
} }
if (creatorSource != null) { if (creatorSource != null) {
WidgetToolBarPane.getTarget().startDraggingBean(XCreatorUtils.createXCreator(creatorSource)); XCreator xCreator = XCreatorUtils.createXCreator(creatorSource);
WidgetToolBarPane.getTarget().startDraggingBean(xCreator);
FormDesignerUtils.addWidgetProcessInfo(xCreator.toData());
lastPressEvent = null; lastPressEvent = null;
this.setBorder(null); this.setBorder(null);
} }

36
designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentCreateOperate.java

@ -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;
}
}

29
designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentDeleteOperate.java

@ -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;
}
}

80
designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java

@ -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;
}
}
}

161
designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java

@ -1,12 +1,37 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.form.FormElementCaseProvider;
import com.fr.form.main.Form; import com.fr.form.main.Form;
import com.fr.form.main.WidgetGather;
import com.fr.form.ui.BaseChartEditor;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ElementCaseEditorProvider;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
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;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* Created by plough on 2017/3/17. * Created by plough on 2017/3/17.
*/ */
public class JFormProcessInfo extends TemplateProcessInfo<Form> { public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private static final String REGEX = "^" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Title") + "\\d+$";
private static final Pattern PATTERN = Pattern.compile(REGEX);
private Map<String, JSONObject> componentProcessInfoMap = new ConcurrentHashMap<String, JSONObject>();
public JFormProcessInfo(Form form) { public JFormProcessInfo(Form form) {
super(form); super(form);
} }
@ -20,14 +45,17 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
public int getCellCount() { public int getCellCount() {
return 0; return 0;
} }
// 获取模板悬浮元素个数 // 获取模板悬浮元素个数
public int getFloatCount() { public int getFloatCount() {
return 0; return 0;
} }
// 获取模板聚合块个数 // 获取模板聚合块个数
public int getBlockCount() { public int getBlockCount() {
return 0; return 0;
} }
// 获取模板控件数 // 获取模板控件数
public int getWidgetCount() { public int getWidgetCount() {
int widgetCount = 0; int widgetCount = 0;
@ -37,4 +65,137 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
} }
return widgetCount; return widgetCount;
} }
@Override
public boolean isTestTemplate() {
Iterator<String> it = this.template.getTableDataNameIterator();
if (!it.hasNext() || getWidgetCount() <= 1 ||
hasEmptyParaPane() || hasTestAbsolutePane()
|| hasTestTabLayout() || hasTestECReport() || hasTestChart()) {
return true;
}
return false;
}
private boolean hasTestECReport() {
ElementCaseEditorProvider[] elementCaseEditorProviders = this.template.getElementCases();
for (ElementCaseEditorProvider elementCaseEditorProvider : elementCaseEditorProviders) {
FormElementCaseProvider elementCase = elementCaseEditorProvider.getElementCase();
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 true;
}
}
}
return false;
}
private boolean hasTestChart() {
final boolean[] hasTestChart = {false};
Form.traversalWidget(this.template.getContainer(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
ChartCollection chartCollection = (ChartCollection) ((BaseChartEditor) widget).getChartCollection();
if (isTestChartCollection(chartCollection)) {
hasTestChart[0] = true;
}
}
@Override
public boolean dealWithAllCards() {
return true;
}
}, BaseChartEditor.class);
return hasTestChart[0];
}
private boolean hasTestTabLayout() {
final boolean[] hasTestTabLayout = {false};
Form.traversalWidget(this.template.getContainer(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
String title = ((CardSwitchButton) widget).getText();
Matcher matcher = PATTERN.matcher(title);
if (matcher.find()) {
hasTestTabLayout[0] = true;
}
}
@Override
public boolean dealWithAllCards() {
return true;
}
}, CardSwitchButton.class);
return hasTestTabLayout[0];
}
private boolean hasTestAbsolutePane() {
final boolean[] hasTestAbsolutePane = {false};
Form.traversalWidget(this.template.getContainer(), new WidgetGather() {
@Override
public void dealWith(Widget widget) {
if (((WAbsoluteLayout) widget).getWidgetCount() == 0) {
hasTestAbsolutePane[0] = true;
}
}
@Override
public boolean dealWithAllCards() {
return true;
}
}, WAbsoluteLayout.class);
return hasTestAbsolutePane[0];
}
private boolean hasEmptyParaPane() {
WLayout paraContainer = this.template.getParaContainer();
return paraContainer != null && paraContainer.getWidgetCount() == 0;
}
@Override
public boolean useParaPane() {
return this.template.getParaContainer() != null;
}
@Override
public JSONArray getComponentsInfo() {
JSONArray ja = new JSONArray();
for (JSONObject value : componentProcessInfoMap.values()) {
ja.put(value);
}
this.componentProcessInfoMap.clear();
return ja;
}
@Override
public void updateTemplateOperationInfo(TemplateOperate templateOperate) {
if (ComparatorUtils.equals(ComponentCreateOperate.OPERATE_TYPE, templateOperate.getOperateType())) {
addComponentCreateInfo(templateOperate.toJSONObject());
}
if (ComparatorUtils.equals(ComponentDeleteOperate.OPERATE_TYPE, templateOperate.getOperateType())) {
addComponentRemoveInfo(templateOperate.toJSONObject());
}
}
private void addComponentCreateInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID");
componentProcessInfoMap.put(componentID, jsonObject);
}
private void addComponentRemoveInfo(JSONObject jsonObject) {
String componentID = jsonObject.getString("componentID");
JSONObject info = componentProcessInfoMap.get(componentID);
if (info == null) {
info = jsonObject;
componentProcessInfoMap.put(componentID, jsonObject);
}
info.put("deleteTime", System.currentTimeMillis());
}
} }

38
designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java

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

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

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

12
designer-realize/src/main/java/com/fr/design/mainframe/JPolyWorkBook.java

@ -3,6 +3,8 @@
*/ */
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.mainframe.template.info.JPolyWorkBookProcessInfo;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.file.FILEChooserPane; import com.fr.file.FILEChooserPane;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.poly.PolyWorkSheet; import com.fr.report.poly.PolyWorkSheet;
@ -49,4 +51,14 @@ public class JPolyWorkBook extends JWorkBook {
protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) { protected void addExtraChooseFILEFilter(FILEChooserPane fileChooser) {
} }
@Override
public TemplateProcessInfo<WorkBook> getProcessInfo() {
if (processInfo == null) {
processInfo = new JPolyWorkBookProcessInfo(template);
}
return processInfo;
}
} }

77
designer-realize/src/main/java/com/fr/design/mainframe/template/info/JPolyWorkBookProcessInfo.java

@ -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;
}
}

84
designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java

@ -1,10 +1,15 @@
package com.fr.design.mainframe.template.info; package com.fr.design.mainframe.template.info;
import com.fr.base.Style;
import com.fr.base.parameter.ParameterUI; import com.fr.base.parameter.ParameterUI;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.json.JSONArray;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr; import com.fr.main.parameter.ReportParameterAttr;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cellcase.CellCase; import com.fr.report.cellcase.CellCase;
import com.fr.report.poly.PolyWorkSheet; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.report.Report; import com.fr.report.report.Report;
import com.fr.report.worksheet.WorkSheet; import com.fr.report.worksheet.WorkSheet;
@ -42,6 +47,7 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
} }
return cellCount; return cellCount;
} }
// 获取模板悬浮元素个数 // 获取模板悬浮元素个数
public int getFloatCount() { public int getFloatCount() {
int chartCount = 0; int chartCount = 0;
@ -57,21 +63,12 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
} }
return chartCount; return chartCount;
} }
// 获取模板聚合块个数 // 获取模板聚合块个数
public int getBlockCount() { public int getBlockCount() {
int blockCount = 0; return 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;
} }
// 获取模板控件数 // 获取模板控件数
public int getWidgetCount() { public int getWidgetCount() {
ReportParameterAttr attr = template.getReportParameterAttr(); ReportParameterAttr attr = template.getReportParameterAttr();
@ -82,4 +79,65 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
ParameterUI pui = attr.getParameterUI(); ParameterUI pui = attr.getParameterUI();
return pui == null ? 0 : (pui.getAllWidgets().length - 1); return pui == null ? 0 : (pui.getAllWidgets().length - 1);
} }
@Override
public boolean isTestTemplate() {
Iterator<String> it = this.template.getTableDataNameIterator();
if (!it.hasNext() || isTestECReport() || getCellCount() <= 5) {
return true;
}
return false;
}
protected boolean isTestECReport() {
int count = this.template.getReportCount();
for (int m = 0; m < count; m++) {
Report report = this.template.getReport(m);
Iterator iterator = report.iteratorOfElementCase();
while (iterator.hasNext()) {
TemplateElementCase templateElementCase = (TemplateElementCase) iterator.next();
int columnLength = templateElementCase.getColumnCount();
int rowLength = templateElementCase.getRowCount();
for (int i = 0; i < columnLength; i++) {
for (int j = 0; j < rowLength; j++) {
TemplateCellElement templateCellElement = templateElementCase.getTemplateCellElement(i, j);
Object value = templateCellElement.getValue();
if (isTestCell(value, templateCellElement.getStyle())) {
return true;
}
}
}
}
}
return false;
}
protected boolean isTestCell(Object value, Style style) {
if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) {
return true;
}
return false;
}
@Override
public boolean useParaPane() {
ReportParameterAttr parameterAttr = this.template.getReportParameterAttr();
if (parameterAttr == null) {
return false;
}
return parameterAttr.getParameterUI() != null;
}
@Override
public JSONArray getComponentsInfo() {
return new JSONArray();
}
@Override
public void updateTemplateOperationInfo(TemplateOperate templateOption) {
}
} }

2
designer-realize/src/main/java/com/fr/design/report/UnitFieldPane.java

@ -67,7 +67,7 @@ public class UnitFieldPane extends JPanel {
this.unitType = unitType; this.unitType = unitType;
valueSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, 0.0, Double.MAX_VALUE, 1.0)); valueSpinner = new UIBasicSpinner(new SpinnerNumberModel(0.0, Integer.MIN_VALUE, Double.MAX_VALUE, 1.0));
textField = ((JSpinner.DefaultEditor) valueSpinner.getEditor()).getTextField(); textField = ((JSpinner.DefaultEditor) valueSpinner.getEditor()).getTextField();
textField.setColumns(OperatingSystem.isWindows() ? TEXT_FIELD_COLUMNS_WINDOWS : TEXT_FIELD_COLUMNS); textField.setColumns(OperatingSystem.isWindows() ? TEXT_FIELD_COLUMNS_WINDOWS : TEXT_FIELD_COLUMNS);
InputEventBaseOnOS.addBasicEditInputMap(textField); InputEventBaseOnOS.addBasicEditInputMap(textField);

49
designer-realize/src/test/java/com.fr/design/mainframe/template/info/JWorkBookProcessInfoTest.java

@ -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…
Cancel
Save