diff --git a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java b/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java index a07f428526..720cda9e76 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java +++ b/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"})); - } - }); } } } diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index c3d2e91c2c..d113752c3b 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -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); + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java b/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java index 4107a0538e..e3107c3b43 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/TemplatePane.java +++ b/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(); }