From fcdb68c2fcedd59e37749bef190d8341f640497e Mon Sep 17 00:00:00 2001 From: Harrison Date: Fri, 21 Dec 2018 11:24:24 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-13074=20=E8=BF=9C=E7=A8=8B=E8=AE=BE?= =?UTF-8?q?=E8=AE=A1=E5=90=91=E4=B8=8B=E5=85=BC=E5=AE=B9=201.=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=80=E4=B8=8B=E9=80=BB=E8=BE=91=E3=80=82=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B9=E4=BE=BF=E7=90=86=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java index 725272a15..58f22d1b6 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -98,7 +98,8 @@ public class EnvChangeEntrance { return false; } - if (versionCheck(selectedEnv)) { + // 如果版本不一致,且确认 不继续 连接,这里返回 false. + if (!versionCheckAndConfirm(selectedEnv)) { return false; } @@ -151,37 +152,47 @@ public class EnvChangeEntrance { } /** - * 切换环境之前,进行版本检测,当版本不一致的时候,提示。 - * 当选择 ok 时,才继续。 + * 切换远程环境之前,进行版本检测,当版本不一致的时候,提示。 + * 当用户确认选择 ok 时,才继续。 * * @param selectedEnv 选择的环境 * @return 是否一致 + * 1. 非远程环境 , 返回 true + * 2. 远程环境 + * 2.1 不匹配, + * 2.1.1 当选择 ok , 返回 true + * 2.1.2 当选择 no, 返回 false + * 2.2 匹配, 返回 true * @throws Exception 异常 */ - private boolean versionCheck(DesignerWorkspaceInfo selectedEnv) throws Exception { + private boolean versionCheckAndConfirm(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())) { + if (AssistUtils.equals(serverVersion, WorkContext.getVersion())) { + return true; + } - final List 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); - } - }); + final List 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; - } + // 只有选择 yes , 这里的值才为 0, 返回 true + // 否着返回 false, 将不进行下面的连接操作。 + return result.size() != 0 && result.get(0) == 0; } - return false; + + return true; } /**