From 2cafff639d7c0a50e97dea693b14ba31bd55c2b1 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 1 Jul 2021 16:32:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-53699=20=E5=90=AF=E5=8A=A8=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E6=97=B6=E6=A8=A1=E6=9D=BF=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=9C=AA=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/app/DesignerAppUtils.java | 22 ++++++++++++++++++- .../start/module/DesignerInitActivator.java | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) 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 index 4680a8a258..a00e7dd6fc 100644 --- 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 @@ -16,6 +16,10 @@ import com.fr.plugin.manage.PluginManager; import com.fr.plugin.manage.control.PluginControllerHelper; import com.fr.plugin.manage.control.PluginExtraInfo; import com.fr.plugin.manage.control.PluginTask; +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.StringUtils; import com.fr.stable.TemplateIOErrorContextHolder; import com.fr.third.guava.cache.Cache; @@ -39,6 +43,7 @@ public class DesignerAppUtils { private static final int DEFAULT_MAX_CACHE_SIZE = 50; private static final int DEFAULT_CONCURRENCY_LEVEL = 8; private static final long DEFAULT_EXPIRE_HOURS = 1; + private static boolean enablePluginTipDialog = true; private static final Cache> ERROR_CACHE = CacheBuilder.newBuilder() .maximumSize(DEFAULT_MAX_CACHE_SIZE) @@ -46,6 +51,21 @@ public class DesignerAppUtils { .concurrencyLevel(DEFAULT_CONCURRENCY_LEVEL) .build(); + public static void initPluginAllActiveListener() { + PluginListenerRegistration.getInstance().listen(PluginEventType.BeforeAllActive, new PluginEventListener() { + @Override + public void on(PluginEvent event) { + enablePluginTipDialog = false; + } + }); + PluginListenerRegistration.getInstance().listen(PluginEventType.AfterAllActive, new PluginEventListener() { + @Override + public void on(PluginEvent event) { + enablePluginTipDialog = true; + } + }); + } + /** * 弹出指定的插件信息, * 并失效缓存 @@ -77,7 +97,7 @@ public class DesignerAppUtils { * @return 格式化后的多行插件错误信息详情 */ public static String dealWithErrorDetailMultiLineAndCache(String key) { - if (!DesignerEnvManager.getEnvManager().isShowTemplateMissingPlugin()) { + if (!DesignerEnvManager.getEnvManager().isShowTemplateMissingPlugin() || !enablePluginTipDialog) { // 直接清空不提示 TemplateIOErrorContextHolder.reset(); return StringUtils.EMPTY; diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java index ebea410bba..1c8fee3793 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerInitActivator.java @@ -1,6 +1,7 @@ package com.fr.start.module; import com.fr.design.PluginClassRefreshManager; +import com.fr.design.mainframe.app.DesignerAppUtils; import com.fr.module.Activator; import com.fr.start.DesignerInitial; @@ -17,6 +18,7 @@ public class DesignerInitActivator extends Activator { @Override public void start() { PluginClassRefreshManager.getInstance().load(); + DesignerAppUtils.initPluginAllActiveListener(); DesignerInitial.init(findSingleton(StartupArgs.class).get()); } From faf18938f45d54cdb2cd3ec5e7c87b3f531c8bab Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 1 Jul 2021 17:43:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-54643=20=E6=9C=80=E6=96=B0=E7=9A=84p?= =?UTF-8?q?ersist=E5=88=86=E6=94=AF=E5=AE=89=E8=A3=85=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=86=85=E5=AD=98=E7=9B=91=E6=8E=A7=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E4=B8=94=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/DesignerFrame.java | 15 ++++ .../design/mainframe/SafeWindowListener.java | 84 +++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/SafeWindowListener.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 25948b62cf..01a7defb2e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -535,6 +535,21 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta } } + @Override + public synchronized void addWindowListener(WindowListener l) { + SafeWindowListener safeWindowListener = new SafeWindowListener(l); + map.put(l, safeWindowListener); + super.addWindowListener(safeWindowListener); + } + + @Override + public synchronized void removeWindowListener(WindowListener l) { + SafeWindowListener safeWindowListener = map.remove(l); + if (safeWindowListener != null) { + super.removeWindowListener(safeWindowListener); + } + } + private void addMacOsListener() { OSSupportCenter.buildAction(new MacOsAddListenerAction(), SupportOSImpl.DOCK_QUIT); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/SafeWindowListener.java b/designer-base/src/main/java/com/fr/design/mainframe/SafeWindowListener.java new file mode 100644 index 0000000000..d88eccfa72 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/SafeWindowListener.java @@ -0,0 +1,84 @@ +package com.fr.design.mainframe; + +import com.fr.log.FineLoggerFactory; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +/** + * 保证监听运行出错也不影响其他功能正常使用 + * + * @author hades + * @version 10.0 + * Created by hades on 2021/6/30 + */ +public class SafeWindowListener implements WindowListener { + + private final WindowListener windowListener; + + public SafeWindowListener(WindowListener windowListener) { + this.windowListener = windowListener; + } + + @Override + public void windowOpened(WindowEvent e) { + try { + windowListener.windowOpened(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } + + @Override + public void windowClosing(WindowEvent e) { + try { + windowListener.windowClosing(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } + + @Override + public void windowClosed(WindowEvent e) { + try { + windowListener.windowClosed(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } + + @Override + public void windowIconified(WindowEvent e) { + try { + windowListener.windowIconified(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } + + @Override + public void windowDeiconified(WindowEvent e) { + try { + windowListener.windowDeiconified(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } + + @Override + public void windowActivated(WindowEvent e) { + try { + windowListener.windowActivated(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } + + @Override + public void windowDeactivated(WindowEvent e) { + try { + windowListener.windowDeactivated(e); + } catch (Throwable throwable) { + FineLoggerFactory.getLogger().debug(throwable.getMessage(), throwable); + } + } +} \ No newline at end of file From 0cf20157c18cccf246f56209acccbcf65a9f62c6 Mon Sep 17 00:00:00 2001 From: hades Date: Thu, 1 Jul 2021 18:46:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-54643=20=E6=9C=80=E6=96=B0=E7=9A=84p?= =?UTF-8?q?ersist=E5=88=86=E6=94=AF=E5=AE=89=E8=A3=85=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=86=85=E5=AD=98=E7=9B=91=E6=8E=A7=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E4=B8=94=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=97=A0=E6=B3=95=E7=BC=96=E8=BE=91=20=20=E6=BC=8F?= =?UTF-8?q?=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/mainframe/DesignerFrame.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java index 01a7defb2e..890b6fa04b 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java @@ -72,6 +72,8 @@ import com.fr.start.OemHandler; import com.fr.workspace.WorkContext; import com.fr.workspace.Workspace; import com.fr.workspace.connect.WorkspaceConnectionInfo; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; import org.jetbrains.annotations.Nullable; @@ -179,6 +181,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta private int contentHeight = (int) (java.awt.Toolkit.getDefaultToolkit().getScreenSize().getHeight()); + private Map map = new HashMap<>(); + private WindowAdapter windowAdapter = new WindowAdapter() { @Override