Browse Source

REPORT-51683 【10.0.17】智能联动被修改位置 update

feature/10.0
hades 4 years ago
parent
commit
268b20690a
  1. 6
      designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java
  2. 20
      designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java
  3. 11
      designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java
  4. 33
      designer-base/src/main/java/com/fr/design/mod/ModClassFilter.java
  5. 35
      designer-base/src/main/java/com/fr/design/mod/impl/change/VanChartHtmlLabelContentChange.java
  6. 6
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4TableDataNameContentReplacer.java
  7. 6
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/Formula4WidgetNameContentReplacer.java
  8. 7
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/JavaScriptContentReplacer.java
  9. 22
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/VanChartHtmlLabelContentReplacer.java
  10. 5
      designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java

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

@ -6,10 +6,12 @@ import com.fr.chart.web.ChartHyperRelateFloatLink;
import com.fr.design.file.filter.ClassFilter; import com.fr.design.file.filter.ClassFilter;
import com.fr.invoke.ClassHelper; import com.fr.invoke.ClassHelper;
import com.fr.js.JavaScriptImpl; import com.fr.js.JavaScriptImpl;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.stable.Filter; import com.fr.stable.Filter;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jetbrains.annotations.Nullable;
/** /**
* 管理所有需要替换内容的对象 * 管理所有需要替换内容的对象
@ -38,10 +40,11 @@ public class ContentObjectManager {
set.add(JavaScriptImpl.class.getName()); set.add(JavaScriptImpl.class.getName());
set.add(ChartHyperRelateCellLink.class.getName()); set.add(ChartHyperRelateCellLink.class.getName());
set.add(ChartHyperRelateFloatLink.class.getName()); set.add(ChartHyperRelateFloatLink.class.getName());
set.add(VanChartHtmlLabel.class.getName());
} }
public void searchObject(Object ob) { public void searchObject(Object ob) {
objectMap = ClassHelper.searchObject(ob, set, ClassFilter.getInstance()); objectMap = ClassHelper.searchObject(ob, set, ModClassFilter.getInstance());
} }
public void searchObject(Object ob, Filter<String> filter) { public void searchObject(Object ob, Filter<String> filter) {
@ -55,6 +58,7 @@ public class ContentObjectManager {
objectMap = null; objectMap = null;
} }
@Nullable
public Map<String, Set<Object>> getObjectMap() { public Map<String, Set<Object>> getObjectMap() {
return objectMap; 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 + "\"";
}
}

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

@ -8,6 +8,7 @@ import com.fr.design.mod.impl.change.ChartHyperRelateCellLinkContentChange;
import com.fr.design.mod.impl.change.ChartHyperRelateFloatLinkContentChange; import com.fr.design.mod.impl.change.ChartHyperRelateFloatLinkContentChange;
import com.fr.design.mod.impl.change.FormulaContentChange; import com.fr.design.mod.impl.change.FormulaContentChange;
import com.fr.design.mod.impl.change.JavaScriptContentChange; 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.Event;
import com.fr.event.EventDispatcher; import com.fr.event.EventDispatcher;
import com.fr.event.Listener; import com.fr.event.Listener;
@ -42,6 +43,9 @@ public class ContentReplacerCenter {
EventDispatcher.listen(WidgetNameModifyEvent.INSTANCE, new Listener<ContentChangeItem>() { EventDispatcher.listen(WidgetNameModifyEvent.INSTANCE, new Listener<ContentChangeItem>() {
@Override @Override
public void on(Event event, ContentChangeItem param) { public void on(Event event, ContentChangeItem param) {
if (param.getChangeMap().isEmpty()) {
return;
}
items.add(param); items.add(param);
} }
}); });
@ -52,7 +56,9 @@ public class ContentReplacerCenter {
items.add(param); items.add(param);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
ContentObjectManager.getInstance().searchObject(param.getObject()); ContentObjectManager.getInstance().searchObject(param.getObject());
FineLoggerFactory.getLogger().debug("search object spend {} ", (System.currentTimeMillis() - start)); 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); List<ContentChangeItem> itemsCopy = new ArrayList<>(items);
items.clear(); items.clear();
onRename(itemsCopy, contentChangeList); onRename(itemsCopy, contentChangeList);
@ -66,6 +72,7 @@ public class ContentReplacerCenter {
contentChangeList.add(new ChartHyperRelateFloatLinkContentChange()); contentChangeList.add(new ChartHyperRelateFloatLinkContentChange());
contentChangeList.add(new FormulaContentChange()); contentChangeList.add(new FormulaContentChange());
contentChangeList.add(new JavaScriptContentChange()); contentChangeList.add(new JavaScriptContentChange());
contentChangeList.add(new VanChartHtmlLabelContentChange());
} }
private void onRename(List<ContentChangeItem> contentChangeItemList, List<ContentChange> contentChangeList) { private void onRename(List<ContentChangeItem> contentChangeItemList, List<ContentChange> contentChangeList) {
@ -82,7 +89,7 @@ public class ContentReplacerCenter {
} }
} }
objectMap.clear(); objectMap.clear();
FineLoggerFactory.getLogger().debug("replace all content spend {} ", (System.currentTimeMillis() - start)); FineLoggerFactory.getLogger().debug("replace all content spend {} ms", (System.currentTimeMillis() - start));
} }
} }

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

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

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

@ -1,7 +1,9 @@
package com.fr.design.mod.impl.repalce; package com.fr.design.mod.impl.repalce;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer; import com.fr.design.mod.ContentReplacer;
import com.fr.parser.FRFormulaTransformer;
/** /**
* @author hades * @author hades
@ -12,7 +14,9 @@ public class Formula4TableDataNameContentReplacer implements ContentReplacer<For
@Override @Override
public void replace(Formula formula, String oldName, String newName) { public void replace(Formula formula, String oldName, String newName) {
//todo 等接口 FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedDataset(oldName, newName);
formula.setContent(ContentReplaceUtil.EQ_STRING + frFormulaTransformer.transform(formula.getPureContent()));
} }
} }

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

@ -1,7 +1,9 @@
package com.fr.design.mod.impl.repalce; package com.fr.design.mod.impl.repalce;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer; import com.fr.design.mod.ContentReplacer;
import com.fr.parser.FRFormulaTransformer;
/** /**
* @author hades * @author hades
@ -12,6 +14,8 @@ public class Formula4WidgetNameContentReplacer implements ContentReplacer<Formul
@Override @Override
public void replace(Formula formula, String oldName, String newName) { public void replace(Formula formula, String oldName, String newName) {
//todo 等接口 FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedWidget(oldName, newName);
formula.setContent(ContentReplaceUtil.EQ_STRING + frFormulaTransformer.transform(formula.getPureContent()));
} }
} }

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

@ -1,6 +1,7 @@
package com.fr.design.mod.impl.repalce; package com.fr.design.mod.impl.repalce;
import com.fr.design.mod.ContentReplacer; import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.js.JavaScriptImpl; import com.fr.js.JavaScriptImpl;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -14,12 +15,8 @@ public class JavaScriptContentReplacer implements ContentReplacer<JavaScriptImpl
@Override @Override
public void replace(JavaScriptImpl javaScript, String oldName, String newName) { public void replace(JavaScriptImpl javaScript, String oldName, String newName) {
if (StringUtils.isNotEmpty(javaScript.getContent())) { if (StringUtils.isNotEmpty(javaScript.getContent())) {
javaScript.setContent(javaScript.getContent().replaceAll(generateStr(oldName), generateStr(newName))); javaScript.setContent(ContentReplaceUtil.replaceContent(javaScript.getContent(), oldName, newName));
} }
} }
private String generateStr(String str) {
return "\"" + str + "\"";
}
} }

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

5
designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java

@ -34,7 +34,10 @@ abstract class ModelUtil {
Map<String, String> renameMap = new HashMap<>(); Map<String, String> renameMap = new HashMap<>();
for (XCreator target : nameRelatedCreators) { for (XCreator target : nameRelatedCreators) {
String uniqueName = uniqueName(form, target, duplicated); String uniqueName = uniqueName(form, target, duplicated);
renameMap.put(target.toData().getWidgetName(), uniqueName); String oldName = target.toData().getWidgetName();
if (StringUtils.isNotEmpty(oldName)) {
renameMap.put(oldName, uniqueName);
}
target.resetCreatorName(uniqueName); target.resetCreatorName(uniqueName);
} }
EventDispatcher.fire(WidgetNameModifyEvent.INSTANCE, new ContentChangeItem(renameMap, xCreator.toData(), ChangeItem.WIDGET_NAME)); EventDispatcher.fire(WidgetNameModifyEvent.INSTANCE, new ContentChangeItem(renameMap, xCreator.toData(), ChangeItem.WIDGET_NAME));

Loading…
Cancel
Save