Browse Source

Merge pull request #875 in DESIGN/design from ~YAOH.WU/design:REPORT-16894 to release/10.0

* commit 'c997a9c3329e25a4f01dd923cb7ab965b5831d91':
  REPORT-16894 远程设计报错完善
bugfix/10.0
yaoh.wu 6 years ago
parent
commit
bc6ea61a93
  1. 4
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 26
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  3. 74
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java

4
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -22,9 +22,9 @@ import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback; import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace; import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@ -120,7 +120,7 @@ public class EnvChangeEntrance {
} }
}); });
} catch (AuthException | RegistEditionException e) { } catch (WorkspaceAuthException | RegistEditionException e) {
// String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
// String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote");
strategy.showTip(new PopTip() { strategy.showTip(new PopTip() {

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

@ -19,8 +19,8 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.guava.base.Strings; import com.fr.third.guava.base.Strings;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.exception.WorkspaceAuthException;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.BoxLayout; import javax.swing.BoxLayout;
@ -523,7 +523,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey()); DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try { try {
return WorkContext.getConnector().testConnection(connection); return WorkContext.getConnector().testConnection(connection);
} catch (AuthException ignored) { } catch (WorkspaceAuthException ignored) {
return null; return null;
} }
} }
@ -532,27 +532,9 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
protected void done() { protected void done() {
okButton.setEnabled(true); okButton.setEnabled(true);
try { try {
TestConnectionResult result = TestConnectionResult.parse(get(), connection); TestConnectionResult result = TestConnectionResult.parse(get(), connection);
if (result == TestConnectionResult.Fully_Success) { message.setText(result.getText());
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful")); uiLabel.setIcon(result.getIcon());
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
}
if (result == TestConnectionResult.Partly_Sucess) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistence_Test"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
}
if (result == TestConnectionResult.Fully_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
}
if (result == TestConnectionResult.Auth_Failed) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
}
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed")); message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));

74
designer-base/src/main/java/com/fr/env/TestConnectionResult.java vendored

@ -1,62 +1,104 @@
package com.fr.env; package com.fr.env;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest; import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import javax.swing.Icon;
import javax.swing.UIManager;
/** /**
* 测试连接的结果 * 测试连接的结果
* 不改变原有逻辑的情况下加入一层转化 * 不改变原有逻辑的情况下加入一层转化
* 根据这里的转化结果判断需要提示哪些内容 * 根据这里的转化结果判断需要提示哪些内容
* * <p>
* created by Harrison on 2018/12/20 * created by Harrison on 2018/12/20
**/ **/
public enum TestConnectionResult { public enum TestConnectionResult {
/** /**
* 完全成功, 版本匹配测试连接成功 * 完全成功, 版本匹配测试连接成功
*/ */
Fully_Success, FULLY_SUCCESS {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.informationIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful");
}
},
/** /**
* 不完全成功版本不匹配但测试连接成功 * 不完全成功版本不匹配但测试连接成功
*/ */
Partly_Sucess, PARTLY_SUCCESS {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.warningIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistence_Test");
}
},
/** /**
* 完全失败直接没连上 * 完全失败直接没连上
*/ */
Fully_Failed, FULLY_FAILED {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.errorIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed");
}
},
/** /**
* 验证 Token 失败 * 验证 Token 失败
*/ */
Auth_Failed; AUTH_FAILED {
@Override
public Icon getIcon() {
return UIManager.getIcon("OptionPane.errorIcon");
}
@Override
public String getText() {
return Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed");
}
};
public abstract Icon getIcon();
public abstract String getText();
public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) { public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) {
if (value == null) { if (value == null) {
return Auth_Failed; return AUTH_FAILED;
} }
if (!value) { if (!value) {
return Fully_Failed; return FULLY_FAILED;
} }
try { try {
String serverVersion = new FunctionalHttpRequest(info).getServerVersion(); String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) { if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return Fully_Success; return FULLY_SUCCESS;
} }
return PARTLY_SUCCESS;
return Partly_Sucess;
} catch (Exception e) { } catch (Exception e) {
// 发生异常,说明没连接上。返回完全失败。 // 发生异常,说明没连接上。返回完全失败。
FineLoggerFactory.getLogger().error(e.getMessage()); FineLoggerFactory.getLogger().error(e.getMessage());
return Fully_Failed; return FULLY_FAILED;
} }
} }
} }

Loading…
Cancel
Save