From 661babee78939bc5451b60dd99371626d7e4976d Mon Sep 17 00:00:00 2001 From: lucian Date: Wed, 11 Mar 2020 16:22:19 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-26262=20=E5=88=87=E6=8D=A2=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E7=9B=AE=E5=BD=95=EF=BC=8C=E6=8E=A7=E4=BB=B6=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E4=B8=8D=E8=83=BD=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/WidgetDefinePaneFactory.java | 32 +++++++++++++++++-- .../widget/WidgetMobilePaneFactory.java | 30 ++++++++++++++++- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java index 2df2e9f2a..0dbde28ad 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetDefinePaneFactory.java @@ -1,6 +1,7 @@ package com.fr.design.widget; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.gui.core.WidgetConstants; import com.fr.design.widget.ui.ButtonDefinePane; import com.fr.design.widget.ui.CheckBoxDefinePane; @@ -42,7 +43,13 @@ import com.fr.form.ui.TextEditor; import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; import com.fr.form.ui.Widget; +import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import com.fr.report.web.button.form.TreeNodeToggleButton; import com.fr.report.web.button.write.AppendRowButton; import com.fr.report.web.button.write.DeleteRowButton; @@ -66,6 +73,26 @@ public class WidgetDefinePaneFactory { private static Map, Appearance> pluginDefineMap = ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap(); static { + putDefault(); + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshPluginMap(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PluginModule.ExtraDesign, CellWidgetOptionProvider.XML_TAG); + } + }); + } + + private WidgetDefinePaneFactory() { + + } + + private static void putDefault() { defineMap.put(NumberEditor.class, new Appearance(NumberEditorDefinePane.class, WidgetConstants.NUMBER + "")); defineMap.put(DateEditor.class, new Appearance(DateEditorDefinePane.class, WidgetConstants.DATE + "")); defineMap.put(ComboCheckBox.class, new Appearance(ComboCheckBoxDefinePane.class, WidgetConstants.COMBOCHECKBOX + "")); @@ -96,8 +123,9 @@ public class WidgetDefinePaneFactory { defineMap.put(TreeNodeToggleButton.class, new Appearance(ButtonDefinePane.class, WidgetConstants.BUTTON + "")); } - private WidgetDefinePaneFactory() { - + private static void refreshPluginMap() { + pluginDefineMap.clear(); + pluginDefineMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetOptionsMap()); } @Nullable diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java index e6438897c..86eba335d 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetMobilePaneFactory.java @@ -1,13 +1,20 @@ package com.fr.design.widget; import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.CellWidgetOptionProvider; import com.fr.design.widget.mobile.WidgetMobilePane; import com.fr.design.widget.ui.mobile.MultiFileEditorMobilePane; import com.fr.design.widget.ui.mobile.ScanCodeMobilePane; import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.TextEditor; import com.fr.form.ui.Widget; +import com.fr.general.GeneralContext; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.context.PluginContext; +import com.fr.plugin.injectable.PluginModule; +import com.fr.plugin.manage.PluginFilter; +import com.fr.plugin.observer.PluginEvent; +import com.fr.plugin.observer.PluginEventListener; import java.util.HashMap; import java.util.Map; @@ -17,22 +24,43 @@ import java.util.Map; */ public class WidgetMobilePaneFactory { private static Map, Class> mobilePaneMap = new HashMap<>(); + private static Map, Class> mobilePluginPaneMap = new HashMap<>(); static { mobilePaneMap.put(MultiFileEditor.class, MultiFileEditorMobilePane.class); mobilePaneMap.put(TextEditor.class, ScanCodeMobilePane.class); - mobilePaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); + mobilePluginPaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); + + GeneralContext.listenPluginRunningChanged(new PluginEventListener() { + @Override + public void on(PluginEvent event) { + refreshPluginMap(); + } + }, new PluginFilter() { + @Override + public boolean accept(PluginContext context) { + return context.contain(PluginModule.ExtraDesign, CellWidgetOptionProvider.XML_TAG); + } + }); } private WidgetMobilePaneFactory() { } + private static void refreshPluginMap() { + mobilePluginPaneMap.clear(); + mobilePluginPaneMap.putAll(ExtraDesignClassManager.getInstance().getCellWidgetMobileOptionsMap()); + } + public static WidgetMobilePane createWidgetMobilePane(Widget widget) { WidgetMobilePane mobilePane = WidgetMobilePane.DEFAULT_PANE; try { if (mobilePaneMap.containsKey(widget.getClass())) { mobilePane = mobilePaneMap.get(widget.getClass()).newInstance(); mobilePane.populate(widget); + } else if (mobilePluginPaneMap.containsKey(widget.getClass())){ + mobilePane = mobilePluginPaneMap.get(widget.getClass()).newInstance(); + mobilePane.populate(widget); } } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e);