Browse Source

Pull request #5321: REPORT-55795 【10.0.19】报错规范——设计器远程设计连接部分

Merge in DESIGN/design from ~HADES/design:feature/10.0 to feature/10.0

* commit '7268eacb44028581cf038679880e834ad3f85a4d':
  REPORT-55795 【10.0.19】报错规范——设计器远程设计连接部分 fix
  REPORT-55795 【10.0.19】报错规范——设计器远程设计连接部分
feature/10.0
Hades 3 years ago
parent
commit
e0b5574335
  1. 14
      designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java
  2. 10
      designer-base/src/main/java/com/fr/env/HelpLink.java
  3. 2
      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. 8
      designer-base/src/main/java/com/fr/env/handler/impl/CancelHandler.java
  7. 10
      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

14
designer-base/src/main/java/com/fr/design/dialog/UIDetailErrorLinkDialog.java

@ -44,6 +44,7 @@ public class UIDetailErrorLinkDialog extends UIDialog {
private static final int GAP_10 = 10;
private static final String TAG_A_START = "<a>";
private static final String TAG_A_END = "</a>";
private static final double SCALE = 1.2;
private final Dimension dimension = new Dimension(300, 180);
@ -99,6 +100,7 @@ public class UIDetailErrorLinkDialog extends UIDialog {
this.getContentPane().add(actionPane, BorderLayout.SOUTH);
this.setSize(dimension);
this.setResizable(false);
this.setModal(true);
GUICoreUtils.centerWindow(this);
}
@ -139,11 +141,21 @@ public class UIDetailErrorLinkDialog extends UIDialog {
UILabel solutionLabel = new UILabel(solution);
panel.add(solutionLabel, BorderLayout.CENTER);
}
dimension.width = Math.max(maxWidth, GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont()));
dimension.width = getMaxDimensionWidth(maxWidth, solution);
return panel;
}
private int getMaxDimensionWidth(int width, String solution) {
int maxWidth = GraphHelper.getWidth(solution, DesignUtils.getDefaultGUIFont());
if (maxWidth >= width) {
maxWidth = (int) (SCALE * maxWidth);
} else {
maxWidth = width;
}
return maxWidth;
}
@Override
public void checkValid() throws Exception {
// do nothing

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

@ -1,14 +1,15 @@
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.stable.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 错误提示中的跳转链接管理
*
* @author hades
* @version 10.0
* Created by hades on 2021/8/9
@ -17,16 +18,13 @@ public class HelpLink {
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();
map.put(InterProviderFactory.getProvider().getLocText("Fine-Core_Remote_Design_Change_PassWord"), workspaceInfo.getConnection().getUrl() + 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);
}
}

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

@ -596,7 +596,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
} catch (Exception e) {
dialog.dispose();
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);
}
}

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

@ -1,18 +1,22 @@
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;
/**
* 取消测试连接时的处理器
*
* @author hades
* @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);
}
}

10
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,7 +41,7 @@ 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);
}

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