From a8596d7e27fd6b5f7ea4dc61c7ca111e8fa35b87 Mon Sep 17 00:00:00 2001 From: hades Date: Tue, 8 Jun 2021 17:17:42 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-53135=20=E3=80=90=E6=99=BA=E8=83=BD?= =?UTF-8?q?=E8=81=94=E5=8A=A8=E3=80=91=E7=BB=84=E4=BB=B6=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=B2=A1=E6=9C=89=E6=96=B0=E5=A2=9E=E6=96=87?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mod/ContentObjectManager.java | 28 +++++++++++++++++++ .../com/fr/design/mod/ContentReplaceUtil.java | 8 ++++++ .../com/fr/design/mod/ContentReplacer.java | 5 ++++ .../repalce/JavaScriptContentReplacer.java | 4 +++ .../VanChartHtmlLabelContentReplacer.java | 5 ++++ .../share/ui/generate/ShareGeneratePane.java | 26 +++++++++++++++-- .../share/ui/generate/ShareMainPane.java | 13 +++++++-- 7 files changed, 85 insertions(+), 4 deletions(-) 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 index b70ea88b0..0111f7836 100644 --- a/designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java +++ b/designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java @@ -9,6 +9,8 @@ import com.fr.data.SimpleDSColumn; import com.fr.data.condition.FormulaCondition; import com.fr.data.impl.FormulaDictionary; import com.fr.data.impl.NameTableData; +import com.fr.design.mod.impl.repalce.JavaScriptContentReplacer; +import com.fr.design.mod.impl.repalce.VanChartHtmlLabelContentReplacer; import com.fr.form.main.FormHyperlink; import com.fr.form.ui.CardSwitchButton; import com.fr.form.ui.WidgetTitle; @@ -22,6 +24,7 @@ import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.FunctionGrouper; import com.fr.report.cell.cellattr.core.group.SelectCount; import com.fr.stable.Filter; +import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -49,6 +52,8 @@ public class ContentObjectManager { private final Set set = new HashSet<>(); + private final Map map = new HashMap<>(); + private ContentObjectManager() { set.add(Formula.class.getName()); set.add(JavaScriptImpl.class.getName()); @@ -70,6 +75,8 @@ public class ContentObjectManager { set.add(SelectCount.class.getName()); set.add(WidgetTitle.class.getName()); set.add(FunctionGrouper.class.getName()); + map.put(JavaScriptImpl.class.getName(), new JavaScriptContentReplacer()); + map.put(VanChartHtmlLabel.class.getName(), new VanChartHtmlLabelContentReplacer()); } public void searchObject(Object ob) { @@ -84,6 +91,9 @@ public class ContentObjectManager { objectMap = ClassHelper.searchObject(ob, set, filter); } public void clearObject() { + if (objectMap != null) { + objectMap.clear(); + } objectMap = null; } @@ -92,4 +102,22 @@ public class ContentObjectManager { return objectMap; } + public boolean needContentTip(Object ob, Set nameSet) { + long start = System.currentTimeMillis(); + objectMap = ClassHelper.searchObject(ob, set, ModClassFilter.getInstance()); + for (Map.Entry> entry : objectMap.entrySet()) { + for (Object o : entry.getValue()) { + for (String name : nameSet) { + ContentReplacer contentReplacer = map.get(entry.getKey()); + if (contentReplacer!= null && contentReplacer.contain(o, name)) { + clearObject(); + return true; + } + } + } + } + clearObject(); + return false; + } + } diff --git a/designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java b/designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java index 1d8e73e84..3b7d9e771 100644 --- a/designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java +++ b/designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java @@ -77,6 +77,7 @@ public class ContentReplaceUtil { content = getFormulaPureContent(content); FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer(); frFormulaTransformer.addRenamedWidget(oldName, newName); + frFormulaTransformer.addRenamedParameter(oldName, newName); return EQ_STRING + frFormulaTransformer.transform(content); } @@ -168,5 +169,12 @@ public class ContentReplaceUtil { return content; } + public static boolean containsName(String content, String name) { + if (StringUtils.isNotEmpty(content)) { + return content.contains(name); + } + return false; + } + } 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 index 3f7126535..a9d54b6a4 100644 --- a/designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java +++ b/designer-base/src/main/java/com/fr/design/mod/ContentReplacer.java @@ -10,4 +10,9 @@ public interface ContentReplacer { void replace(T t, String oldName, String newName); + + default boolean contain(T t, String name) { + return false; + } + } 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 index 118f1b79c..763b0b4a0 100644 --- 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 @@ -19,4 +19,8 @@ public class JavaScriptContentReplacer implements ContentReplacer xCreators = new HashSet<>(); + xCreator.traversalNameRelatedXCreators(xCreators); + Set nameSet = new HashSet<>(); + for (XCreator creator : xCreators) { + nameSet.add(creator.toData().getWidgetName()); + } + boolean result = ContentObjectManager.getInstance().needContentTip(shareWidget, nameSet); + FineLoggerFactory.getLogger().debug("needContentTip spend {} ms", (System.currentTimeMillis() - start)); + return result; + } + private JPanel createUploadCheckBox() { JPanel panel = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java index df1d2c04b..a4fc73fbe 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/ShareMainPane.java @@ -131,13 +131,15 @@ public class ShareMainPane extends JPanel { private boolean upload; private List effectItemGroups; + private final boolean needContentTip; - public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List effectItemGroups) { + public ShareMainPane(Image shareCover, Rectangle rec, boolean upload, List effectItemGroups, boolean needContentTip) { this.shareCover = shareCover; this.rec = rec; this.upload = upload; this.effectItemGroups = effectItemGroups; + this.needContentTip = needContentTip; initCover(shareCover); this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -174,7 +176,14 @@ public class ShareMainPane extends JPanel { private JPanel createOverviewPane(boolean upload) { JPanel componentPane = createComponentOverviewPane(upload); String title = Toolkit.i18nText("Fine-Design_Share_Overview"); - JPanel overviewPane = FRGUIPaneFactory.createTitledBorderPane(title); + JPanel overviewPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(title); + if (needContentTip) { + UILabel tipsLabel = ShareUIUtils.createTipsLabel(Toolkit.i18nText("Fine-Design_Share_Generate_Content_Tip")); + tipsLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0)); + JPanel panel = new JPanel(FRGUIPaneFactory.createBorderLayout()); + panel.add(tipsLabel); + overviewPane.add(panel, BorderLayout.NORTH); + } overviewPane.add(componentPane, BorderLayout.CENTER); return overviewPane;