From 7268eacb44028581cf038679880e834ad3f85a4d Mon Sep 17 00:00:00 2001 From: hades Date: Wed, 11 Aug 2021 14:14:02 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55795=20=E3=80=9010.0.19=E3=80=91?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E8=A7=84=E8=8C=83=E2=80=94=E2=80=94=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=99=A8=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E9=83=A8=E5=88=86=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 2 -- .../src/main/java/com/fr/env/HelpLink.java | 14 ++-------- .../main/java/com/fr/env/RemoteEnvPane.java | 3 +- .../java/com/fr/env/handler/RefWrapper.java | 28 +++++++++++++++++++ .../handler/RemoteDesignExceptionHandler.java | 20 +++++++------ .../fr/env/handler/impl/CancelHandler.java | 6 ++-- .../fr/env/handler/impl/CommonHandler.java | 11 +++++--- .../fr/env/handler/impl/ExecutionHandler.java | 8 ++++-- .../env/handler/impl/UnexpectedHandler.java | 6 ++-- 9 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/env/handler/RefWrapper.java diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 606013ed1..785f3b92b 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -20,7 +20,6 @@ import com.fr.design.notification.NotificationCenter; import com.fr.design.utils.DesignUtils; import com.fr.design.versioncheck.VersionCheckUtils; import com.fr.env.EnvListPane; -import com.fr.env.HelpLink; import com.fr.env.handler.RemoteDesignExceptionHandler; import com.fr.exit.DesignerExiter; import com.fr.general.GeneralUtils; @@ -140,7 +139,6 @@ public class EnvChangeEntrance { pluginErrorRemind(); } catch (Exception exception) { // 失败的处理 - HelpLink.setConnectionInfo(connectionInfo); RemoteDesignExceptionHandler.getInstance().handleInSwitch(exception, selectedEnv); return false; } diff --git a/designer-base/src/main/java/com/fr/env/HelpLink.java b/designer-base/src/main/java/com/fr/env/HelpLink.java index dda75a924..c717ce6ea 100644 --- a/designer-base/src/main/java/com/fr/env/HelpLink.java +++ b/designer-base/src/main/java/com/fr/env/HelpLink.java @@ -1,11 +1,9 @@ package com.fr.env; -import com.fr.design.DesignerEnvManager; -import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.general.locale.LocaleCenter; import com.fr.general.locale.LocaleMark; import com.fr.locale.InterProviderFactory; -import com.fr.workspace.connect.WorkspaceConnectionInfo; +import com.fr.stable.StringUtils; import java.util.HashMap; import java.util.Map; @@ -18,23 +16,15 @@ import java.util.Map; */ public class HelpLink { - private static WorkspaceConnectionInfo connectionInfo; - public static String getLink(String solution) { Map map = new HashMap<>(); - String currentName = DesignerEnvManager.getEnvManager().getCurEnvName(); - DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName); LocaleMark linkMark = LocaleCenter.getMark(RemoteDesignLocaleMark.class); String link = linkMark.getValue(); - String url = connectionInfo == null ? workspaceInfo.getConnection().getUrl() : connectionInfo.getUrl(); - map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), url + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH); + map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), StringUtils.EMPTY); map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Cert_Error_Solution"), link); map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Connection_Unknown_Error_Solution"), link); map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_NetWork_Connection_Error_Solution"), link); return map.get(solution); } - public static void setConnectionInfo(WorkspaceConnectionInfo connectionInfo) { - HelpLink.connectionInfo = connectionInfo; - } } diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 6d34cd7c0..17dc72dba 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -596,8 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane { } } catch (Exception e) { dialog.dispose(); - HelpLink.setConnectionInfo(connection); - RemoteDesignExceptionHandler.getInstance().handleInTest(e); + RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv); } dialogDownPane.remove(cancelButton); dialogDownPane.revalidate(); diff --git a/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java b/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java new file mode 100644 index 000000000..a2db84d23 --- /dev/null +++ b/designer-base/src/main/java/com/fr/env/handler/RefWrapper.java @@ -0,0 +1,28 @@ +package com.fr.env.handler; + +/** + * + * @author hades + * @version 10.0 + * Created by hades on 2021/8/11 + */ +public class RefWrapper { + + private final Throwable throwable; + + private final String link; + + + public RefWrapper(Throwable throwable, String link) { + this.throwable = throwable; + this.link = link; + } + + public Throwable getThrowable() { + return throwable; + } + + public String getLink() { + return link; + } +} diff --git a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java b/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java index 81d10611f..7e6154eee 100644 --- a/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java @@ -5,6 +5,7 @@ import com.fr.design.dialog.FineJOptionPane; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.i18n.Toolkit; +import com.fr.env.RemoteWorkspaceURL; import com.fr.env.handler.impl.CancelHandler; import com.fr.env.handler.impl.CommonHandler; import com.fr.env.handler.impl.ExecutionHandler; @@ -30,9 +31,9 @@ public class RemoteDesignExceptionHandler { return INSTANCE; } - private final List> testList = new ArrayList<>(); + private final List> testList = new ArrayList<>(); - private final List> switchList = new ArrayList<>(); + private final List> switchList = new ArrayList<>(); private RemoteDesignExceptionHandler() { // 要保证顺序 @@ -47,11 +48,12 @@ public class RemoteDesignExceptionHandler { switchList.add(new CommonHandler(true)); } - public void handle(Throwable e, List> list) { + public void handle(Throwable e, List> list, DesignerWorkspaceInfo workspaceInfo) { Throwable throwable = e; ResultWrapper wrapper; - for (Handler handler : list) { - wrapper = handler.handle(throwable); + String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH; + for (Handler handler : list) { + wrapper = handler.handle(new RefWrapper(throwable, link)); throwable = wrapper.getThrowable(); if (!wrapper.isNext()) { break; @@ -70,7 +72,7 @@ public class RemoteDesignExceptionHandler { UIManager.getIcon("OptionPane.errorIcon")); return; } - handle(e, switchList); + handle(e, switchList, workspaceInfo); } public void handleInStart(Throwable e, DesignerWorkspaceInfo workspaceInfo) { @@ -78,11 +80,11 @@ public class RemoteDesignExceptionHandler { FineLoggerFactory.getLogger().error(e.getMessage(), e); return; } - handle(e, testList); + handle(e, testList, workspaceInfo); } - public void handleInTest(Throwable e) { - handle(e, testList); + public void handleInTest(Throwable e, DesignerWorkspaceInfo workspaceInfo) { + handle(e, testList, workspaceInfo); } } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java index dc36cb4db..140d0ec13 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java @@ -1,6 +1,7 @@ package com.fr.env.handler.impl; import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; import com.fr.env.handler.ResultWrapper; import java.util.concurrent.CancellationException; @@ -11,10 +12,11 @@ import java.util.concurrent.CancellationException; * @version 10.0 * Created by hades on 2021/8/5 */ -public class CancelHandler implements Handler { +public class CancelHandler implements Handler { @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); return new ResultWrapper(!(e instanceof CancellationException), e); } } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java index dd6a1e52e..2fc8f9e15 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java @@ -7,7 +7,9 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.env.HelpLink; import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; import com.fr.env.handler.ResultWrapper; +import com.fr.stable.StringUtils; import javax.swing.SwingUtilities; /** @@ -15,7 +17,7 @@ import javax.swing.SwingUtilities; * @version 10.0 * Created by hades on 2021/8/5 */ -public class CommonHandler implements Handler { +public class CommonHandler implements Handler { private final boolean onSwitch; @@ -24,12 +26,14 @@ public class CommonHandler implements Handler { } @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); if (e instanceof ExceptionDescriptor) { ExceptionDescriptor exceptionDescriptor = (ExceptionDescriptor) e; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { + String link = HelpLink.getLink(exceptionDescriptor.solution()); UIDetailErrorLinkDialog detailErrorLinkDialog = UIDetailErrorLinkDialog.newBuilder(). setWindow(onSwitch ? DesignerContext.getDesignerFrame() : EnvChangeEntrance.getInstance().getDialog()). setErrorCode(exceptionDescriptor.errorCode()). @@ -37,10 +41,9 @@ public class CommonHandler implements Handler { setSolution(exceptionDescriptor.solution()). setDetailReason(exceptionDescriptor.detailReason()). setTitle(Toolkit.i18nText("Fine-Design_Basic_Connection_Failed")). - setLink(HelpLink.getLink(exceptionDescriptor.solution())). + setLink(StringUtils.isEmpty(link) ? wrapper.getLink() : link). setThrowable(e).build(); detailErrorLinkDialog.setVisible(true); - HelpLink.setConnectionInfo(null); } }); } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java index 67adf2354..5388935ea 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java @@ -1,6 +1,7 @@ package com.fr.env.handler.impl; import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; import com.fr.env.handler.ResultWrapper; import java.util.concurrent.ExecutionException; @@ -9,13 +10,14 @@ import java.util.concurrent.ExecutionException; * @version 10.0 * Created by hades on 2021/8/5 */ -public class ExecutionHandler implements Handler { +public class ExecutionHandler implements Handler { @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); if (e instanceof ExecutionException) { return new ResultWrapper(e.getCause()); } - return new ResultWrapper(e.getCause()); + return new ResultWrapper(e); } } diff --git a/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java index 5a47e7de5..28a2b645d 100644 --- a/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java +++ b/designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java @@ -2,6 +2,7 @@ package com.fr.env.handler.impl; import com.fr.base.exception.ExceptionDescriptor; import com.fr.env.handler.Handler; +import com.fr.env.handler.RefWrapper; import com.fr.env.handler.ResultWrapper; import com.fr.workspace.engine.convert.ExceptionConverter; @@ -12,10 +13,11 @@ import com.fr.workspace.engine.convert.ExceptionConverter; * @version 10.0 * Created by hades on 2021/8/5 */ -public class UnexpectedHandler implements Handler { +public class UnexpectedHandler implements Handler { @Override - public ResultWrapper handle(Throwable e) { + public ResultWrapper handle(RefWrapper wrapper) { + Throwable e = wrapper.getThrowable(); if (!(e instanceof ExceptionDescriptor)) { return new ResultWrapper(ExceptionConverter.getInstance().convert(e)) ; }