From 24743dbf2b3d90d48955ceff0b41c4556b87fd94 Mon Sep 17 00:00:00 2001 From: ju Date: Fri, 13 Jul 2018 17:45:21 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-9712=20=E5=88=87=E6=8D=A2=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=A4=B1=E8=B4=A5=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E5=90=AF=E5=8A=A8=E5=B9=B3=E5=8F=B0=E8=B5=B7?= =?UTF-8?q?=E4=B8=8D=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/file/SwitchExistEnv.java | 36 +++++++++---------- .../com/fr/design/env/RemoteWorkspace.java | 18 +++++++++- .../com/fr/design/mainframe/TemplatePane.java | 19 +++++----- 3 files changed, 45 insertions(+), 28 deletions(-) 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(); }