From 25293200a50269c0cad89b3adedd5af0a9a12aaa Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 16:04:30 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-52819=20=E5=8A=A0=E5=AF=86=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=8A=A0=E8=BD=BD=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...orManager.java => SharableCollectorManager.java} | 6 +++--- .../mainframe/share/util/SharableXMLUtils.java | 13 +++++++++++++ .../com/fr/design/share/SharableInitManager.java | 11 +++++++++++ .../java/com/fr/start/module/DesignerActivator.java | 3 ++- 4 files changed, 29 insertions(+), 4 deletions(-) rename designer-base/src/main/java/com/fr/design/mainframe/share/collect/{CollectorManager.java => SharableCollectorManager.java} (92%) create mode 100644 designer-form/src/main/java/com/fr/design/mainframe/share/util/SharableXMLUtils.java create mode 100644 designer-realize/src/main/java/com/fr/design/share/SharableInitManager.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/CollectorManager.java b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java similarity index 92% rename from designer-base/src/main/java/com/fr/design/mainframe/share/collect/CollectorManager.java rename to designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java index 3ccb62429..1248a74c7 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/CollectorManager.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/SharableCollectorManager.java @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit; /** * created by Harrison on 2020/03/25 **/ -public class CollectorManager { +public class SharableCollectorManager { /** * 1 天 @@ -32,10 +32,10 @@ public class CollectorManager { private ScheduledExecutorService service; private static class ConfigManagerHolder { - private static CollectorManager instance = new CollectorManager(); + private static SharableCollectorManager instance = new SharableCollectorManager(); } - public static CollectorManager getInstance() { + public static SharableCollectorManager getInstance() { return ConfigManagerHolder.instance; } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/SharableXMLUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/SharableXMLUtils.java new file mode 100644 index 000000000..baacf4272 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/SharableXMLUtils.java @@ -0,0 +1,13 @@ +package com.fr.design.mainframe.share.util; + +import com.fr.form.share.encrypt.engine.SharableReadHelper; +import com.fr.stable.xml.XMLConf; +import com.fr.stable.xml.helper.XMLReadHelper; + +public class SharableXMLUtils { + public static synchronized void registerSharableReadHelper() { + XMLReadHelper readHelper = XMLConf.getReadHelper(); + XMLReadHelper helper = new SharableReadHelper(readHelper); + XMLConf.registerXMLHelper(helper); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/share/SharableInitManager.java b/designer-realize/src/main/java/com/fr/design/share/SharableInitManager.java new file mode 100644 index 000000000..42870535b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/share/SharableInitManager.java @@ -0,0 +1,11 @@ +package com.fr.design.share; + +import com.fr.design.mainframe.share.collect.SharableCollectorManager; +import com.fr.design.mainframe.share.util.SharableXMLUtils; + +public class SharableInitManager { + public static void start() { + SharableXMLUtils.registerSharableReadHelper(); + SharableCollectorManager.getInstance().execute(); + } +} 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 5c7a20efc..43c0e720f 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 @@ -60,12 +60,12 @@ import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.parameter.FormParameterReader; import com.fr.design.parameter.ParameterPropertyPane; import com.fr.design.parameter.WorkBookParameterReader; +import com.fr.design.share.SharableInitManager; import com.fr.design.share.ui.config.ShareConfigPane; import com.fr.design.share.ui.generate.ShareGeneratePane; import com.fr.design.update.actions.RecoverForDesigner; import com.fr.design.update.push.DesignerPushUpdateManager; import com.fr.design.widget.ui.btn.FormSubmitButtonDetailPane; -import com.fr.form.stable.ElementCaseThumbnailProcessor; import com.fr.general.GeneralContext; import com.fr.general.xml.GeneralXMLTools; import com.fr.js.EmailJavaScript; @@ -205,6 +205,7 @@ public class DesignerActivator extends Activator { designerRegister(); InformationCollector.getInstance().collectStartTime(); + SharableInitManager.start(); } private void createPluginListener() { From bb828b6e089b8a45854b2f4c388bc16ba794dc4e Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 16:21:11 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-52816=20=E7=BC=96=E8=BE=91=E6=A1=86?= =?UTF-8?q?=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/share/ui/generate/ShareMainPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e9b5a25e2..504d95be9 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 @@ -498,7 +498,7 @@ public class ShareMainPane extends JPanel { ArrayUtils.toPrimitive(rowSizeList.toArray(new Double[rowSizeList.size()])), columnSize, rowCountList.toArray(new int[rowCountList.size()][]), - LayoutConstants.VGAP_MEDIUM, LayoutConstants.VGAP_MEDIUM); + LayoutConstants.HGAP_SMALL, LayoutConstants.VGAP_MEDIUM); } private JPanel createNameFiledPane() { From e6bcb5a99a6549f38c4de8785ed87b818f465731 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 16:30:28 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-52818=20=E5=9B=BE=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=BF=AB=E6=8D=B7=E9=85=8D=E7=BD=AE=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E4=BA=86=E7=BC=96=E8=BE=91=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/designer/creator/XChartEditor.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index 24bea0177..682dcc4d4 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -255,6 +255,10 @@ public class XChartEditor extends XBorderStyleWidgetCreator { * @param e 鼠标点击事件 */ public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { + if (this.isShareConfigButtonFocus()) { + CoverReportPane.showShareConfig(((XCreator) this.getParent()).toData()); + return; + } FormDesigner designer = editingMouseListener.getDesigner(); SelectionModel selectionModel = editingMouseListener.getSelectionModel(); isEditing = e.getButton() == MouseEvent.BUTTON1 && @@ -272,11 +276,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator { } } } - if (this.isShareConfigButtonFocus()) { - CoverReportPane.showShareConfig(((XCreator) this.getParent()).toData()); - } - - } @Override From 8169f88c6c7f5ce25844f60220471ef8c0ff6499 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 19:21:18 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-52895=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 --- .../com/fr/design/mainframe/EastRegionContainerPane.java | 2 ++ .../design/mainframe/share/collect/ComponentCollector.java | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java index 1bffe0842..3047ca99c 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java @@ -15,6 +15,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.reuse.ReuseGuideDialog; import com.fr.design.mainframe.reuse.SnapChatKeys; +import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.menu.SnapChatUtil; import com.fr.design.notification.SnapChat; import com.fr.design.notification.SnapChatFactory; @@ -313,6 +314,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer { new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + ComponentCollector.getInstance().collectCmpBoardClick(); ComponentReuseNotifyUtil.enterWidgetLibExtraAction(true); } }); diff --git a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java index 1fa2b993e..3ea805deb 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/share/collect/ComponentCollector.java @@ -12,6 +12,7 @@ import com.fr.form.share.Group; import com.fr.form.share.group.filter.DirFilter; import com.fr.form.share.group.filter.ReuFilter; import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.json.JSON; import com.fr.json.JSONArray; import com.fr.json.JSONException; @@ -371,7 +372,7 @@ public class ComponentCollector implements XMLable { sortType = JSONFactory.createJSON(JSON.ARRAY); } - private int cmpBoardClickDaily() { + private int cmpBoardClickDaily() { DateTime dateTime = DateTime.parse(startTime); DateTime currTime = DateTime.now(); @@ -524,7 +525,7 @@ public class ComponentCollector implements XMLable { jo.put("userId", MarketConfig.getInstance().getBBSAttr().getBbsUid()); jo.put("uuid", uuid); jo.put("cmpBoardClickDaily", cmpBoardClickDaily()); - jo.put("pluginVersion", PluginContexts.currentContext().getVersion()); + jo.put("pluginVersion", GeneralUtils.readBuildNO()); jo.put("localCmpNumber", localCmpNumber); jo.put("remoteCmpNumber", remoteCmpNumber); jo.put("uploadCmpNumber", uploadCmpNumber); From b5f3394fa77a00d76deaad9505c648f7675418ca Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 19:56:10 +0800 Subject: [PATCH 5/7] =?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; + } } From 61c6ac4fb10d7a26375c5a75cc9bdb31fb4cb107 Mon Sep 17 00:00:00 2001 From: kuangshuai Date: Thu, 27 May 2021 20:27:27 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-51678=20=E4=BA=8B=E4=BB=B6=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9=E6=94=AF=E6=8C=81=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/share/effect/EffectItemGroup.java | 3 +-- .../fr/design/share/effect/ListenerEffectItem.java | 11 +++++++++-- .../share/ui/config/table/ConfigTableModel.java | 3 +-- .../share/ui/generate/table/EffectTableModel.java | 3 +-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java b/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java index 923c200d1..a07478c9d 100644 --- a/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java +++ b/designer-realize/src/main/java/com/fr/design/share/effect/EffectItemGroup.java @@ -68,8 +68,7 @@ public class EffectItemGroup { for (int index = 0; index < listenerSize; index ++) { Listener listener = widget.getListener(index); SourceNode sourceNode = SourceNodeUtils.createSourceNode(widget, null); - String eventName = switchLang(listener.getEventName()) + (index + 1); - this.add(new ListenerEffectItem(listener, sourceNode, eventName)); + this.add(new ListenerEffectItem(listener, sourceNode)); } } diff --git a/designer-realize/src/main/java/com/fr/design/share/effect/ListenerEffectItem.java b/designer-realize/src/main/java/com/fr/design/share/effect/ListenerEffectItem.java index 38d635424..55b53ad72 100644 --- a/designer-realize/src/main/java/com/fr/design/share/effect/ListenerEffectItem.java +++ b/designer-realize/src/main/java/com/fr/design/share/effect/ListenerEffectItem.java @@ -9,10 +9,9 @@ import com.fr.form.ui.Widget; public class ListenerEffectItem extends BaseEffectItem { private Listener listener; - public ListenerEffectItem(Listener listener, SourceNode sourceNode, String name) { + public ListenerEffectItem(Listener listener, SourceNode sourceNode) { this.listener = listener; this.setSourceNode(sourceNode); - this.setName(name); init(); } @@ -24,6 +23,8 @@ public class ListenerEffectItem extends BaseEffectItem { object = new Listener(listener.getTargetWidget(), listener.getEventName(), listener.getAction(), listener.isInvokeOnce()); } setObject(object); + + setName(listener.getName()); this.setNameableCreator(new EventCreator(Widget.EVENT_STATECHANGE, EventPropertyTable.WidgetEventListenerUpdatePane.class)); } @@ -32,7 +33,13 @@ public class ListenerEffectItem extends BaseEffectItem { setObject((Listener) bean); } + public void setName(String name) { + super.setName(name); + getObject().setName(name); + } + public void save() { + listener.setName(getObject().getName()); listener.setEventName(getObject().getEventName()); listener.setAction(getObject().getAction()); listener.setInvokeOnce(getObject().isInvokeOnce()); diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/config/table/ConfigTableModel.java b/designer-realize/src/main/java/com/fr/design/share/ui/config/table/ConfigTableModel.java index 29fe8e125..b9b3f15d2 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/config/table/ConfigTableModel.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/config/table/ConfigTableModel.java @@ -39,8 +39,7 @@ public class ConfigTableModel extends AbstractTableModel { @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - EffectItem effectItem = effectItems.get(rowIndex); - return columnIndex == 1 && !(effectItem instanceof ListenerEffectItem); + return columnIndex == 1; } @Override diff --git a/designer-realize/src/main/java/com/fr/design/share/ui/generate/table/EffectTableModel.java b/designer-realize/src/main/java/com/fr/design/share/ui/generate/table/EffectTableModel.java index 042159c69..f9d4ecb2b 100644 --- a/designer-realize/src/main/java/com/fr/design/share/ui/generate/table/EffectTableModel.java +++ b/designer-realize/src/main/java/com/fr/design/share/ui/generate/table/EffectTableModel.java @@ -44,8 +44,7 @@ public class EffectTableModel extends AbstractTableModel { @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - EffectItem effectItem = effectItems.get(rowIndex); - return columnIndex == 1 && !(effectItem instanceof ListenerEffectItem); + return columnIndex == 1; } @Override From fd6832105343d5142ec7cfa9bf6b25c07691869d Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 27 May 2021 22:42:12 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-52942=20=E5=A4=84=E7=90=86=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8F=90=E5=88=B0=E5=85=AC=E5=85=B1=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=A8=8D=E5=90=8E=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/app/AbstractWorkBookApp.java | 65 +-------------- .../mainframe/app/DesignerAppUtils.java | 83 +++++++++++++++++++ .../com/fr/design/mainframe/app/FormApp.java | 1 + 3 files changed, 85 insertions(+), 64 deletions(-) create mode 100644 designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java index 4f22528c7..60ce295a3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/AbstractWorkBookApp.java @@ -1,31 +1,16 @@ package com.fr.design.mainframe.app; import com.fr.base.Parameter; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.UIExpandDialog; -import com.fr.design.extra.exe.callback.InstallOnlineCallback; -import com.fr.design.extra.exe.callback.ModifyStatusCallback; -import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.App; -import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JWorkBook; import com.fr.design.worker.open.OpenResult; import com.fr.design.worker.open.OpenWorker; import com.fr.file.FILE; -import com.fr.io.TemplateIOErrorUtils; import com.fr.log.FineLoggerFactory; import com.fr.main.impl.WorkBook; -import com.fr.plugin.context.PluginMarker; -import com.fr.plugin.context.PluginMarkerAdapter; -import com.fr.plugin.manage.PluginManager; -import com.fr.plugin.manage.control.PluginControllerHelper; -import com.fr.plugin.manage.control.PluginTask; import com.fr.report.worksheet.WorkSheet; -import com.fr.third.guava.collect.Multimap; -import com.fr.workspace.WorkContext; -import java.util.Collection; import java.util.concurrent.Callable; /** @@ -48,7 +33,7 @@ abstract class AbstractWorkBookApp implements App { @Override public OpenResult call() { WorkBook workBook = asIOFile(tplFile); - dealWithTemplateIOError(tplFile.getPath()); + DesignerAppUtils.dealWithTemplateIOError(tplFile.getPath()); return new OpenResult<>(workBook, workBook.getParameters()); } }, emptyTemplate); @@ -68,54 +53,6 @@ abstract class AbstractWorkBookApp implements App { return emptyTemplate; } - private void dealWithTemplateIOError(String path) { - // 试图获取多行读取错误提示并缓存待处理列表 - String detail = TemplateIOErrorUtils.dealWithErrorDetailMultiLineAndCache(path); - if (detail.length() > 0) { - if (WorkContext.getCurrent().isLocal()) { - UIExpandDialog.Builder() - .owner(DesignerContext.getDesignerFrame()) - .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) - .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Local")) - .detail(detail) - .okText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_OK_Btn")) - .cancelText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Cancel_Btn")) - .dialogActionListener(new DialogActionAdapter() { - public void doOk() { - installAndEnablePlugin(path); - } - - @Override - public void doCancel() { - TemplateIOErrorUtils.invalidatePlugins(path); - } - }).build().setVisible(true); - } else { - UIExpandDialog.Builder().owner(DesignerContext.getDesignerFrame()) - .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) - .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Remote")) - .detail(detail) - .build() - .setVisible(true); - } - - } - } - - public void installAndEnablePlugin(String key) { - Multimap stringPluginMarkerAdapterMultimap = TemplateIOErrorUtils.popPluginInfoMap(key); - Collection disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.DISABLE_PLUGIN); - for (PluginMarkerAdapter disablePlugin : disablePlugins) { - PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); - } - - Collection uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.NOT_INSTALLED_PLUGIN); - for (PluginMarker uninstallPlugin : uninstallPlugins) { - PluginTask pluginTask = PluginTask.installTask(uninstallPlugin); - PluginControllerHelper.installOnline(uninstallPlugin, new InstallOnlineCallback(pluginTask)); - } - } - @Override public String mark4Provider() { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java new file mode 100644 index 000000000..4ac1a273a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/DesignerAppUtils.java @@ -0,0 +1,83 @@ +package com.fr.design.mainframe.app; + +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.UIExpandDialog; +import com.fr.design.extra.exe.callback.InstallOnlineCallback; +import com.fr.design.extra.exe.callback.ModifyStatusCallback; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.ui.util.UIUtil; +import com.fr.io.TemplateIOErrorUtils; +import com.fr.plugin.context.PluginMarker; +import com.fr.plugin.context.PluginMarkerAdapter; +import com.fr.plugin.manage.PluginManager; +import com.fr.plugin.manage.control.PluginControllerHelper; +import com.fr.plugin.manage.control.PluginTask; +import com.fr.third.guava.collect.Multimap; +import com.fr.workspace.WorkContext; + +import java.util.Collection; + +/** + * 设计器app共用工具类 + * + * @author vito + * @version 10.0 + * Created by vito on 2021/5/27 + */ +public class DesignerAppUtils { + + /** + * 处理模板读取时的异常 + * + * @param path 模板路径 + */ + public static void dealWithTemplateIOError(String path) { + // 试图获取多行读取错误提示并缓存待处理列表 + String detail = TemplateIOErrorUtils.dealWithErrorDetailMultiLineAndCache(path); + if (detail.length() > 0) { + UIUtil.invokeLaterIfNeeded(() -> { + if (WorkContext.getCurrent().isLocal()) { + UIExpandDialog.Builder() + .owner(DesignerContext.getDesignerFrame()) + .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) + .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Local")) + .detail(detail) + .okText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_OK_Btn")) + .cancelText(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Cancel_Btn")) + .dialogActionListener(new DialogActionAdapter() { + public void doOk() { + installAndEnablePlugin(path); + } + + @Override + public void doCancel() { + TemplateIOErrorUtils.invalidatePlugins(path); + } + }).build().setVisible(true); + } else { + UIExpandDialog.Builder().owner(DesignerContext.getDesignerFrame()) + .title(Toolkit.i18nText("Fine-Design_Basic_Tool_Tips")) + .message(Toolkit.i18nText("Fine-Design_Template_Plugin_Error_Message_Remote")) + .detail(detail) + .build() + .setVisible(true); + } + }); + } + } + + private static void installAndEnablePlugin(String key) { + Multimap stringPluginMarkerAdapterMultimap = TemplateIOErrorUtils.popPluginInfoMap(key); + Collection disablePlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.DISABLE_PLUGIN); + for (PluginMarkerAdapter disablePlugin : disablePlugins) { + PluginManager.getController().enable(disablePlugin, new ModifyStatusCallback(false)); + } + + Collection uninstallPlugins = stringPluginMarkerAdapterMultimap.get(TemplateIOErrorUtils.NOT_INSTALLED_PLUGIN); + for (PluginMarker uninstallPlugin : uninstallPlugins) { + PluginTask pluginTask = PluginTask.installTask(uninstallPlugin); + PluginControllerHelper.installOnline(uninstallPlugin, new InstallOnlineCallback(pluginTask)); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java index 5d828713f..511c98e62 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java @@ -63,6 +63,7 @@ class FormApp extends AbstractAppProvider { @Override public OpenResult call() throws Exception { Form form = asIOFile(tplFile); + DesignerAppUtils.dealWithTemplateIOError(tplFile.getPath()); return new OpenResult<>(form, form.getParameters()); } }, emptyForm);