Browse Source

Pull request #4421: REPORT-51683 【10.0.17】智能联动被修改位置

Merge in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit '268b20690ad2e2b793bdd699f808a6d87c0d2fff':
  REPORT-51683 【10.0.17】智能联动被修改位置 update
  REPORT-51683 【10.0.17】智能联动被修改位置
feature/10.0
Hades 3 years ago
parent
commit
20b772c00d
  1. 29
      designer-base/src/main/java/com/fr/design/mod/ContentChange.java
  2. 66
      designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java
  3. 20
      designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java
  4. 13
      designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java
  5. 108
      designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java
  6. 33
      designer-base/src/main/java/com/fr/design/mod/ModClassFilter.java
  7. 14
      designer-base/src/main/java/com/fr/design/mod/bean/ChangeItem.java
  8. 33
      designer-base/src/main/java/com/fr/design/mod/bean/ContentChangeItem.java
  9. 13
      designer-base/src/main/java/com/fr/design/mod/event/ModifyEvent.java
  10. 12
      designer-base/src/main/java/com/fr/design/mod/event/TableDataModifyEvent.java
  11. 12
      designer-base/src/main/java/com/fr/design/mod/event/WidgetNameModifyEvent.java
  12. 16
      designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateCellLinkContentChange.java
  13. 16
      designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateFloatLinkContentChange.java
  14. 30
      designer-base/src/main/java/com/fr/design/mod/impl/change/ChartHyperRelateLinkContentChange.java
  15. 37
      designer-base/src/main/java/com/fr/design/mod/impl/change/FormulaContentChange.java
  16. 36
      designer-base/src/main/java/com/fr/design/mod/impl/change/JavaScriptContentChange.java
  17. 35
      designer-base/src/main/java/com/fr/design/mod/impl/change/VanChartHtmlLabelContentChange.java
  18. 21
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/ChartHyperRelateLink4WidgetNameContentReplacer.java
  19. 22
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java
  20. 21
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java
  21. 22
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java
  22. 22
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/VanChartHtmlLabelContentReplacer.java
  23. 12
      designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java
  24. 9
      designer-form/src/main/java/com/fr/design/mainframe/FormCreatorDropTarget.java
  25. 2
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

29
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<T> {
/**
* 标识内容替换类型
*
* @return
*/
String type();
/**
* 替换详情信息
*
* @return
*/
Map<ChangeItem, ContentReplacer<T>> changeInfo();
}

66
designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java

@ -0,0 +1,66 @@
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.plugin.chart.base.VanChartHtmlLabel;
import com.fr.stable.Filter;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.jetbrains.annotations.Nullable;
/**
* 管理所有需要替换内容的对象
*
* @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<String, Set<Object>> objectMap;
private final Set<String> 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());
set.add(VanChartHtmlLabel.class.getName());
}
public void searchObject(Object ob) {
objectMap = ClassHelper.searchObject(ob, set, ModClassFilter.getInstance());
}
public void searchObject(Object ob, Filter<String> filter) {
objectMap = ClassHelper.searchObject(ob, set, filter);
}
public void searchObject(Object ob, Set<String> set, Filter<String> filter) {
objectMap = ClassHelper.searchObject(ob, set, filter);
}
public void clearObject() {
objectMap = null;
}
@Nullable
public Map<String, Set<Object>> getObjectMap() {
return objectMap;
}
}

20
designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java

@ -0,0 +1,20 @@
package com.fr.design.mod;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/5/31
*/
public class ContentReplaceUtil {
public static final String EQ_STRING = "=";
public static String replaceContent(String content, String oldName, String newName) {
return content.replaceAll(generateStr(oldName), generateStr(newName));
}
private static String generateStr(String str) {
return "\"" + str + "\"";
}
}

13
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<T> {
void replace(T t, String oldName, String newName);
}

108
designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java

@ -0,0 +1,108 @@
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.design.mod.impl.change.VanChartHtmlLabelContentChange;
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<ContentChange> contentChangeList = new ArrayList<>();
private List<ContentChangeItem> items = new ArrayList<>();
private ContentReplacerCenter() {
EventDispatcher.listen(WidgetNameModifyEvent.INSTANCE, new Listener<ContentChangeItem>() {
@Override
public void on(Event event, ContentChangeItem param) {
if (param.getChangeMap().isEmpty()) {
return;
}
items.add(param);
}
});
EventDispatcher.listen(TableDataModifyEvent.INSTANCE, new Listener<ContentChangeItem>() {
@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 {} ms", (System.currentTimeMillis() - start));
FineLoggerFactory.getLogger().debug("search result: {}", ContentObjectManager.getInstance().getObjectMap() == null
? null : ContentObjectManager.getInstance().getObjectMap().keySet());
List<ContentChangeItem> 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());
contentChangeList.add(new VanChartHtmlLabelContentChange());
}
private void onRename(List<ContentChangeItem> contentChangeItemList, List<ContentChange> contentChangeList) {
Map<String, Set<Object>> objectMap = ContentObjectManager.getInstance().getObjectMap();
if (objectMap != null) {
long start = System.currentTimeMillis();
for (ContentChange contentChange : contentChangeList) {
Set<Object> 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 {} ms", (System.currentTimeMillis() - start));
}
}
private void fireChange(Object o, ContentChange contentChange, List<ContentChangeItem> itemList) {
// 当前两项存在两项: 数据集名称和组件名称
for (ContentChangeItem contentChangeItem : itemList) {
Map<ChangeItem, ContentReplacer> map = contentChange.changeInfo();
if (map.containsKey(contentChangeItem.getChangeItem())) {
// 具体重命名取决于复用组件存在多少个组件或数据集
for (Map.Entry<String, String> entry : contentChangeItem.getChangeMap().entrySet()) {
map.get(contentChangeItem.getChangeItem()).replace(o, entry.getKey(), entry.getValue());
}
}
}
}
}

33
designer-base/src/main/java/com/fr/design/mod/ModClassFilter.java

@ -0,0 +1,33 @@
package com.fr.design.mod;
import com.fr.stable.Filter;
import java.util.HashSet;
import java.util.Set;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/5/31
*/
public class ModClassFilter implements Filter<String> {
private static final Set<String> FILTER_SET = new HashSet<>();
private static final Filter<String> INSTANCE = new ModClassFilter();
public static Filter<String> getInstance() {
return INSTANCE;
}
static {
FILTER_SET.add("java.awt.image.BufferedImage");
FILTER_SET.add("sun.awt.AppContext");
FILTER_SET.add("com.fr.poly.creator.ECBlockCreator");
FILTER_SET.add("io.netty.channel.nio.SelectedSelectionKeySet");
}
@Override
public boolean accept(String s) {
return FILTER_SET.contains(s);
}
}

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

33
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<String, String> changeMap;
private final ChangeItem changeItem;
private final Object object;
public ContentChangeItem(Map<String, String> changeMap,Object object, ChangeItem changeItem) {
this.changeMap = changeMap;
this.changeItem = changeItem;
this.object = object;
}
public Map<String, String> getChangeMap() {
return changeMap;
}
public ChangeItem getChangeItem() {
return changeItem;
}
public Object getObject() {
return object;
}
}

13
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<ContentChangeItem> {
}

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

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

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

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

30
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<ChartHyperRelateLink> {
private final Map<ChangeItem, ContentReplacer<ChartHyperRelateLink>> map;
public ChartHyperRelateLinkContentChange() {
this.map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, new ChartHyperRelateLink4WidgetNameContentReplacer());
}
@Override
public Map<ChangeItem, ContentReplacer<ChartHyperRelateLink>> changeInfo() {
return map;
}
}

37
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<Formula> {
private final Map<ChangeItem, ContentReplacer<Formula>> 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<ChangeItem, ContentReplacer<Formula>> changeInfo() {
return map;
}
}

36
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<JavaScriptImpl> {
private final Map<ChangeItem, ContentReplacer<JavaScriptImpl>> 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<ChangeItem, ContentReplacer<JavaScriptImpl>> changeInfo() {
return map;
}
}

35
designer-base/src/main/java/com/fr/design/mod/impl/change/VanChartHtmlLabelContentChange.java

@ -0,0 +1,35 @@
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.VanChartHtmlLabelContentReplacer;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/5/31
*/
public class VanChartHtmlLabelContentChange implements ContentChange<VanChartHtmlLabel> {
private final Map<ChangeItem, ContentReplacer<VanChartHtmlLabel>> map;
public VanChartHtmlLabelContentChange() {
map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, new VanChartHtmlLabelContentReplacer());
map.put(ChangeItem.TABLE_DATA_NAME, new VanChartHtmlLabelContentReplacer());
}
@Override
public String type() {
return VanChartHtmlLabel.class.getName();
}
@Override
public Map<ChangeItem, ContentReplacer<VanChartHtmlLabel>> changeInfo() {
return map;
}
}

21
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<ChartHyperRelateLink> {
@Override
public void replace(ChartHyperRelateLink chartHyperRelateLink, String oldName, String newName) {
if (ComparatorUtils.equals(chartHyperRelateLink.getRelateCCName(), oldName)) {
chartHyperRelateLink.setRelateCCName(newName);
}
}
}

22
designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java

@ -0,0 +1,22 @@
package com.fr.design.mod.impl.repalce;
import com.fr.base.Formula;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer;
import com.fr.parser.FRFormulaTransformer;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/5/28
*/
public class Formula4TableDataNameContentReplacer implements ContentReplacer<Formula> {
@Override
public void replace(Formula formula, String oldName, String newName) {
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedDataset(oldName, newName);
formula.setContent(ContentReplaceUtil.EQ_STRING + frFormulaTransformer.transform(formula.getPureContent()));
}
}

21
designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java

@ -0,0 +1,21 @@
package com.fr.design.mod.impl.repalce;
import com.fr.base.Formula;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer;
import com.fr.parser.FRFormulaTransformer;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/5/28
*/
public class Formula4WidgetNameContentReplacer implements ContentReplacer<Formula> {
@Override
public void replace(Formula formula, String oldName, String newName) {
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedWidget(oldName, newName);
formula.setContent(ContentReplaceUtil.EQ_STRING + frFormulaTransformer.transform(formula.getPureContent()));
}
}

22
designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java

@ -0,0 +1,22 @@
package com.fr.design.mod.impl.repalce;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.ContentReplaceUtil;
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<JavaScriptImpl> {
@Override
public void replace(JavaScriptImpl javaScript, String oldName, String newName) {
if (StringUtils.isNotEmpty(javaScript.getContent())) {
javaScript.setContent(ContentReplaceUtil.replaceContent(javaScript.getContent(), oldName, newName));
}
}
}

22
designer-base/src/main/java/com/fr/design/mod/impl/repalce/VanChartHtmlLabelContentReplacer.java

@ -0,0 +1,22 @@
package com.fr.design.mod.impl.repalce;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.stable.StringUtils;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/5/31
*/
public class VanChartHtmlLabelContentReplacer implements ContentReplacer<VanChartHtmlLabel> {
@Override
public void replace(VanChartHtmlLabel vanChartHtmlLabel, String oldName, String newName) {
if (StringUtils.isNotEmpty(vanChartHtmlLabel.getCustomText())) {
vanChartHtmlLabel.setCustomText(
ContentReplaceUtil.replaceContent(vanChartHtmlLabel.getCustomText(), oldName, newName));
}
}
}

12
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,16 @@ abstract class ModelUtil {
Set<XCreator> nameRelatedCreators = new HashSet<>();
//直接遍历出来目标值,然后按需处理
xCreator.traversalNameRelatedXCreators(nameRelatedCreators);
Map<String, String> renameMap = new HashMap<>();
for (XCreator target : nameRelatedCreators) {
String uniqueName = uniqueName(form, target, duplicated);
String oldName = target.toData().getWidgetName();
if (StringUtils.isNotEmpty(oldName)) {
renameMap.put(oldName, 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<String> duplicated) {

9
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<String, String> tdNameMap = Collections.emptyMap();
if (sharableEditor != null && bindInfo != null) {
Map<String, String> 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<String, String> 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}));

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

Loading…
Cancel
Save