Browse Source

REPORT-9712 切换远程服务器失败后,再启动平台起不来

master
ju 6 years ago
parent
commit
24743dbf2b
  1. 36
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  2. 18
      designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java
  3. 19
      designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

36
designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java

@ -22,7 +22,7 @@ import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.AuthException;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Iterator;
@ -107,28 +107,28 @@ public class SwitchExistEnv extends MenuDef {
Workspace workspace;
try {
workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}));
return;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
fireDSChanged();
}
});
} catch (AuthException exception) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"Fine-Designer_Basic_Remote_Connect_Auth_Failed"}));
return;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void success() {
DesignerEnvManager.getEnvManager().setCurEnvName(envName);
DesignUtils.refreshDesignerFrame();
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().refreshToolArea();
fireDSChanged();
}
@Override
public void fail() {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}));
}
});
}
}
}

18
designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java vendored

@ -1,11 +1,12 @@
package com.fr.design.env;
import com.fr.workspace.server.authority.decision.DecisionOperator;
import com.fr.locale.InterProviderFactory;
import com.fr.stable.AssistUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.Workspace;
import com.fr.workspace.connect.WorkspaceClient;
import com.fr.workspace.connect.WorkspaceConnection;
import com.fr.workspace.server.authority.decision.DecisionOperator;
/**
* Created by juhaoyu on 2018/6/14.
@ -17,10 +18,13 @@ public class RemoteWorkspace implements Workspace {
private final String address;
private final WorkspaceConnection connection;
RemoteWorkspace(WorkspaceClient client, WorkspaceConnection connection) {
this.client = client;
this.address = connection.getUrl();
this.connection = connection;
}
@Override
@ -61,4 +65,16 @@ public class RemoteWorkspace implements Workspace {
return client.getPool().get(type);
}
@Override
public int hashCode() {
return connection.hashCode();
}
@Override
public boolean equals(Object obj) {
return obj != null && obj instanceof RemoteWorkspace && AssistUtils.equals(((RemoteWorkspace) obj).connection, this.connection);
}
}

19
designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java

@ -19,6 +19,7 @@ import com.fr.general.Inter;
import com.fr.stable.EnvChangedListener;
import com.fr.workspace.WorkContext;
import com.fr.workspace.WorkContextCallback;
import com.fr.workspace.Workspace;
import javax.swing.*;
import java.awt.*;
@ -132,17 +133,17 @@ public class TemplatePane extends JPanel implements MouseListener {
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(selectedName);
GeneralContext.fireEnvWillChangeListener();
try {
WorkContext.switchTo(DesignerWorkspaceGenerator.generate(selectedEnv), new WorkContextCallback() {
@Override
public void fail() {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText(new String[]{"M-SwitchWorkspace", "Failed"}),
null, 0, UIManager.getIcon("OptionPane.errorIcon"));
}
Workspace workspace = DesignerWorkspaceGenerator.generate(selectedEnv);
if (workspace == null) {
JOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Inter.getLocText(new String[]{"FR-Designer_M-SwitchWorkspace", "Failed"}));
return false;
}
WorkContext.switchTo(workspace, new WorkContextCallback() {
@Override
public void success() {
public void done() {
DesignerEnvManager.getEnvManager().setCurEnvName(selectedName);
DesignUtils.refreshDesignerFrame();
}

Loading…
Cancel
Save