Browse Source

REPORT-55795 【10.0.19】报错规范——设计器远程设计连接部分 fix

feature/10.0
hades 3 years ago
parent
commit
7268eacb44
  1. 2
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 14
      designer-base/src/main/java/com/fr/env/HelpLink.java
  3. 3
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  4. 28
      designer-base/src/main/java/com/fr/env/handler/RefWrapper.java
  5. 20
      designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java
  6. 6
      designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java
  7. 11
      designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java
  8. 8
      designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java
  9. 6
      designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java

2
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;
}

14
designer-base/src/main/java/com/fr/env/HelpLink.java vendored

@ -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<String, String> map = new HashMap<>();
String currentName = DesignerEnvManager.getEnvManager().getCurEnvName();
DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(currentName);
LocaleMark<String> 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;
}
}

3
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -596,8 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
} catch (Exception e) {
dialog.dispose();
HelpLink.setConnectionInfo(connection);
RemoteDesignExceptionHandler.getInstance().handleInTest(e);
RemoteDesignExceptionHandler.getInstance().handleInTest(e, remoteEnv);
}
dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate();

28
designer-base/src/main/java/com/fr/env/handler/RefWrapper.java vendored

@ -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;
}
}

20
designer-base/src/main/java/com/fr/env/handler/RemoteDesignExceptionHandler.java vendored

@ -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<Handler<Throwable, ResultWrapper>> testList = new ArrayList<>();
private final List<Handler<RefWrapper, ResultWrapper>> testList = new ArrayList<>();
private final List<Handler<Throwable, ResultWrapper>> switchList = new ArrayList<>();
private final List<Handler<RefWrapper, ResultWrapper>> switchList = new ArrayList<>();
private RemoteDesignExceptionHandler() {
// 要保证顺序
@ -47,11 +48,12 @@ public class RemoteDesignExceptionHandler {
switchList.add(new CommonHandler(true));
}
public void handle(Throwable e, List<Handler<Throwable, ResultWrapper>> list) {
public void handle(Throwable e, List<Handler<RefWrapper, ResultWrapper>> list, DesignerWorkspaceInfo workspaceInfo) {
Throwable throwable = e;
ResultWrapper wrapper;
for (Handler<Throwable, ResultWrapper> handler : list) {
wrapper = handler.handle(throwable);
String link = workspaceInfo.getConnection().getUrl() + RemoteWorkspaceURL.SYSTEM_LOGIN_PATH;
for (Handler<RefWrapper, ResultWrapper> 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);
}
}

6
designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java vendored

@ -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<Throwable, ResultWrapper> {
public class CancelHandler implements Handler<RefWrapper, ResultWrapper> {
@Override
public ResultWrapper handle(Throwable e) {
public ResultWrapper handle(RefWrapper wrapper) {
Throwable e = wrapper.getThrowable();
return new ResultWrapper(!(e instanceof CancellationException), e);
}
}

11
designer-base/src/main/java/com/fr/env/handler/impl/CommonHandler.java vendored

@ -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<Throwable, ResultWrapper> {
public class CommonHandler implements Handler<RefWrapper, ResultWrapper> {
private final boolean onSwitch;
@ -24,12 +26,14 @@ public class CommonHandler implements Handler<Throwable, ResultWrapper> {
}
@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<Throwable, ResultWrapper> {
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);
}
});
}

8
designer-base/src/main/java/com/fr/env/handler/impl/ExecutionHandler.java vendored

@ -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<Throwable, ResultWrapper> {
public class ExecutionHandler implements Handler<RefWrapper, ResultWrapper> {
@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);
}
}

6
designer-base/src/main/java/com/fr/env/handler/impl/UnexpectedHandler.java vendored

@ -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<Throwable, ResultWrapper> {
public class UnexpectedHandler implements Handler<RefWrapper, ResultWrapper> {
@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)) ;
}

Loading…
Cancel
Save