From cafb3d21303863dd97e58e1cd2369f9563756567 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 31 Mar 2023 18:25:30 +0800 Subject: [PATCH 1/6] =?UTF-8?q?REPORT-92953=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=B7=A5=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8E=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 4 ++++ .../src/main/java/com/fr/design/gui/ilist/JNameEdList.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) 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 d38def2836..9771239eab 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -116,6 +116,10 @@ public class EnvChangeEntrance { if (!checkValid) { return false; } + //如果是相同环境就不会做done操作,因此不会更新名字,需要先判断一下,如果是相同环境也要更新一下名字(可能会重命名) + if (AssistUtils.equals(WorkContext.getCurrent(), workspace)) { + DesignerEnvManager.getEnvManager().setCurEnvName(envName); + } WorkContext.switchTo(workspace, new WorkContextCallback() { @Override diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java index 4c530c0fcc..4a489e50f5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java @@ -175,7 +175,8 @@ public class JNameEdList extends UIList implements CellEditorListener { } public void setIllegalIndex(int index) { - setNameAt(NameInspector.ILLEGAL_NAME_HOLDER, index); + //环境如果重名会被命名为请重命名,这个”请重命名“也会重复,后面加个索引区别一下 + setNameAt(NameInspector.ILLEGAL_NAME_HOLDER + index, index); this.repaint(); } From 58109181e0e97126fed713fc3c621441812826ce Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 31 Mar 2023 18:31:06 +0800 Subject: [PATCH 2/6] =?UTF-8?q?REPORT-92953=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=B7=A5=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8E=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/gui/ilist/JNameEdList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java index 4a489e50f5..c12a225051 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java +++ b/designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java @@ -175,7 +175,7 @@ public class JNameEdList extends UIList implements CellEditorListener { } public void setIllegalIndex(int index) { - //环境如果重名会被命名为请重命名,这个”请重命名“也会重复,后面加个索引区别一下 + //环境如果重名会被命名为请重命名,这个请重命名也会重复,后面加个索引区别一下 setNameAt(NameInspector.ILLEGAL_NAME_HOLDER + index, index); this.repaint(); } From 07991b53e5801e9c6b30f4a24de1ca26b892b41f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 3 Apr 2023 15:15:09 +0800 Subject: [PATCH 3/6] =?UTF-8?q?REPORT-92953=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=B7=A5=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8E=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/EnvChangeEntrance.java | 102 ++++++++++++------ 1 file changed, 68 insertions(+), 34 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 9771239eab..59b8e8e533 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -120,19 +120,14 @@ public class EnvChangeEntrance { if (AssistUtils.equals(WorkContext.getCurrent(), workspace)) { DesignerEnvManager.getEnvManager().setCurEnvName(envName); } - - WorkContext.switchTo(workspace, new WorkContextCallback() { - @Override - public void done() { - DesignerEnvManager.getEnvManager().setCurEnvName(envName); - DesignUtils.refreshDesignerFrame(); - DesignTableDataManager.fireDSChanged(new HashMap()); - if (WorkContext.getCurrent().isLocal()) { - //初始化一下serverTray - ServerTray.init(); - } - } - }); + //如果是相同环境 + if (isSameEnv(workspace)) { + //目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了 + switch2SameEnv(envName); + } else { + //切换到新环境,做下封装 + switch2OtherEnv(workspace, envName); + } // REPORT-25688如果是war包部署的服务器,给与提示 if (WorkContext.getCurrent().isWarDeploy()) { FineJOptionPane.showMessageDialog(null, Toolkit.i18nText("Fine-Design_Basic_War_Deploy_Tip"), @@ -160,6 +155,41 @@ public class EnvChangeEntrance { return true; } + private void switch2OtherEnv(Workspace workspace, String envName) { + WorkContext.switchTo(workspace, new WorkContextCallback() { + @Override + public void done() { + DesignerEnvManager.getEnvManager().setCurEnvName(envName); + DesignUtils.refreshDesignerFrame(); + DesignTableDataManager.fireDSChanged(new HashMap()); + if (WorkContext.getCurrent().isLocal()) { + //初始化一下serverTray + ServerTray.init(); + } + } + }); + } + + /** + * 切换到相同环境要做的事情 + * + * @param envName 当前的环境名 + */ + private void switch2SameEnv(String envName) { + //当前环境名称可能重命名更改过,需要更新一下,防止启动失败 + DesignerEnvManager.getEnvManager().setCurEnvName(envName); + } + + /** + * 是否切换到相同环境 + * + * @param workspace 要切换的环境 + * @return 是则返回true + */ + private boolean isSameEnv(Workspace workspace) { + return AssistUtils.equals(WorkContext.getCurrent(), workspace); + } + /** * 这个功能留着,可能会加回来,先做注释处理 * 切换远程环境之前,进行版本检测,当版本不一致的时候,提示。 @@ -205,13 +235,14 @@ public class EnvChangeEntrance { return true; } - /** + /** * 对选择的环境做服务检测 + * * @param selectedEnv 选择的工作环境 */ public void showServiceDialog(DesignerWorkspaceInfo selectedEnv) throws Exception { //是否需要做服务校验 - if(needCheckBranch(selectedEnv)) { + if (needCheckBranch(selectedEnv)) { String localBranch; String remoteBranch; WorkspaceConnectionInfo connectionInfo = selectedEnv.getConnection(); @@ -232,18 +263,18 @@ public class EnvChangeEntrance { StringBuilder textBuilder = new StringBuilder(); for (Class clazz : noExistServiceSet) { WorkspaceAPI workspaceAPI = (WorkspaceAPI) clazz.getAnnotation(WorkspaceAPI.class); - if(workspaceAPI == null){ + if (workspaceAPI == null) { FineLoggerFactory.getLogger().info("workspace service {} get annotation failed", clazz); continue; } - if(workspaceAPI.ignore()){ + if (workspaceAPI.ignore()) { continue; } String descriptionOfCN = InterProviderFactory.getProvider().getLocText(workspaceAPI.description()); textBuilder.append(descriptionOfCN).append("\n"); } String areaText = textBuilder.toString(); - if(StringUtils.isEmpty(areaText)){ + if (StringUtils.isEmpty(areaText)) { return; } @@ -255,24 +286,25 @@ public class EnvChangeEntrance { * 判断是否需要做版本验证,判断依据为 * 1、选择的环境为远程环境 * 2、一个月内不弹出是否勾选 + * * @param selectedEnv 选择的环境 * @return */ - private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv){ - if(selectedEnv.getType() == DesignerWorkspaceType.Remote){ + private boolean needCheckBranch(DesignerWorkspaceInfo selectedEnv) { + if (selectedEnv.getType() == DesignerWorkspaceType.Remote) { try { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar = Calendar.getInstance(); - if(StringUtils.isEmpty(selectedEnv.getRemindTime())){ + if (StringUtils.isEmpty(selectedEnv.getRemindTime())) { return true; } //获取记录的时间 Date remindTime = format.parse(selectedEnv.getRemindTime()); calendar.setTime(remindTime); //获取一个月后的时间 - calendar.add(Calendar.MONTH,1); + calendar.add(Calendar.MONTH, 1); //与当前时间作对比,然后判断是否提示 - if(new Date().after(calendar.getTime())){ + if (new Date().after(calendar.getTime())) { return true; } } catch (ParseException e) { @@ -284,21 +316,22 @@ public class EnvChangeEntrance { /** * 获取不存在的服务列表 + * * @param info 环境连接信息 * @return 以Set形式返回不存在的服务 */ - public Set getNoExistServiceSet(WorkspaceConnectionInfo info){ + public Set getNoExistServiceSet(WorkspaceConnectionInfo info) { Set noExistServiceSet = new HashSet(); Set remoteServiceSet = new HashSet(); Set localServiceSet = FineObjectPool.getInstance().getServerPool().keySet(); try { JSONArray serviceArray = new FunctionalHttpRequest(info).getServiceList(); - for(int i = 0; i < serviceArray.size(); i++){ - try{ + for (int i = 0; i < serviceArray.size(); i++) { + try { Class clazz = Class.forName((String) serviceArray.get(i)); remoteServiceSet.add(clazz); - } catch (Exception e){ + } catch (Exception e) { continue; } } @@ -308,12 +341,12 @@ public class EnvChangeEntrance { } catch (WorkspaceConnectionException e) { FineLoggerFactory.getLogger().info(e.getMessage()); //根据本地的服务列表做逐一检测 - for(Class clazz : localServiceSet) { + for (Class clazz : localServiceSet) { Method testMethod = Reflect.on(Method.class).create(clazz, "connectTest", new Class[0], String.class, new Class[0], 1025, 8, null, null, null, null).get(); WorkspaceProxyPool proxyPool = (WorkspaceProxyPool) (((RemoteWorkspace) WorkContext.getCurrent()).getClient()).getPool(); Result result = proxyPool.testInvoker(testMethod); Exception invokeException = (Exception) result.getException(); - if(invokeException != null){ + if (invokeException != null) { Exception cause = (Exception) invokeException.getCause(); //获取被包装最底层的异常 while (cause != null) { @@ -321,25 +354,26 @@ public class EnvChangeEntrance { cause = (Exception) invokeException.getCause(); } //该异常表示服务不存在 - if(invokeException instanceof ClassNotFoundException){ + if (invokeException instanceof ClassNotFoundException) { noExistServiceSet.add(clazz); } } } return noExistServiceSet; - } catch (Exception e){ - FineLoggerFactory.getLogger().error(e.getMessage(),e); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); return noExistServiceSet; } } /** * 格式化分支版本号 + * * @param branch 初始的分支版本号 * @return 格式化后的版本号 */ - private String formatBranch(String branch){ - if(branch.contains("#")){ + private String formatBranch(String branch) { + if (branch.contains("#")) { return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13); } return branch; From b983e1ebdb00ba82cf01f43d925353618e0bd467 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 3 Apr 2023 15:15:46 +0800 Subject: [PATCH 4/6] =?UTF-8?q?REPORT-92953=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=B7=A5=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8E=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 59b8e8e533..cb78d56436 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -155,6 +155,12 @@ public class EnvChangeEntrance { return true; } + /** + * 切换到其他环境 + * + * @param workspace 要切换的环境 + * @param envName 要切换的环境名称 + */ private void switch2OtherEnv(Workspace workspace, String envName) { WorkContext.switchTo(workspace, new WorkContextCallback() { @Override From b68a0841db5c1d12015b297adfda388f4c0d5cd8 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 3 Apr 2023 15:16:38 +0800 Subject: [PATCH 5/6] =?UTF-8?q?REPORT-92953=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=B7=A5=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8E=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 4 ---- 1 file changed, 4 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 cb78d56436..4300ba039c 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -116,10 +116,6 @@ public class EnvChangeEntrance { if (!checkValid) { return false; } - //如果是相同环境就不会做done操作,因此不会更新名字,需要先判断一下,如果是相同环境也要更新一下名字(可能会重命名) - if (AssistUtils.equals(WorkContext.getCurrent(), workspace)) { - DesignerEnvManager.getEnvManager().setCurEnvName(envName); - } //如果是相同环境 if (isSameEnv(workspace)) { //目前切换到相同环境需要更新一下名字,后续如果有别的操作直接往里面加就行了 From dd8dec870b475f5beb2e4917fcfd5cc421170705 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 3 Apr 2023 15:31:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?REPORT-92953=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=BB=98=E8=AE=A4=E5=B7=A5=E7=A8=8B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=90=8E=E6=97=A0=E6=B3=95=E5=90=AF=E5=8A=A8=20?= =?UTF-8?q?=E6=94=B9=E4=B8=80=E4=B8=8B=E8=80=81=E4=BB=A3=E7=A0=81=E9=AD=94?= =?UTF-8?q?=E6=B3=95=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/design/EnvChangeEntrance.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 4300ba039c..17d7d5883e 100644 --- a/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java +++ b/designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java @@ -65,6 +65,9 @@ import java.util.HashSet; import static javax.swing.JOptionPane.QUESTION_MESSAGE; public class EnvChangeEntrance { + private static final String BRANCH_TAG = "#"; + private static final String BRANCH_BEGIN = "-"; + private static final int BRANCH_SUB_LENGTH = 13; public static EnvChangeEntrance getInstance() { return HOLDER.singleton; @@ -375,8 +378,8 @@ public class EnvChangeEntrance { * @return 格式化后的版本号 */ private String formatBranch(String branch) { - if (branch.contains("#")) { - return branch.substring(branch.lastIndexOf("-") + 1, branch.length() - 13); + if (branch.contains(BRANCH_TAG)) { + return branch.substring(branch.lastIndexOf(BRANCH_BEGIN) + 1, branch.length() - BRANCH_SUB_LENGTH); } return branch; }