From f62f46b7b4779144d6eaf4b0ee6ba287db4322fa Mon Sep 17 00:00:00 2001 From: hades Date: Fri, 28 May 2021 18:57:19 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-51683=20=E3=80=9010.0.17=E3=80=91?= =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=81=94=E5=8A=A8=E8=A2=AB=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/mod/ContentChange.java | 29 +++++ .../fr/design/mod/ContentObjectManager.java | 62 +++++++++++ .../com/fr/design/mod/ContentReplacer.java | 13 +++ .../fr/design/mod/ContentReplacerCenter.java | 101 ++++++++++++++++++ .../com/fr/design/mod/bean/ChangeItem.java | 14 +++ .../fr/design/mod/bean/ContentChangeItem.java | 33 ++++++ .../com/fr/design/mod/event/ModifyEvent.java | 13 +++ .../mod/event/TableDataModifyEvent.java | 12 +++ .../mod/event/WidgetNameModifyEvent.java | 12 +++ ...ChartHyperRelateCellLinkContentChange.java | 16 +++ ...hartHyperRelateFloatLinkContentChange.java | 16 +++ .../ChartHyperRelateLinkContentChange.java | 30 ++++++ .../mod/impl/change/FormulaContentChange.java | 37 +++++++ .../impl/change/JavaScriptContentChange.java | 36 +++++++ ...rRelateLink4WidgetNameContentReplacer.java | 21 ++++ .../Formula4TableDataNameContentReplacer.java | 18 ++++ .../Formula4WidgetNameContentReplacer.java | 17 +++ .../repalce/JavaScriptContentReplacer.java | 25 +++++ .../designer/beans/models/ModelUtil.java | 9 ++ .../mainframe/FormCreatorDropTarget.java | 9 +- .../fr/start/module/DesignerActivator.java | 2 + 21 files changed, 524 insertions(+), 1 deletion(-) create mode 100644 designer-base/src/main/java/com/fr/design/mod/ContentChange.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/bean/ChangeItem.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/bean/ContentChangeItem.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/event/ModifyEvent.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/event/TableDataModifyEvent.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/event/WidgetNameModifyEvent.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateCellLinkContentChange.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateFloatLinkContentChange.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateLinkContentChange.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/change/FormulaContentChange.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/change/JavaScriptContentChange.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/repalce/ChartHyperRelateLink4WidgetNameContentReplacer.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java create mode 100644 designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java diff --git a/designer-base/src/main/java/com/fr/design/mod/ContentChange.java b/designer-base/src/main/java/com/fr/design/mod/ContentChange.java new file mode 100644 index 000000000..8361d8609 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/ContentChange.java @@ -0,0 +1,29 @@ +package com.fr.design.mod; + +import com.fr.design.mod.bean.ChangeItem; + +import java.util.Map; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/27 + */ +public interface ContentChange { + + /** + * 标识内容替换类型 + * + * @return + */ + String type(); + + /** + * 替换详情信息 + * + * @return + */ + Map> changeInfo(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java b/designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java new file mode 100644 index 000000000..a9bdd5115 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java @@ -0,0 +1,62 @@ +package com.fr.design.mod; + +import com.fr.base.Formula; +import com.fr.chart.web.ChartHyperRelateCellLink; +import com.fr.chart.web.ChartHyperRelateFloatLink; +import com.fr.design.file.filter.ClassFilter; +import com.fr.invoke.ClassHelper; +import com.fr.js.JavaScriptImpl; +import com.fr.stable.Filter; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * 管理所有需要替换内容的对象 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/4/28 + */ +public class ContentObjectManager { + + private static ContentObjectManager INSTANCE = new ContentObjectManager(); + + public static ContentObjectManager getInstance() { + return INSTANCE; + } + + /** + * 放置所有需要替换内容的对象 + */ + private Map> objectMap; + + private final Set set = new HashSet<>(); + + private ContentObjectManager() { + set.add(Formula.class.getName()); + set.add(JavaScriptImpl.class.getName()); + set.add(ChartHyperRelateCellLink.class.getName()); + set.add(ChartHyperRelateFloatLink.class.getName()); + } + + public void searchObject(Object ob) { + objectMap = ClassHelper.searchObject(ob, set, ClassFilter.getInstance()); + } + + public void searchObject(Object ob, Filter filter) { + objectMap = ClassHelper.searchObject(ob, set, filter); + } + + public void searchObject(Object ob, Set set, Filter filter) { + objectMap = ClassHelper.searchObject(ob, set, filter); + } + public void clearObject() { + objectMap = null; + } + + public Map> getObjectMap() { + return objectMap; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java b/designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java new file mode 100644 index 000000000..3f7126535 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java @@ -0,0 +1,13 @@ +package com.fr.design.mod; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/5/27 + */ +public interface ContentReplacer { + + void replace(T t, String oldName, String newName); + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java b/designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java new file mode 100644 index 000000000..5359d87e5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java @@ -0,0 +1,101 @@ +package com.fr.design.mod; + +import com.fr.design.mod.bean.ChangeItem; +import com.fr.design.mod.bean.ContentChangeItem; +import com.fr.design.mod.event.TableDataModifyEvent; +import com.fr.design.mod.event.WidgetNameModifyEvent; +import com.fr.design.mod.impl.change.ChartHyperRelateCellLinkContentChange; +import com.fr.design.mod.impl.change.ChartHyperRelateFloatLinkContentChange; +import com.fr.design.mod.impl.change.FormulaContentChange; +import com.fr.design.mod.impl.change.JavaScriptContentChange; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.log.FineLoggerFactory; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * 默认联动内容替换器实现 + * + * 当前替换顺序:组件名-> 数据集名 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/5/27 + */ +public class ContentReplacerCenter { + + private static final ContentReplacerCenter INSTANCE = new ContentReplacerCenter(); + + public static ContentReplacerCenter getInstance() { + return INSTANCE; + } + + private List contentChangeList = new ArrayList<>(); + private List items = new ArrayList<>(); + + private ContentReplacerCenter() { + + EventDispatcher.listen(WidgetNameModifyEvent.INSTANCE, new Listener() { + @Override + public void on(Event event, ContentChangeItem param) { + items.add(param); + } + }); + + EventDispatcher.listen(TableDataModifyEvent.INSTANCE, new Listener() { + @Override + public void on(Event event, ContentChangeItem param) { + items.add(param); + long start = System.currentTimeMillis(); + ContentObjectManager.getInstance().searchObject(param.getObject()); + FineLoggerFactory.getLogger().debug("search object spend {} ", (System.currentTimeMillis() - start)); + List itemsCopy = new ArrayList<>(items); + items.clear(); + onRename(itemsCopy, contentChangeList); + } + }); + + } + + public void register() { + contentChangeList.add(new ChartHyperRelateCellLinkContentChange()); + contentChangeList.add(new ChartHyperRelateFloatLinkContentChange()); + contentChangeList.add(new FormulaContentChange()); + contentChangeList.add(new JavaScriptContentChange()); + } + + private void onRename(List contentChangeItemList, List contentChangeList) { + Map> objectMap = ContentObjectManager.getInstance().getObjectMap(); + if (objectMap != null) { + long start = System.currentTimeMillis(); + for (ContentChange contentChange : contentChangeList) { + Set set = objectMap.get(contentChange.type()); + // 所有需要处理的js等对象 + if (set != null) { + for (Object ob : set) { + fireChange(ob, contentChange, contentChangeItemList); + } + } + } + objectMap.clear(); + FineLoggerFactory.getLogger().debug("replace all content spend {} ", (System.currentTimeMillis() - start)); + } + } + + private void fireChange(Object o, ContentChange contentChange, List itemList) { + // 当前两项存在两项: 数据集名称和组件名称 + for (ContentChangeItem contentChangeItem : itemList) { + Map map = contentChange.changeInfo(); + if (map.containsKey(contentChangeItem.getChangeItem())) { + // 具体重命名取决于复用组件存在多少个组件或数据集 + for (Map.Entry entry : contentChangeItem.getChangeMap().entrySet()) { + map.get(contentChangeItem.getChangeItem()).replace(o, entry.getKey(), entry.getValue()); + } + } + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/mod/bean/ChangeItem.java b/designer-base/src/main/java/com/fr/design/mod/bean/ChangeItem.java new file mode 100644 index 000000000..179a3819b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/bean/ChangeItem.java @@ -0,0 +1,14 @@ +package com.fr.design.mod.bean; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public enum ChangeItem { + + TABLE_DATA_NAME, + + WIDGET_NAME + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/bean/ContentChangeItem.java b/designer-base/src/main/java/com/fr/design/mod/bean/ContentChangeItem.java new file mode 100644 index 000000000..8904a0c45 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/bean/ContentChangeItem.java @@ -0,0 +1,33 @@ +package com.fr.design.mod.bean; + +import java.util.Map; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class ContentChangeItem { + + private final Map changeMap; + private final ChangeItem changeItem; + private final Object object; + + public ContentChangeItem(Map changeMap,Object object, ChangeItem changeItem) { + this.changeMap = changeMap; + this.changeItem = changeItem; + this.object = object; + } + + public Map getChangeMap() { + return changeMap; + } + + public ChangeItem getChangeItem() { + return changeItem; + } + + public Object getObject() { + return object; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mod/event/ModifyEvent.java b/designer-base/src/main/java/com/fr/design/mod/event/ModifyEvent.java new file mode 100644 index 000000000..a5debb430 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/event/ModifyEvent.java @@ -0,0 +1,13 @@ +package com.fr.design.mod.event; + +import com.fr.design.mod.bean.ContentChangeItem; +import com.fr.event.Event; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class ModifyEvent implements Event { + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/event/TableDataModifyEvent.java b/designer-base/src/main/java/com/fr/design/mod/event/TableDataModifyEvent.java new file mode 100644 index 000000000..6359682cf --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/event/TableDataModifyEvent.java @@ -0,0 +1,12 @@ +package com.fr.design.mod.event; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class TableDataModifyEvent extends ModifyEvent { + + public static final TableDataModifyEvent INSTANCE = new TableDataModifyEvent(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/event/WidgetNameModifyEvent.java b/designer-base/src/main/java/com/fr/design/mod/event/WidgetNameModifyEvent.java new file mode 100644 index 000000000..d3d8a9164 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/event/WidgetNameModifyEvent.java @@ -0,0 +1,12 @@ +package com.fr.design.mod.event; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class WidgetNameModifyEvent extends ModifyEvent { + + public static final WidgetNameModifyEvent INSTANCE = new WidgetNameModifyEvent(); + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateCellLinkContentChange.java b/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateCellLinkContentChange.java new file mode 100644 index 000000000..8b8b32e81 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateCellLinkContentChange.java @@ -0,0 +1,16 @@ +package com.fr.design.mod.impl.change; + +import com.fr.chart.web.ChartHyperRelateCellLink; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class ChartHyperRelateCellLinkContentChange extends ChartHyperRelateLinkContentChange { + + @Override + public String type() { + return ChartHyperRelateCellLink.class.getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateFloatLinkContentChange.java b/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateFloatLinkContentChange.java new file mode 100644 index 000000000..dc3cf04ae --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateFloatLinkContentChange.java @@ -0,0 +1,16 @@ +package com.fr.design.mod.impl.change; + +import com.fr.chart.web.ChartHyperRelateFloatLink; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class ChartHyperRelateFloatLinkContentChange extends ChartHyperRelateLinkContentChange{ + + @Override + public String type() { + return ChartHyperRelateFloatLink.class.getName(); + } +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateLinkContentChange.java b/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateLinkContentChange.java new file mode 100644 index 000000000..139bda0c2 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateLinkContentChange.java @@ -0,0 +1,30 @@ +package com.fr.design.mod.impl.change; + +import com.fr.chart.web.ChartHyperRelateLink; +import com.fr.design.mod.ContentChange; +import com.fr.design.mod.ContentReplacer; +import com.fr.design.mod.bean.ChangeItem; +import com.fr.design.mod.impl.repalce.ChartHyperRelateLink4WidgetNameContentReplacer; +import java.util.HashMap; +import java.util.Map; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/27 + */ +public abstract class ChartHyperRelateLinkContentChange implements ContentChange { + + private final Map> map; + + public ChartHyperRelateLinkContentChange() { + this.map = new HashMap<>(); + map.put(ChangeItem.WIDGET_NAME, new ChartHyperRelateLink4WidgetNameContentReplacer()); + } + + @Override + public Map> changeInfo() { + return map; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/change/FormulaContentChange.java b/designer-base/src/main/java/com/fr/design/mod/impl/change/FormulaContentChange.java new file mode 100644 index 000000000..de69b49d5 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/change/FormulaContentChange.java @@ -0,0 +1,37 @@ +package com.fr.design.mod.impl.change; + +import com.fr.base.Formula; +import com.fr.design.mod.ContentChange; +import com.fr.design.mod.ContentReplacer; +import com.fr.design.mod.bean.ChangeItem; +import com.fr.design.mod.impl.repalce.Formula4TableDataNameContentReplacer; +import com.fr.design.mod.impl.repalce.Formula4WidgetNameContentReplacer; +import java.util.HashMap; +import java.util.Map; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/27 + */ +public class FormulaContentChange implements ContentChange { + + private final Map> map; + + public FormulaContentChange() { + map = new HashMap<>(); + map.put(ChangeItem.WIDGET_NAME, new Formula4WidgetNameContentReplacer()); + map.put(ChangeItem.TABLE_DATA_NAME, new Formula4TableDataNameContentReplacer()); + } + + @Override + public String type() { + return Formula.class.getName(); + } + + @Override + public Map> changeInfo() { + return map; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/change/JavaScriptContentChange.java b/designer-base/src/main/java/com/fr/design/mod/impl/change/JavaScriptContentChange.java new file mode 100644 index 000000000..62653349c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/change/JavaScriptContentChange.java @@ -0,0 +1,36 @@ +package com.fr.design.mod.impl.change; + +import com.fr.design.mod.ContentChange; +import com.fr.design.mod.ContentReplacer; +import com.fr.design.mod.bean.ChangeItem; +import com.fr.design.mod.impl.repalce.JavaScriptContentReplacer; +import com.fr.js.JavaScriptImpl; +import java.util.HashMap; +import java.util.Map; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/27 + */ +public class JavaScriptContentChange implements ContentChange { + + private final Map> map; + + public JavaScriptContentChange() { + map = new HashMap<>(); + map.put(ChangeItem.WIDGET_NAME, new JavaScriptContentReplacer()); + map.put(ChangeItem.TABLE_DATA_NAME, new JavaScriptContentReplacer()); + } + + @Override + public String type() { + return JavaScriptImpl.class.getName(); + } + + @Override + public Map> changeInfo() { + return map; + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/repalce/ChartHyperRelateLink4WidgetNameContentReplacer.java b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/ChartHyperRelateLink4WidgetNameContentReplacer.java new file mode 100644 index 000000000..9fa32280f --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/ChartHyperRelateLink4WidgetNameContentReplacer.java @@ -0,0 +1,21 @@ +package com.fr.design.mod.impl.repalce; + +import com.fr.chart.web.ChartHyperRelateLink; +import com.fr.design.mod.ContentReplacer; +import com.fr.general.ComparatorUtils; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class ChartHyperRelateLink4WidgetNameContentReplacer implements ContentReplacer { + + @Override + public void replace(ChartHyperRelateLink chartHyperRelateLink, String oldName, String newName) { + if (ComparatorUtils.equals(chartHyperRelateLink.getRelateCCName(), oldName)) { + chartHyperRelateLink.setRelateCCName(newName); + } + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java new file mode 100644 index 000000000..c08507229 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java @@ -0,0 +1,18 @@ +package com.fr.design.mod.impl.repalce; + +import com.fr.base.Formula; +import com.fr.design.mod.ContentReplacer; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class Formula4TableDataNameContentReplacer implements ContentReplacer { + + @Override + public void replace(Formula formula, String oldName, String newName) { + //todo 等接口 + } + +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java new file mode 100644 index 000000000..9c5e15810 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java @@ -0,0 +1,17 @@ +package com.fr.design.mod.impl.repalce; + +import com.fr.base.Formula; +import com.fr.design.mod.ContentReplacer; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class Formula4WidgetNameContentReplacer implements ContentReplacer { + + @Override + public void replace(Formula formula, String oldName, String newName) { + //todo 等接口 + } +} diff --git a/designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java new file mode 100644 index 000000000..bbbcd02a4 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java @@ -0,0 +1,25 @@ +package com.fr.design.mod.impl.repalce; + +import com.fr.design.mod.ContentReplacer; +import com.fr.js.JavaScriptImpl; +import com.fr.stable.StringUtils; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2021/5/28 + */ +public class JavaScriptContentReplacer implements ContentReplacer { + + @Override + public void replace(JavaScriptImpl javaScript, String oldName, String newName) { + if (StringUtils.isNotEmpty(javaScript.getContent())) { + javaScript.setContent(javaScript.getContent().replaceAll(generateStr(oldName), generateStr(newName))); + } + } + + private String generateStr(String str) { + return "\"" + str + "\""; + } + +} diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java index 32d217adc..062ec7480 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java @@ -2,11 +2,17 @@ package com.fr.design.designer.beans.models; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.mod.bean.ChangeItem; +import com.fr.design.mod.bean.ContentChangeItem; +import com.fr.design.mod.event.WidgetNameModifyEvent; +import com.fr.event.EventDispatcher; import com.fr.form.main.Form; import com.fr.form.ui.Widget; import com.fr.stable.StringUtils; +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; /** @@ -25,10 +31,13 @@ abstract class ModelUtil { Set nameRelatedCreators = new HashSet<>(); //直接遍历出来目标值,然后按需处理 xCreator.traversalNameRelatedXCreators(nameRelatedCreators); + Map renameMap = new HashMap<>(); for (XCreator target : nameRelatedCreators) { String uniqueName = uniqueName(form, target, duplicated); + renameMap.put(target.toData().getWidgetName(), uniqueName); target.resetCreatorName(uniqueName); } + EventDispatcher.fire(WidgetNameModifyEvent.INSTANCE, new ContentChangeItem(renameMap, xCreator.toData(), ChangeItem.WIDGET_NAME)); } private static String uniqueName(Form form, XCreator xCreator, Set duplicated) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java index eb036239b..1b8940064 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -21,7 +21,11 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.icon.IconPathConstants; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.design.mod.bean.ChangeItem; +import com.fr.design.mod.bean.ContentChangeItem; +import com.fr.design.mod.event.TableDataModifyEvent; import com.fr.design.utils.ComponentUtils; +import com.fr.event.EventDispatcher; import com.fr.form.share.editor.SharableEditorProvider; import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.ShareLoader; @@ -29,6 +33,7 @@ import com.fr.form.ui.Widget; import com.fr.stable.Constants; import com.fr.stable.StringUtils; +import java.util.Collections; import javax.swing.BorderFactory; import javax.swing.JWindow; import java.util.List; @@ -102,14 +107,16 @@ public class FormCreatorDropTarget extends DropTarget { String shareId = addingXCreator.getShareId(); SharableEditorProvider sharableEditor = ShareLoader.getLoader().getSharedElCaseEditorById(shareId); SharableWidgetProvider bindInfo = ShareLoader.getLoader().getElCaseBindInfoById(shareId); + Map tdNameMap = Collections.emptyMap(); if (sharableEditor != null && bindInfo != null) { - Map tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource(), true); + tdNameMap = TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).addTableData(bindInfo.getName(), sharableEditor.getTableDataSource(), true); //合并数据集之后,可能会有数据集名称变化,做一下联动 //共享的组件拿的时候都是克隆的,这边改拖拽中克隆的对象而非新克隆对象,上面这个新克隆的对象只是为了拿数据集 for (Map.Entry entry : tdNameMap.entrySet()) { designer.getTarget().renameTableData(widget, entry.getKey(), entry.getValue()); } } + EventDispatcher.fire(TableDataModifyEvent.INSTANCE, new ContentChangeItem(tdNameMap, widget, ChangeItem.TABLE_DATA_NAME)); } designer.getSelectionModel().setSelectedCreators( FormSelectionUtils.rebuildSelection(xCreator, new Widget[]{widget})); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 43c0e720f..e73e9387f 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -55,6 +55,7 @@ import com.fr.design.mainframe.form.FormReportComponentComposite; import com.fr.design.mainframe.loghandler.DesignerLogAppender; import com.fr.design.mainframe.share.constants.ShareEntryKey; import com.fr.design.mainframe.socketio.DesignerSocketIO; +import com.fr.design.mod.ContentReplacerCenter; import com.fr.design.module.DesignModuleFactory; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.parameter.FormParameterReader; @@ -158,6 +159,7 @@ public class DesignerActivator extends Activator { storePassport(); AlphaFineHelper.switchConfig4Locale(); RecoverManager.register(new RecoverForDesigner()); + ContentReplacerCenter.getInstance().register(); pushUpdateTask.run(); }