Browse Source

代码修改

feature/big-screen
kerry 5 years ago
parent
commit
c1c7e06f28
  1. 7
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  2. 20
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateOperate.java
  3. 6
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateProcessInfo.java
  4. 6
      designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java
  5. 17
      designer-form/src/main/java/com/fr/design/mainframe/JForm.java
  6. 36
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentCreateOperate.java
  7. 29
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentDeleteOperate.java
  8. 41
      designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java
  9. 33
      designer-form/src/main/java/com/fr/design/mainframe/template/info/JFormProcessInfo.java
  10. 15
      designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java
  11. 4
      designer-form/src/test/java/com/fr/design/mainframe/template/info/JFormProcessInfoTest.java
  12. 5
      designer-realize/src/main/java/com/fr/design/mainframe/template/info/JWorkBookProcessInfo.java

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

@ -38,6 +38,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.chart.info.ChartInfoCollector; import com.fr.design.mainframe.chart.info.ChartInfoCollector;
import com.fr.design.mainframe.template.info.TemplateInfoCollector; import com.fr.design.mainframe.template.info.TemplateInfoCollector;
import com.fr.design.mainframe.template.info.TemplateOperate;
import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.template.info.TimeConsumeTimer; import com.fr.design.mainframe.template.info.TimeConsumeTimer;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -1262,11 +1263,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
template.setTemplateID(templateId); template.setTemplateID(templateId);
} }
public void addWidgetProcessInfo(Widget widget) { public void updateTemplateOperationInfo(TemplateOperate operateInfo) {
}
public void removeWidgetProcessInfo(Widget widget) {
} }

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

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

@ -4,7 +4,6 @@ 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.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider; import com.fr.chartx.attr.ChartProvider;
import com.fr.form.ui.Widget;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
/** /**
@ -46,12 +45,9 @@ public abstract class TemplateProcessInfo<T extends BaseBook> {
//获取组件信息 //获取组件信息
public abstract JSONArray getComponentsInfo(); public abstract JSONArray getComponentsInfo();
public void addComponentCreateInfo(Widget widget) {
}
public void addComponentRemoveInfo(Widget widget) { public abstract void updateTemplateOperationInfo(TemplateOperate templateOption);
}
protected boolean isTestCell(Object value, Style style) { protected boolean isTestCell(Object value, Style style) {
if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) { if (value instanceof ChartCollection && isTestChartCollection((ChartCollection) value)) {

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

@ -3,6 +3,8 @@ package com.fr.design.form.util;
import com.fr.design.file.HistoryTemplateListCache; 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.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.Widget;
import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WFitLayout;
@ -32,12 +34,12 @@ public class FormDesignerUtils {
public static void addWidgetProcessInfo(Widget widget) { public static void addWidgetProcessInfo(Widget widget) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jTemplate.addWidgetProcessInfo(widget); jTemplate.updateTemplateOperationInfo(new ComponentCreateOperate(widget));
} }
public static void removeWidgetProcessInfo(Widget widget) { public static void removeWidgetProcessInfo(Widget widget) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
jTemplate.removeWidgetProcessInfo(widget); jTemplate.updateTemplateOperationInfo(new ComponentDeleteOperate(widget));
} }
} }

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

@ -45,6 +45,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECCompositeProvider;
import com.fr.design.mainframe.form.FormECDesignerProvider; import com.fr.design.mainframe.form.FormECDesignerProvider;
import com.fr.design.mainframe.template.info.JFormProcessInfo; import com.fr.design.mainframe.template.info.JFormProcessInfo;
import com.fr.design.mainframe.template.info.TemplateOperate;
import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.mainframe.toolbar.ToolBarMenuDock; import com.fr.design.mainframe.toolbar.ToolBarMenuDock;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
@ -105,7 +106,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID;
public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form> { public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<Form> {
private static final String FORM_CARD = "FORM"; private static final String FORM_CARD = "FORM";
@ -214,25 +214,14 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm<F
} }
public TemplateProcessInfo<Form> getProcessInfo() { public TemplateProcessInfo<Form> getProcessInfo() {
if (processInfo == null) {
processInfo = new JFormProcessInfo(template);
}
return processInfo; return processInfo;
} }
public void addWidgetProcessInfo(Widget widget) { public void updateTemplateOperationInfo(TemplateOperate operateInfo) {
if (processInfo == null) {
return;
}
widget.setWidgetID(UUID.randomUUID().toString());
processInfo.addComponentCreateInfo(widget);
}
public void removeWidgetProcessInfo(Widget widget) {
if (processInfo == null) { if (processInfo == null) {
return; return;
} }
processInfo.addComponentRemoveInfo(widget); processInfo.updateTemplateOperationInfo(operateInfo);
} }
public FormECCompositeProvider getReportComposite() { public FormECCompositeProvider getReportComposite() {

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

41
designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentProcessInfo.java → designer-form/src/main/java/com/fr/design/mainframe/template/info/ComponentOperate.java

@ -8,44 +8,29 @@ import com.fr.form.ui.container.WCardLayout;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
/** /**
* Created by kerry on 2020-05-07 * Created by kerry on 2020-05-08
*/ */
public class ComponentProcessInfo { public abstract class ComponentOperate implements TemplateOperate {
private static final String ATTR_COMPONENT_ID = "componentID"; private static final String ATTR_COMPONENT_ID = "componentID";
private static final String ATTR_COMPONENT_NAME = "componentName"; private static final String ATTR_COMPONENT_NAME = "componentName";
private static final String ATTR_COMPONENT_TYPE = "componentType"; private static final String ATTR_COMPONENT_TYPE = "componentType";
private static final String ATTR_CREATE_TIME = "createTime"; protected static final String ATTR_CREATE_TIME = "createTime";
private static final String ATTR_DELETE_TIME = "deleteTime"; protected static final String ATTR_DELETE_TIME = "deleteTime";
private String componentID;
private String componentName;
private String componentType;
private long createTime = 0L;
private long deleteTime = 0L;
private Widget widget;
public ComponentProcessInfo(Widget widget) { public ComponentOperate(Widget widget) {
this(widget, 0L); this.widget = widget;
} }
public ComponentProcessInfo(Widget widget, long createTime) { @Override
this.componentID = widget.getWidgetID();
this.componentName = widget.getWidgetName();
this.componentType = ComponentType.parseType(widget).name();
this.createTime = createTime;
}
public void updateDeleteTime(long deleteTime) {
this.deleteTime = deleteTime;
}
public JSONObject toJSONObject() { public JSONObject toJSONObject() {
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put(ATTR_COMPONENT_ID, componentID) jo.put(ATTR_COMPONENT_ID, widget.getWidgetID())
.put(ATTR_COMPONENT_NAME, componentName) .put(ATTR_COMPONENT_NAME, widget.getWidgetName())
.put(ATTR_COMPONENT_TYPE, componentType) .put(ATTR_COMPONENT_TYPE, ComponentType.parseType(widget).name())
.put(ATTR_CREATE_TIME, createTime) .put(ATTR_CREATE_TIME, 0L)
.put(ATTR_DELETE_TIME, deleteTime); .put(ATTR_DELETE_TIME, 0L);
return jo; return jo;
} }

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

@ -10,7 +10,9 @@ import com.fr.form.ui.ElementCaseEditorProvider;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WLayout; import com.fr.form.ui.container.WLayout;
import com.fr.general.ComparatorUtils;
import com.fr.json.JSONArray; import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.report.cell.DefaultTemplateCellElement; import com.fr.report.cell.DefaultTemplateCellElement;
import java.util.Iterator; import java.util.Iterator;
@ -28,7 +30,7 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
private static final Pattern PATTERN = Pattern.compile(REGEX); private static final Pattern PATTERN = Pattern.compile(REGEX);
private Map<String, ComponentProcessInfo> componentProcessInfoMap = new ConcurrentHashMap<String, ComponentProcessInfo>(); private Map<String, JSONObject> componentProcessInfoMap = new ConcurrentHashMap<String, JSONObject>();
public JFormProcessInfo(Form form) { public JFormProcessInfo(Form form) {
super(form); super(form);
@ -166,23 +168,34 @@ public class JFormProcessInfo extends TemplateProcessInfo<Form> {
@Override @Override
public JSONArray getComponentsInfo() { public JSONArray getComponentsInfo() {
JSONArray ja = new JSONArray(); JSONArray ja = new JSONArray();
for (ComponentProcessInfo value : componentProcessInfoMap.values()) { for (JSONObject value : componentProcessInfoMap.values()) {
ja.put(value.toJSONObject()); ja.put(value);
} }
this.componentProcessInfoMap.clear(); this.componentProcessInfoMap.clear();
return ja; return ja;
} }
public void addComponentCreateInfo(Widget widget) { @Override
componentProcessInfoMap.put(widget.getWidgetID(), new ComponentProcessInfo(widget, System.currentTimeMillis())); 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.optString("componentID");
componentProcessInfoMap.put(componentID, jsonObject);
} }
public void addComponentRemoveInfo(Widget widget) { private void addComponentRemoveInfo(JSONObject jsonObject) {
ComponentProcessInfo info = componentProcessInfoMap.get(widget.getWidgetID()); String componentID = jsonObject.optString("componentID");
JSONObject info = componentProcessInfoMap.get(componentID);
if (info == null) { if (info == null) {
info = new ComponentProcessInfo(widget); info = jsonObject;
componentProcessInfoMap.put(widget.getWidgetID(), info); componentProcessInfoMap.put(componentID, jsonObject);
} }
info.updateDeleteTime(System.currentTimeMillis()); info.put("deleteTime", System.currentTimeMillis());
} }
} }

15
designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentProcessInfoTest.java → designer-form/src/test/java/com/fr/design/mainframe/template/info/ComponentCreateOperateTest.java

@ -13,27 +13,26 @@ import org.junit.Test;
/** /**
* Created by kerry on 2020-05-08 * Created by kerry on 2020-05-08
*/ */
public class ComponentProcessInfoTest { public class ComponentCreateOperateTest {
@Test @Test
public void testToJSONObject() { public void testToJSONObject() {
Widget button = new FreeButton(); Widget button = new FreeButton();
button.setWidgetName("button1"); button.setWidgetName("button1");
ComponentCreateOperate info = new ComponentCreateOperate(button);
button.setWidgetID("xxxxxxx"); button.setWidgetID("xxxxxxx");
ComponentProcessInfo info = new ComponentProcessInfo(button);
JSONObject jo = info.toJSONObject(); JSONObject jo = info.toJSONObject();
Assert.assertEquals("xxxxxxx", jo.optString("componentID")); Assert.assertEquals("xxxxxxx", jo.optString("componentID"));
Assert.assertEquals("button1", jo.optString("componentName")); Assert.assertEquals("button1", jo.optString("componentName"));
Assert.assertEquals("Widget", jo.optString("componentType")); Assert.assertEquals("Widget", jo.optString("componentType"));
Assert.assertEquals("0", jo.optString("createTime"));
Assert.assertEquals("0", jo.optString("deleteTime")); Assert.assertEquals("0", jo.optString("deleteTime"));
} }
@Test @Test
public void testComponentType() { public void testComponentType() {
Assert.assertEquals(ComponentProcessInfo.ComponentType.Widget, ComponentProcessInfo.ComponentType.parseType(new FreeButton())); Assert.assertEquals(ComponentOperate.ComponentType.Widget, ComponentOperate.ComponentType.parseType(new FreeButton()));
Assert.assertEquals(ComponentProcessInfo.ComponentType.Report, ComponentProcessInfo.ComponentType.parseType(new ElementCaseEditor())); Assert.assertEquals(ComponentOperate.ComponentType.Report, ComponentOperate.ComponentType.parseType(new ElementCaseEditor()));
Assert.assertEquals(ComponentProcessInfo.ComponentType.Chart, ComponentProcessInfo.ComponentType.parseType(new ChartEditor())); Assert.assertEquals(ComponentOperate.ComponentType.Chart, ComponentOperate.ComponentType.parseType(new ChartEditor()));
Assert.assertEquals(ComponentProcessInfo.ComponentType.Absolute, ComponentProcessInfo.ComponentType.parseType(new WAbsoluteLayout())); Assert.assertEquals(ComponentOperate.ComponentType.Absolute, ComponentOperate.ComponentType.parseType(new WAbsoluteLayout()));
Assert.assertEquals(ComponentProcessInfo.ComponentType.TabLayout, ComponentProcessInfo.ComponentType.parseType(new WCardLayout())); Assert.assertEquals(ComponentOperate.ComponentType.TabLayout, ComponentOperate.ComponentType.parseType(new WCardLayout()));
} }
} }

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

@ -137,8 +137,8 @@ public class JFormProcessInfoTest {
FreeButton button2 = new FreeButton(); FreeButton button2 = new FreeButton();
button1.setWidgetID("xxxx1"); button1.setWidgetID("xxxx1");
button2.setWidgetID("xxxx2"); button2.setWidgetID("xxxx2");
jFormProcessInfo.addComponentCreateInfo(button1); Reflect.on(jFormProcessInfo).call("addComponentCreateInfo", new ComponentCreateOperate(button1).toJSONObject());
jFormProcessInfo.addComponentRemoveInfo(button2); Reflect.on(jFormProcessInfo).call("addComponentRemoveInfo", new ComponentDeleteOperate(button2).toJSONObject());
JSONArray ja = jFormProcessInfo.getComponentsInfo(); JSONArray ja = jFormProcessInfo.getComponentsInfo();
Assert.assertEquals(2, ja.size()); Assert.assertEquals(2, ja.size());

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

@ -135,4 +135,9 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo<WorkBook> {
public JSONArray getComponentsInfo() { public JSONArray getComponentsInfo() {
return new JSONArray(); return new JSONArray();
} }
@Override
public void updateTemplateOperationInfo(TemplateOperate templateOption) {
}
} }

Loading…
Cancel
Save