From c93febc5847b2a84189d2f179f2814dc5addb602 Mon Sep 17 00:00:00 2001 From: Maksim Date: Thu, 27 Feb 2020 16:16:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=90=8E=EF=BC=8C=E5=AF=B9=E5=88=9D=E5=A7=8B=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=81=9A=E4=B8=80=E6=AC=A1=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 78 ++++++++++++------- .../module/DesignerWorkspaceProvider.java | 16 ++++ 2 files changed, 64 insertions(+), 30 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 a60791c6b6..e998ad9047 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -132,36 +132,7 @@ public class EnvChangeEntrance { if (template != null) { template.refreshToolArea(); } - - //是否需要做服务校验 - if(needCheckBranch(selectedEnv)) { - String localBranch; - String remoteBranch; - localBranch = GeneralUtils.readFullBuildNO(); - try { - remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch(); - } catch (WorkspaceConnectionException e) { - remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(localBranch); - } - //通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本) - if (localBranch.contains("#") && localBranch.equals(remoteBranch)) { - //说明版本一致,仅做日志记录 - FineLoggerFactory.getLogger().info("Remote Designer version consistency"); - } else { - localBranch = formatBranch(localBranch); - remoteBranch = formatBranch(remoteBranch); - Set noExistServiceSet = getNoExistServiceSet(connectionInfo); - StringBuilder textBuilder = new StringBuilder(); - for (Class clazz : noExistServiceSet) { - WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); - String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); - textBuilder.append(descriptionOfCN).append("\n"); - } - String areaText = textBuilder.toString(); - CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); - dialog.setVisible(true); - } - } + serviceDialog(selectedEnv); } catch (WorkspaceAuthException | RegistEditionException e) { // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); @@ -238,6 +209,43 @@ public class EnvChangeEntrance { return true; } + /** + * 对选择的环境做服务检测 + * @param selectedEnv 选择的工作环境 + */ + public void serviceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { + //是否需要做服务校验 + if(needCheckBranch(selectedEnv)) { + String localBranch; + String remoteBranch; + WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); + localBranch = GeneralUtils.readFullBuildNO(); + try { + remoteBranch = new FunctionalHttpRequest(connectionInfo).getServerBranch(); + } catch (WorkspaceConnectionException e) { + remoteBranch = Toolkit.i18nText("Fine-Design_Basic_Remote_Design_Branch_Is_Old") + formatBranch(localBranch); + } + //通过是否包含#来避免当前版本为非安装版本(主要是内部开发版本) + if (localBranch.contains("#") && localBranch.equals(remoteBranch)) { + //说明版本一致,仅做日志记录 + FineLoggerFactory.getLogger().info("Remote Designer version consistency"); + } else { + localBranch = formatBranch(localBranch); + remoteBranch = formatBranch(remoteBranch); + Set noExistServiceSet = getNoExistServiceSet(connectionInfo); + StringBuilder textBuilder = new StringBuilder(); + for (Class clazz : noExistServiceSet) { + WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); + String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); + textBuilder.append(descriptionOfCN).append("\n"); + } + String areaText = textBuilder.toString(); + CheckServiceDialog dialog = new CheckServiceDialog(DesignerContext.getDesignerFrame(), areaText, localBranch, remoteBranch); + dialog.setVisible(true); + } + } + } + /** * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 @@ -249,6 +257,11 @@ public class EnvChangeEntrance { return selectedEnv.getType() == DesignerWorkspaceType.Remote; } + /** + * 获取不存在的服务列表 + * @param info 环境连接信息 + * @return 以Set形式返回不存在的服务 + */ public Set getNoExistServiceSet(WorkspaceConnectionInfo info){ Set noExistServiceSet = new HashSet(); Set remoteServiceSet = new HashSet(); @@ -295,6 +308,11 @@ public class EnvChangeEntrance { } } + /** + * 格式化分支版本号 + * @param branch 初始的分支版本号 + * @return 格式化后的版本号 + */ private String formatBranch(String branch){ if(branch.contains("#")){ return branch.substring(branch.lastIndexOf("#") + 1, branch.length() - 13); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index 7d63571ad6..c8622d6797 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -6,6 +6,10 @@ import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.env.DesignerWorkspaceGenerator; import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.LocalDesignerWorkspaceInfo; +import com.fr.event.Event; +import com.fr.event.EventDispatcher; +import com.fr.event.Listener; +import com.fr.event.Null; import com.fr.log.FineLoggerFactory; import com.fr.module.Activator; import com.fr.stable.StringUtils; @@ -54,6 +58,18 @@ public class DesignerWorkspaceProvider extends Activator { EnvChangeEntrance.getInstance().dealEvnExceptionWhenStartDesigner(); } else { WorkContext.switchTo(workspace); + //在设计器完全启动完成后,对初始环境进行一次服务检测,对主要功能无影响,异常仅做日志提示即可 + final DesignerWorkspaceInfo selectEnv = workspaceInfo; + EventDispatcher.listen(DesignerLaunchStatus.STARTUP_COMPLETE, new Listener() { + @Override + public void on(Event event, Null aNull) { + try { + EnvChangeEntrance.getInstance().serviceDialog(selectEnv); + } catch (Exception e) { + FineLoggerFactory.getLogger().warn("Check Service Failed"); + } + } + }); } } catch (Throwable e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); From f7a37afe40caba55bf2f005fc05fa3328461e9fb Mon Sep 17 00:00:00 2001 From: Maksim Date: Thu, 27 Feb 2020 17:59:04 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 4 ++-- .../java/com/fr/start/module/DesignerWorkspaceProvider.java | 2 +- 2 files changed, 3 insertions(+), 3 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 e998ad9047..48c5576bcc 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -132,7 +132,7 @@ public class EnvChangeEntrance { if (template != null) { template.refreshToolArea(); } - serviceDialog(selectedEnv); + showServiceDialog(selectedEnv); } catch (WorkspaceAuthException | RegistEditionException e) { // String title = Toolkit.i18nText("Fine-Design_Basic_Remote_Connect_Auth_Failed"); // String title = Toolkit.i18nText("Fine-Design_Basic_Lic_Does_Not_Support_Remote"); @@ -213,7 +213,7 @@ public class EnvChangeEntrance { * 对选择的环境做服务检测 * @param selectedEnv 选择的工作环境 */ - public void serviceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { + public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { //是否需要做服务校验 if(needCheckBranch(selectedEnv)) { String localBranch; diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java index c8622d6797..e0fc4dfe97 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerWorkspaceProvider.java @@ -64,7 +64,7 @@ public class DesignerWorkspaceProvider extends Activator { @Override public void on(Event event, Null aNull) { try { - EnvChangeEntrance.getInstance().serviceDialog(selectEnv); + EnvChangeEntrance.getInstance().showServiceDialog(selectEnv); } catch (Exception e) { FineLoggerFactory.getLogger().warn("Check Service Failed"); }