Browse Source

REPORT-13074 远程设计向下兼容

1. 加入序列化异常 SerilizationException , WorkspaceNoteHitException
2. 加入切换远程连接的检测,以及测试远程连接的提醒。
bugfix/10.0
Harrison 6 years ago
parent
commit
ba5b8fe167
  1. 46
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 31
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  3. 55
      designer-base/src/main/java/com/fr/env/TestConnectionResult.java

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

@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.i18n.Toolkit;
@ -15,19 +16,25 @@ import com.fr.env.EnvListPane;
import com.fr.general.GeneralContext;
import com.fr.license.exception.RegistEditionException;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static javax.swing.JOptionPane.ERROR_MESSAGE;
import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance {
@ -90,6 +97,11 @@ public class EnvChangeEntrance {
});
return false;
}
if (versionCheck(selectedEnv)) {
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
@ -138,6 +150,40 @@ public class EnvChangeEntrance {
return true;
}
/**
* 切换环境之前进行版本检测当版本不一致的时候提示
* 当选择 ok 才继续
*
* @param selectedEnv 选择的环境
* @return 是否一致
* @throws Exception 异常
*/
private boolean versionCheck(DesignerWorkspaceInfo selectedEnv) throws Exception {
if (selectedEnv.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo info = selectedEnv.getConnection();
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (!AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
final List<Integer> result = new ArrayList<>(1);
PopTipStrategy.NOW.showTip(new PopTip() {
@Override
public void show() {
String[] option = {Toolkit.i18nText("Fine-Design_Report_Yes"), Toolkit.i18nText("Fine-Design_Report_No")};
int choice = JOptionPane.showOptionDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistency"),
UIManager.getString("OptionPane.messageDialogTitle"), JOptionPane.YES_NO_OPTION, QUESTION_MESSAGE, UIManager.getIcon("OptionPane.warningIcon"), option, 1);
result.add(choice);
}
});
return result.size() != 0 && result.get(0) == 1;
}
}
return false;
}
/**
* 编辑items
*

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

@ -511,14 +511,14 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
}
private void tryConnectRemoteEnv() {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
final WorkspaceConnectionInfo connection = remoteEnv.getConnection();
final SwingWorker<Boolean, Void> worker = new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
final RemoteDesignerWorkspaceInfo remoteEnv = updateBean();
WorkspaceConnectionInfo connection = remoteEnv.getConnection();
DesignerEnvManager.getEnvManager().setCertificatePath(connection.getCertPath());
DesignerEnvManager.getEnvManager().setCertificatePass(connection.getCertSecretKey());
try {
@ -532,23 +532,33 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
protected void done() {
okButton.setEnabled(true);
try {
Boolean result = get();
if (result == null) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} else {
if (result) {
TestConnectionResult result = TestConnectionResult.parse(get(), connection);
if (result == TestConnectionResult.Fully_Success) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Successful"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
} else {
}
if (result == TestConnectionResult.Partly_Sucess) {
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Version_Inconsistency"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.informationIcon"));
}
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) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
message.setText(Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Failed"));
uiLabel.setIcon(UIManager.getIcon("OptionPane.errorIcon"));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage());
}
dialogDownPane.remove(cancelButton);
dialogDownPane.revalidate();
@ -596,6 +606,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
dialogDownPane = new JPanel();
uiLabel = new UILabel(UIManager.getIcon("OptionPane.informationIcon"));
upPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
//upPane.setLayout(new BorderLayout());
upPane.add(uiLabel);
upPane.add(message);
dialogDownPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0));

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

@ -0,0 +1,55 @@
package com.fr.env;
import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
/**
* created by Harrison on 2018/12/20
**/
public enum TestConnectionResult {
/**
* 完全成功, 版本匹配测试连接成功
*/
Fully_Success(0),
/**
* 不完全成功版本不匹配但测试连接成功
*/
Partly_Sucess(1),
/**
* 完全失败直接没连上
*/
Fully_Failed(2),
/**
* 验证 Token 失败
*/
Auth_Failed(3);
private int sign;
TestConnectionResult(int i) {
this.sign = i;
}
public static TestConnectionResult parse(Boolean value, WorkspaceConnectionInfo info) throws Exception {
if (value == null) {
return Auth_Failed;
}
if (!value) {
return Fully_Failed;
}
String serverVersion = new FunctionalHttpRequest(info).getServerVersion();
if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) {
return Fully_Success;
}
return Partly_Sucess;
}
}
Loading…
Cancel
Save