From 47b00511334c3c1e35d2267eada86623a72314de Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 21 Oct 2021 15:30:26 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-61356=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=8A=A0=E8=BD=BD=E5=AE=8C=E6=88=90=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=81=9C=E7=95=99=E7=9A=84=E7=A9=BA=E7=99=BD=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=8F=98=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/NorthRegionContainerPane.java | 79 ++++++++++++++----- 1 file changed, 61 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java index b07071057..05198ba0e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -17,6 +17,8 @@ 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.plugin.observer.PluginEventType; +import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; @@ -38,6 +40,17 @@ public class NorthRegionContainerPane extends JPanel { private JMenuBar menuBar; + private PluginFilter pluginFilter = new PluginFilter() { + + @Override + public boolean accept(PluginContext context) { + + return context.contain(PluginModule.ExtraDesign); + } + }; + + private volatile boolean existDesignExtraPlugin; + public static NorthRegionContainerPane getInstance() { if (THIS == null) { synchronized (NorthRegionContainerPane.class) { @@ -66,34 +79,64 @@ public class NorthRegionContainerPane extends JPanel { //hugh: private修改为protected方便oem的时候修改右上的组件构成 //顶部日志+登陆按钮 final JPanel northEastPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + initPluginListener(northEastPane, ad); + refreshNorthEastPane(northEastPane, ad); + return northEastPane; + } + + private void initPluginListener(JPanel northEastPane, ToolBarMenuDock ad) { //优先级为-1,保证最后全面刷新一次 - GeneralContext.listenPluginRunningChanged(new PluginEventListener(-1) { + PluginEventListener pluginOnRunOrStopListener = new PluginEventListener(-1) { @Override public void on(PluginEvent event) { - - refreshNorthEastPane(northEastPane, ad); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (DesignerContext.getDesignerFrame() == null) { - return; - } - DesignerContext.getDesignerFrame().refresh(); - DesignerContext.getDesignerFrame().repaint(); - } - }); + refreshAll(northEastPane, ad); } - }, new PluginFilter() { + }; + // 在设计器启动时仅在最后一个插件启用时候进行刷新一次 如果插件启用过程中存在实现了设计器接口的插件 + PluginEventListener afterAllPluginsActiveListener = new PluginEventListener() { + @Override + public void on(PluginEvent event) { + //优先级为-1,保证最后全面刷新一次 + GeneralContext.listenPluginRunningChanged(pluginOnRunOrStopListener, pluginFilter); + // 在设计器启动时仅在最后一个插件启用时候进行刷新一次 如果插件启用过程中存在实现了设计器接口的插件 + boolean needRefresh = DesignerContext.getDesignerFrame() != null && DesignerContext.getDesignerFrame().isVisible() && existDesignExtraPlugin; + if (needRefresh) { + refreshAll(northEastPane, ad); + } + } + }; + PluginEventListener beforeAllPluginStopListener = new PluginEventListener() { + @Override + public void on(PluginEvent event) { + PluginListenerRegistration.getInstance().stopListen(pluginOnRunOrStopListener); + } + }; + PluginEventListener pluginEventListener = new PluginEventListener() { @Override - public boolean accept(PluginContext context) { + public void on(PluginEvent event) { + existDesignExtraPlugin = true; + } + }; + GeneralContext.listenPluginRunningChanged(pluginEventListener, pluginFilter); + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterAllActive, afterAllPluginsActiveListener); + PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllStop, beforeAllPluginStopListener); - return context.contain(PluginModule.ExtraDesign); + } + + private void refreshAll(JPanel northEastPane, ToolBarMenuDock ad) { + refreshNorthEastPane(northEastPane, ad); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (DesignerContext.getDesignerFrame() == null) { + return; + } + DesignerContext.getDesignerFrame().refresh(); + DesignerContext.getDesignerFrame().repaint(); } }); - refreshNorthEastPane(northEastPane, ad); - return northEastPane; } private void refreshNorthEastPane(final JPanel northEastPane, final ToolBarMenuDock ad) { From 793caec8900b40ee63f4c9c597273d2c3b050090 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 21 Oct 2021 15:51:30 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-60253=20=E5=AE=89=E8=A3=85=E5=A4=A7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E5=AF=BC=E5=87=BA=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=A8=A1=E6=9D=BF=E4=BB=8E=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=B0=E8=BF=9C=E7=A8=8B=EF=BC=8C=E5=86=8D?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=B0=E6=9C=AC=E5=9C=B0=EF=BC=8C=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E4=BF=9D=E5=AD=98=E6=A8=A1=E6=9D=BF=E4=BC=9A=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=20=E4=BF=9D=E5=AD=98=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?=E6=9C=89npe=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/JTemplate.java | 4 +++- .../main/java/com/fr/design/mainframe/JTemplateFactory.java | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index f2e3470a8..1ccc07303 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -381,7 +381,9 @@ public abstract class JTemplate> */ @Deprecated public void refreshResource() { - refreshResource(this.editingFILE); + if (JTemplateFactory.isAvailable()) { + refreshResource(this.editingFILE); + } } public void refreshResource(FILE file) { diff --git a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java index 5e75cc64b..9aa8204d6 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplateFactory.java @@ -93,4 +93,7 @@ public final class JTemplateFactory { ALL_APP.remove(app); } } -} \ No newline at end of file + + public static boolean isAvailable() { + return !ALL_APP.isEmpty(); + }} \ No newline at end of file From c43a01c40c3b87a17c868aa157d4bfd112727566 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 21 Oct 2021 16:33:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-61356=20=20fix=20=E7=BB=9F=E4=B8=80a?= =?UTF-8?q?pi=E4=BD=BF=E7=94=A8=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/mainframe/NorthRegionContainerPane.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java index 05198ba0e..91899e5b5 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/NorthRegionContainerPane.java @@ -18,7 +18,6 @@ import com.fr.plugin.manage.PluginFilter; import com.fr.plugin.observer.PluginEvent; import com.fr.plugin.observer.PluginEventListener; import com.fr.plugin.observer.PluginEventType; -import com.fr.plugin.observer.PluginListenerRegistration; import com.fr.stable.os.support.OSBasedAction; import com.fr.stable.os.support.OSSupportCenter; @@ -110,7 +109,7 @@ public class NorthRegionContainerPane extends JPanel { PluginEventListener beforeAllPluginStopListener = new PluginEventListener() { @Override public void on(PluginEvent event) { - PluginListenerRegistration.getInstance().stopListen(pluginOnRunOrStopListener); + GeneralContext.stopListenPlugin(pluginOnRunOrStopListener); } }; PluginEventListener pluginEventListener = new PluginEventListener() { @@ -120,8 +119,8 @@ public class NorthRegionContainerPane extends JPanel { } }; GeneralContext.listenPluginRunningChanged(pluginEventListener, pluginFilter); - PluginListenerRegistration.getInstance().listen(PluginEventType.AfterAllActive, afterAllPluginsActiveListener); - PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllStop, beforeAllPluginStopListener); + GeneralContext.listenPlugin(PluginEventType.AfterAllActive, afterAllPluginsActiveListener); + GeneralContext.listenPlugin(PluginEventType.BeforeAllStop, beforeAllPluginStopListener); }