From b5f3394fa77a00d76deaad9505c648f7675418ca Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 19:56:10 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-52928=20=E9=83=A8=E5=88=86=E5=9F=8B?= =?UTF-8?q?=E7=82=B9=E6=B2=A1=E6=9C=89=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collect/SharableCollectorManager.java | 2 +- .../java/com/fr/design/mainframe/JForm.java | 25 +++++++++++++++++++ .../share/util/ShareComponentUtils.java | 18 ++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java index 1248a74c7..2ea982001 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java @@ -43,7 +43,7 @@ public class SharableCollectorManager { public void execute() { service = Executors - .newSingleThreadScheduledExecutor(new NamedThreadFactory("plugin-CollectorManager", true)); + .newSingleThreadScheduledExecutor(new NamedThreadFactory("SharableComponentCollectorManager", true)); service.scheduleAtFixedRate(new Runnable() { @Override public void run() { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java index 2a130dad4..c67280caa 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/JForm.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/JForm.java @@ -45,6 +45,8 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.form.FormECCompositeProvider; import com.fr.design.mainframe.form.FormECDesignerProvider; +import com.fr.design.mainframe.share.collect.ComponentCollector; +import com.fr.design.mainframe.share.util.ShareComponentUtils; import com.fr.design.mainframe.template.info.JFormProcessInfo; import com.fr.design.mainframe.template.info.TemplateProcessInfo; import com.fr.design.mainframe.toolbar.ToolBarMenuDock; @@ -74,6 +76,7 @@ import com.fr.form.ui.Widget; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WLayout; import com.fr.general.ComparatorUtils; +import com.fr.json.JSONArray; import com.fr.log.FineLoggerFactory; import com.fr.page.PaperSettingProvider; import com.fr.plugin.observer.PluginEventListener; @@ -337,6 +340,28 @@ public class JForm extends JTemplate implements BaseJForm jt) { + if (jt == null) { + return; + } + int useCount = 0; + if (!jt.getProcessInfo().isTestTemplate()) { + JForm jForm = (JForm) jt; + XLayoutContainer root = jForm.getFormDesign().getRootComponent(); + List xCreators = ShareComponentUtils.getHelpConfigXCreatorList(root); + JSONArray helpConfigUseInfo = ComponentCollector.getInstance().getHelpConfigUseInfoWithTemplate(jt.getTarget().getTemplateID()); + for (XCreator xCreator : xCreators) { + if (helpConfigUseInfo.contains(ShareComponentUtils.getWidgetId(xCreator.toData()))) { + useCount++; + } + } + ComponentCollector.getInstance().collectHelpConfigInfo(jt.getTarget().getTemplateID(), xCreators.size(), useCount); + } + + } + }); return tabCenterPane; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java index abd2c5450..485c44149 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/ShareComponentUtils.java @@ -20,8 +20,11 @@ import com.fr.stable.StringUtils; import com.fr.workspace.WorkContext; import org.jetbrains.annotations.NotNull; +import java.awt.Component; import java.awt.Dimension; import java.awt.Rectangle; +import java.util.ArrayList; +import java.util.List; /** * Coder: zack @@ -89,5 +92,18 @@ public class ShareComponentUtils { } - + public static List getHelpConfigXCreatorList(XCreator root) { + List helpConfigXCreatorList = new ArrayList<>(); + if (isShareWidget(root)) { + helpConfigXCreatorList.add(root); + return helpConfigXCreatorList; + } + Component[] components = root.getComponents(); + for (Component component : components) { + if (component instanceof XCreator) { + helpConfigXCreatorList.addAll(getHelpConfigXCreatorList((XCreator) component)); + } + } + return helpConfigXCreatorList; + } }